babylon.module.d.ts 5.0 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406
  1. declare module "babylonjs/types" {
  2. /** Alias type for value that can be null */
  3. export type Nullable<T> = T | null;
  4. /**
  5. * Alias type for number that are floats
  6. * @ignorenaming
  7. */
  8. export type float = number;
  9. /**
  10. * Alias type for number that are doubles.
  11. * @ignorenaming
  12. */
  13. export type double = number;
  14. /**
  15. * Alias type for number that are integer
  16. * @ignorenaming
  17. */
  18. export type int = number;
  19. /** Alias type for number array or Float32Array */
  20. export type FloatArray = number[] | Float32Array;
  21. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  22. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  23. /**
  24. * Alias for types that can be used by a Buffer or VertexBuffer.
  25. */
  26. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  27. /**
  28. * Alias type for primitive types
  29. * @ignorenaming
  30. */
  31. type Primitive = undefined | null | boolean | string | number | Function;
  32. /**
  33. * Type modifier to make all the properties of an object Readonly
  34. */
  35. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  36. /**
  37. * Type modifier to make all the properties of an object Readonly recursively
  38. */
  39. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  40. /** @hidden */
  41. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  42. }
  43. /** @hidden */
  44. /** @hidden */
  45. type DeepImmutableObject<T> = {
  46. readonly [K in keyof T]: DeepImmutable<T[K]>;
  47. };
  48. }
  49. declare module "babylonjs/Misc/arrayTools" {
  50. /**
  51. * Class containing a set of static utilities functions for arrays.
  52. */
  53. export class ArrayTools {
  54. /**
  55. * Returns an array of the given size filled with element built from the given constructor and the paramters
  56. * @param size the number of element to construct and put in the array
  57. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  58. * @returns a new array filled with new objects
  59. */
  60. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  61. }
  62. }
  63. declare module "babylonjs/Maths/math.scalar" {
  64. /**
  65. * Scalar computation library
  66. */
  67. export class Scalar {
  68. /**
  69. * Two pi constants convenient for computation.
  70. */
  71. static TwoPi: number;
  72. /**
  73. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  74. * @param a number
  75. * @param b number
  76. * @param epsilon (default = 1.401298E-45)
  77. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  78. */
  79. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  80. /**
  81. * Returns a string : the upper case translation of the number i to hexadecimal.
  82. * @param i number
  83. * @returns the upper case translation of the number i to hexadecimal.
  84. */
  85. static ToHex(i: number): string;
  86. /**
  87. * Returns -1 if value is negative and +1 is value is positive.
  88. * @param value the value
  89. * @returns the value itself if it's equal to zero.
  90. */
  91. static Sign(value: number): number;
  92. /**
  93. * Returns the value itself if it's between min and max.
  94. * Returns min if the value is lower than min.
  95. * Returns max if the value is greater than max.
  96. * @param value the value to clmap
  97. * @param min the min value to clamp to (default: 0)
  98. * @param max the max value to clamp to (default: 1)
  99. * @returns the clamped value
  100. */
  101. static Clamp(value: number, min?: number, max?: number): number;
  102. /**
  103. * the log2 of value.
  104. * @param value the value to compute log2 of
  105. * @returns the log2 of value.
  106. */
  107. static Log2(value: number): number;
  108. /**
  109. * Loops the value, so that it is never larger than length and never smaller than 0.
  110. *
  111. * This is similar to the modulo operator but it works with floating point numbers.
  112. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  113. * With t = 5 and length = 2.5, the result would be 0.0.
  114. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  115. * @param value the value
  116. * @param length the length
  117. * @returns the looped value
  118. */
  119. static Repeat(value: number, length: number): number;
  120. /**
  121. * Normalize the value between 0.0 and 1.0 using min and max values
  122. * @param value value to normalize
  123. * @param min max to normalize between
  124. * @param max min to normalize between
  125. * @returns the normalized value
  126. */
  127. static Normalize(value: number, min: number, max: number): number;
  128. /**
  129. * Denormalize the value from 0.0 and 1.0 using min and max values
  130. * @param normalized value to denormalize
  131. * @param min max to denormalize between
  132. * @param max min to denormalize between
  133. * @returns the denormalized value
  134. */
  135. static Denormalize(normalized: number, min: number, max: number): number;
  136. /**
  137. * Calculates the shortest difference between two given angles given in degrees.
  138. * @param current current angle in degrees
  139. * @param target target angle in degrees
  140. * @returns the delta
  141. */
  142. static DeltaAngle(current: number, target: number): number;
  143. /**
  144. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  145. * @param tx value
  146. * @param length length
  147. * @returns The returned value will move back and forth between 0 and length
  148. */
  149. static PingPong(tx: number, length: number): number;
  150. /**
  151. * Interpolates between min and max with smoothing at the limits.
  152. *
  153. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  154. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  155. * @param from from
  156. * @param to to
  157. * @param tx value
  158. * @returns the smooth stepped value
  159. */
  160. static SmoothStep(from: number, to: number, tx: number): number;
  161. /**
  162. * Moves a value current towards target.
  163. *
  164. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  165. * Negative values of maxDelta pushes the value away from target.
  166. * @param current current value
  167. * @param target target value
  168. * @param maxDelta max distance to move
  169. * @returns resulting value
  170. */
  171. static MoveTowards(current: number, target: number, maxDelta: number): number;
  172. /**
  173. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  174. *
  175. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  176. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  177. * @param current current value
  178. * @param target target value
  179. * @param maxDelta max distance to move
  180. * @returns resulting angle
  181. */
  182. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  183. /**
  184. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  185. * @param start start value
  186. * @param end target value
  187. * @param amount amount to lerp between
  188. * @returns the lerped value
  189. */
  190. static Lerp(start: number, end: number, amount: number): number;
  191. /**
  192. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  193. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  194. * @param start start value
  195. * @param end target value
  196. * @param amount amount to lerp between
  197. * @returns the lerped value
  198. */
  199. static LerpAngle(start: number, end: number, amount: number): number;
  200. /**
  201. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  202. * @param a start value
  203. * @param b target value
  204. * @param value value between a and b
  205. * @returns the inverseLerp value
  206. */
  207. static InverseLerp(a: number, b: number, value: number): number;
  208. /**
  209. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  210. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  211. * @param value1 spline value
  212. * @param tangent1 spline value
  213. * @param value2 spline value
  214. * @param tangent2 spline value
  215. * @param amount input value
  216. * @returns hermite result
  217. */
  218. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  219. /**
  220. * Returns a random float number between and min and max values
  221. * @param min min value of random
  222. * @param max max value of random
  223. * @returns random value
  224. */
  225. static RandomRange(min: number, max: number): number;
  226. /**
  227. * This function returns percentage of a number in a given range.
  228. *
  229. * RangeToPercent(40,20,60) will return 0.5 (50%)
  230. * RangeToPercent(34,0,100) will return 0.34 (34%)
  231. * @param number to convert to percentage
  232. * @param min min range
  233. * @param max max range
  234. * @returns the percentage
  235. */
  236. static RangeToPercent(number: number, min: number, max: number): number;
  237. /**
  238. * This function returns number that corresponds to the percentage in a given range.
  239. *
  240. * PercentToRange(0.34,0,100) will return 34.
  241. * @param percent to convert to number
  242. * @param min min range
  243. * @param max max range
  244. * @returns the number
  245. */
  246. static PercentToRange(percent: number, min: number, max: number): number;
  247. /**
  248. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  249. * @param angle The angle to normalize in radian.
  250. * @return The converted angle.
  251. */
  252. static NormalizeRadians(angle: number): number;
  253. }
  254. }
  255. declare module "babylonjs/Maths/math" {
  256. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  257. /**
  258. * Constant used to convert a value to gamma space
  259. * @ignorenaming
  260. */
  261. export const ToGammaSpace: number;
  262. /**
  263. * Constant used to convert a value to linear space
  264. * @ignorenaming
  265. */
  266. export const ToLinearSpace = 2.2;
  267. /**
  268. * Constant used to define the minimal number value in Babylon.js
  269. * @ignorenaming
  270. */
  271. let Epsilon: number;
  272. export { Epsilon };
  273. /**
  274. * Class used to hold a RBG color
  275. */
  276. export class Color3 {
  277. /**
  278. * Defines the red component (between 0 and 1, default is 0)
  279. */
  280. r: number;
  281. /**
  282. * Defines the green component (between 0 and 1, default is 0)
  283. */
  284. g: number;
  285. /**
  286. * Defines the blue component (between 0 and 1, default is 0)
  287. */
  288. b: number;
  289. /**
  290. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  291. * @param r defines the red component (between 0 and 1, default is 0)
  292. * @param g defines the green component (between 0 and 1, default is 0)
  293. * @param b defines the blue component (between 0 and 1, default is 0)
  294. */
  295. constructor(
  296. /**
  297. * Defines the red component (between 0 and 1, default is 0)
  298. */
  299. r?: number,
  300. /**
  301. * Defines the green component (between 0 and 1, default is 0)
  302. */
  303. g?: number,
  304. /**
  305. * Defines the blue component (between 0 and 1, default is 0)
  306. */
  307. b?: number);
  308. /**
  309. * Creates a string with the Color3 current values
  310. * @returns the string representation of the Color3 object
  311. */
  312. toString(): string;
  313. /**
  314. * Returns the string "Color3"
  315. * @returns "Color3"
  316. */
  317. getClassName(): string;
  318. /**
  319. * Compute the Color3 hash code
  320. * @returns an unique number that can be used to hash Color3 objects
  321. */
  322. getHashCode(): number;
  323. /**
  324. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  325. * @param array defines the array where to store the r,g,b components
  326. * @param index defines an optional index in the target array to define where to start storing values
  327. * @returns the current Color3 object
  328. */
  329. toArray(array: FloatArray, index?: number): Color3;
  330. /**
  331. * Returns a new Color4 object from the current Color3 and the given alpha
  332. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  333. * @returns a new Color4 object
  334. */
  335. toColor4(alpha?: number): Color4;
  336. /**
  337. * Returns a new array populated with 3 numeric elements : red, green and blue values
  338. * @returns the new array
  339. */
  340. asArray(): number[];
  341. /**
  342. * Returns the luminance value
  343. * @returns a float value
  344. */
  345. toLuminance(): number;
  346. /**
  347. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  348. * @param otherColor defines the second operand
  349. * @returns the new Color3 object
  350. */
  351. multiply(otherColor: DeepImmutable<Color3>): Color3;
  352. /**
  353. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  354. * @param otherColor defines the second operand
  355. * @param result defines the Color3 object where to store the result
  356. * @returns the current Color3
  357. */
  358. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  359. /**
  360. * Determines equality between Color3 objects
  361. * @param otherColor defines the second operand
  362. * @returns true if the rgb values are equal to the given ones
  363. */
  364. equals(otherColor: DeepImmutable<Color3>): boolean;
  365. /**
  366. * Determines equality between the current Color3 object and a set of r,b,g values
  367. * @param r defines the red component to check
  368. * @param g defines the green component to check
  369. * @param b defines the blue component to check
  370. * @returns true if the rgb values are equal to the given ones
  371. */
  372. equalsFloats(r: number, g: number, b: number): boolean;
  373. /**
  374. * Multiplies in place each rgb value by scale
  375. * @param scale defines the scaling factor
  376. * @returns the updated Color3
  377. */
  378. scale(scale: number): Color3;
  379. /**
  380. * Multiplies the rgb values by scale and stores the result into "result"
  381. * @param scale defines the scaling factor
  382. * @param result defines the Color3 object where to store the result
  383. * @returns the unmodified current Color3
  384. */
  385. scaleToRef(scale: number, result: Color3): Color3;
  386. /**
  387. * Scale the current Color3 values by a factor and add the result to a given Color3
  388. * @param scale defines the scale factor
  389. * @param result defines color to store the result into
  390. * @returns the unmodified current Color3
  391. */
  392. scaleAndAddToRef(scale: number, result: Color3): Color3;
  393. /**
  394. * Clamps the rgb values by the min and max values and stores the result into "result"
  395. * @param min defines minimum clamping value (default is 0)
  396. * @param max defines maximum clamping value (default is 1)
  397. * @param result defines color to store the result into
  398. * @returns the original Color3
  399. */
  400. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  401. /**
  402. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  403. * @param otherColor defines the second operand
  404. * @returns the new Color3
  405. */
  406. add(otherColor: DeepImmutable<Color3>): Color3;
  407. /**
  408. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  409. * @param otherColor defines the second operand
  410. * @param result defines Color3 object to store the result into
  411. * @returns the unmodified current Color3
  412. */
  413. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  414. /**
  415. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  416. * @param otherColor defines the second operand
  417. * @returns the new Color3
  418. */
  419. subtract(otherColor: DeepImmutable<Color3>): Color3;
  420. /**
  421. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  422. * @param otherColor defines the second operand
  423. * @param result defines Color3 object to store the result into
  424. * @returns the unmodified current Color3
  425. */
  426. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  427. /**
  428. * Copy the current object
  429. * @returns a new Color3 copied the current one
  430. */
  431. clone(): Color3;
  432. /**
  433. * Copies the rgb values from the source in the current Color3
  434. * @param source defines the source Color3 object
  435. * @returns the updated Color3 object
  436. */
  437. copyFrom(source: DeepImmutable<Color3>): Color3;
  438. /**
  439. * Updates the Color3 rgb values from the given floats
  440. * @param r defines the red component to read from
  441. * @param g defines the green component to read from
  442. * @param b defines the blue component to read from
  443. * @returns the current Color3 object
  444. */
  445. copyFromFloats(r: number, g: number, b: number): Color3;
  446. /**
  447. * Updates the Color3 rgb values from the given floats
  448. * @param r defines the red component to read from
  449. * @param g defines the green component to read from
  450. * @param b defines the blue component to read from
  451. * @returns the current Color3 object
  452. */
  453. set(r: number, g: number, b: number): Color3;
  454. /**
  455. * Compute the Color3 hexadecimal code as a string
  456. * @returns a string containing the hexadecimal representation of the Color3 object
  457. */
  458. toHexString(): string;
  459. /**
  460. * Computes a new Color3 converted from the current one to linear space
  461. * @returns a new Color3 object
  462. */
  463. toLinearSpace(): Color3;
  464. /**
  465. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  466. * @param convertedColor defines the Color3 object where to store the linear space version
  467. * @returns the unmodified Color3
  468. */
  469. toLinearSpaceToRef(convertedColor: Color3): Color3;
  470. /**
  471. * Computes a new Color3 converted from the current one to gamma space
  472. * @returns a new Color3 object
  473. */
  474. toGammaSpace(): Color3;
  475. /**
  476. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  477. * @param convertedColor defines the Color3 object where to store the gamma space version
  478. * @returns the unmodified Color3
  479. */
  480. toGammaSpaceToRef(convertedColor: Color3): Color3;
  481. private static _BlackReadOnly;
  482. /**
  483. * Creates a new Color3 from the string containing valid hexadecimal values
  484. * @param hex defines a string containing valid hexadecimal values
  485. * @returns a new Color3 object
  486. */
  487. static FromHexString(hex: string): Color3;
  488. /**
  489. * Creates a new Color3 from the starting index of the given array
  490. * @param array defines the source array
  491. * @param offset defines an offset in the source array
  492. * @returns a new Color3 object
  493. */
  494. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  495. /**
  496. * Creates a new Color3 from integer values (< 256)
  497. * @param r defines the red component to read from (value between 0 and 255)
  498. * @param g defines the green component to read from (value between 0 and 255)
  499. * @param b defines the blue component to read from (value between 0 and 255)
  500. * @returns a new Color3 object
  501. */
  502. static FromInts(r: number, g: number, b: number): Color3;
  503. /**
  504. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  505. * @param start defines the start Color3 value
  506. * @param end defines the end Color3 value
  507. * @param amount defines the gradient value between start and end
  508. * @returns a new Color3 object
  509. */
  510. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  511. /**
  512. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  513. * @param left defines the start value
  514. * @param right defines the end value
  515. * @param amount defines the gradient factor
  516. * @param result defines the Color3 object where to store the result
  517. */
  518. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  519. /**
  520. * Returns a Color3 value containing a red color
  521. * @returns a new Color3 object
  522. */
  523. static Red(): Color3;
  524. /**
  525. * Returns a Color3 value containing a green color
  526. * @returns a new Color3 object
  527. */
  528. static Green(): Color3;
  529. /**
  530. * Returns a Color3 value containing a blue color
  531. * @returns a new Color3 object
  532. */
  533. static Blue(): Color3;
  534. /**
  535. * Returns a Color3 value containing a black color
  536. * @returns a new Color3 object
  537. */
  538. static Black(): Color3;
  539. /**
  540. * Gets a Color3 value containing a black color that must not be updated
  541. */
  542. static readonly BlackReadOnly: DeepImmutable<Color3>;
  543. /**
  544. * Returns a Color3 value containing a white color
  545. * @returns a new Color3 object
  546. */
  547. static White(): Color3;
  548. /**
  549. * Returns a Color3 value containing a purple color
  550. * @returns a new Color3 object
  551. */
  552. static Purple(): Color3;
  553. /**
  554. * Returns a Color3 value containing a magenta color
  555. * @returns a new Color3 object
  556. */
  557. static Magenta(): Color3;
  558. /**
  559. * Returns a Color3 value containing a yellow color
  560. * @returns a new Color3 object
  561. */
  562. static Yellow(): Color3;
  563. /**
  564. * Returns a Color3 value containing a gray color
  565. * @returns a new Color3 object
  566. */
  567. static Gray(): Color3;
  568. /**
  569. * Returns a Color3 value containing a teal color
  570. * @returns a new Color3 object
  571. */
  572. static Teal(): Color3;
  573. /**
  574. * Returns a Color3 value containing a random color
  575. * @returns a new Color3 object
  576. */
  577. static Random(): Color3;
  578. }
  579. /**
  580. * Class used to hold a RBGA color
  581. */
  582. export class Color4 {
  583. /**
  584. * Defines the red component (between 0 and 1, default is 0)
  585. */
  586. r: number;
  587. /**
  588. * Defines the green component (between 0 and 1, default is 0)
  589. */
  590. g: number;
  591. /**
  592. * Defines the blue component (between 0 and 1, default is 0)
  593. */
  594. b: number;
  595. /**
  596. * Defines the alpha component (between 0 and 1, default is 1)
  597. */
  598. a: number;
  599. /**
  600. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  601. * @param r defines the red component (between 0 and 1, default is 0)
  602. * @param g defines the green component (between 0 and 1, default is 0)
  603. * @param b defines the blue component (between 0 and 1, default is 0)
  604. * @param a defines the alpha component (between 0 and 1, default is 1)
  605. */
  606. constructor(
  607. /**
  608. * Defines the red component (between 0 and 1, default is 0)
  609. */
  610. r?: number,
  611. /**
  612. * Defines the green component (between 0 and 1, default is 0)
  613. */
  614. g?: number,
  615. /**
  616. * Defines the blue component (between 0 and 1, default is 0)
  617. */
  618. b?: number,
  619. /**
  620. * Defines the alpha component (between 0 and 1, default is 1)
  621. */
  622. a?: number);
  623. /**
  624. * Adds in place the given Color4 values to the current Color4 object
  625. * @param right defines the second operand
  626. * @returns the current updated Color4 object
  627. */
  628. addInPlace(right: DeepImmutable<Color4>): Color4;
  629. /**
  630. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  631. * @returns the new array
  632. */
  633. asArray(): number[];
  634. /**
  635. * Stores from the starting index in the given array the Color4 successive values
  636. * @param array defines the array where to store the r,g,b components
  637. * @param index defines an optional index in the target array to define where to start storing values
  638. * @returns the current Color4 object
  639. */
  640. toArray(array: number[], index?: number): Color4;
  641. /**
  642. * Determines equality between Color4 objects
  643. * @param otherColor defines the second operand
  644. * @returns true if the rgba values are equal to the given ones
  645. */
  646. equals(otherColor: DeepImmutable<Color4>): boolean;
  647. /**
  648. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  649. * @param right defines the second operand
  650. * @returns a new Color4 object
  651. */
  652. add(right: DeepImmutable<Color4>): Color4;
  653. /**
  654. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  655. * @param right defines the second operand
  656. * @returns a new Color4 object
  657. */
  658. subtract(right: DeepImmutable<Color4>): Color4;
  659. /**
  660. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  661. * @param right defines the second operand
  662. * @param result defines the Color4 object where to store the result
  663. * @returns the current Color4 object
  664. */
  665. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  666. /**
  667. * Creates a new Color4 with the current Color4 values multiplied by scale
  668. * @param scale defines the scaling factor to apply
  669. * @returns a new Color4 object
  670. */
  671. scale(scale: number): Color4;
  672. /**
  673. * Multiplies the current Color4 values by scale and stores the result in "result"
  674. * @param scale defines the scaling factor to apply
  675. * @param result defines the Color4 object where to store the result
  676. * @returns the current unmodified Color4
  677. */
  678. scaleToRef(scale: number, result: Color4): Color4;
  679. /**
  680. * Scale the current Color4 values by a factor and add the result to a given Color4
  681. * @param scale defines the scale factor
  682. * @param result defines the Color4 object where to store the result
  683. * @returns the unmodified current Color4
  684. */
  685. scaleAndAddToRef(scale: number, result: Color4): Color4;
  686. /**
  687. * Clamps the rgb values by the min and max values and stores the result into "result"
  688. * @param min defines minimum clamping value (default is 0)
  689. * @param max defines maximum clamping value (default is 1)
  690. * @param result defines color to store the result into.
  691. * @returns the cuurent Color4
  692. */
  693. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  694. /**
  695. * Multipy an Color4 value by another and return a new Color4 object
  696. * @param color defines the Color4 value to multiply by
  697. * @returns a new Color4 object
  698. */
  699. multiply(color: Color4): Color4;
  700. /**
  701. * Multipy a Color4 value by another and push the result in a reference value
  702. * @param color defines the Color4 value to multiply by
  703. * @param result defines the Color4 to fill the result in
  704. * @returns the result Color4
  705. */
  706. multiplyToRef(color: Color4, result: Color4): Color4;
  707. /**
  708. * Creates a string with the Color4 current values
  709. * @returns the string representation of the Color4 object
  710. */
  711. toString(): string;
  712. /**
  713. * Returns the string "Color4"
  714. * @returns "Color4"
  715. */
  716. getClassName(): string;
  717. /**
  718. * Compute the Color4 hash code
  719. * @returns an unique number that can be used to hash Color4 objects
  720. */
  721. getHashCode(): number;
  722. /**
  723. * Creates a new Color4 copied from the current one
  724. * @returns a new Color4 object
  725. */
  726. clone(): Color4;
  727. /**
  728. * Copies the given Color4 values into the current one
  729. * @param source defines the source Color4 object
  730. * @returns the current updated Color4 object
  731. */
  732. copyFrom(source: Color4): Color4;
  733. /**
  734. * Copies the given float values into the current one
  735. * @param r defines the red component to read from
  736. * @param g defines the green component to read from
  737. * @param b defines the blue component to read from
  738. * @param a defines the alpha component to read from
  739. * @returns the current updated Color4 object
  740. */
  741. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  742. /**
  743. * Copies the given float values into the current one
  744. * @param r defines the red component to read from
  745. * @param g defines the green component to read from
  746. * @param b defines the blue component to read from
  747. * @param a defines the alpha component to read from
  748. * @returns the current updated Color4 object
  749. */
  750. set(r: number, g: number, b: number, a: number): Color4;
  751. /**
  752. * Compute the Color4 hexadecimal code as a string
  753. * @returns a string containing the hexadecimal representation of the Color4 object
  754. */
  755. toHexString(): string;
  756. /**
  757. * Computes a new Color4 converted from the current one to linear space
  758. * @returns a new Color4 object
  759. */
  760. toLinearSpace(): Color4;
  761. /**
  762. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  763. * @param convertedColor defines the Color4 object where to store the linear space version
  764. * @returns the unmodified Color4
  765. */
  766. toLinearSpaceToRef(convertedColor: Color4): Color4;
  767. /**
  768. * Computes a new Color4 converted from the current one to gamma space
  769. * @returns a new Color4 object
  770. */
  771. toGammaSpace(): Color4;
  772. /**
  773. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  774. * @param convertedColor defines the Color4 object where to store the gamma space version
  775. * @returns the unmodified Color4
  776. */
  777. toGammaSpaceToRef(convertedColor: Color4): Color4;
  778. /**
  779. * Creates a new Color4 from the string containing valid hexadecimal values
  780. * @param hex defines a string containing valid hexadecimal values
  781. * @returns a new Color4 object
  782. */
  783. static FromHexString(hex: string): Color4;
  784. /**
  785. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  786. * @param left defines the start value
  787. * @param right defines the end value
  788. * @param amount defines the gradient factor
  789. * @returns a new Color4 object
  790. */
  791. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  792. /**
  793. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  794. * @param left defines the start value
  795. * @param right defines the end value
  796. * @param amount defines the gradient factor
  797. * @param result defines the Color4 object where to store data
  798. */
  799. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  800. /**
  801. * Creates a new Color4 from a Color3 and an alpha value
  802. * @param color3 defines the source Color3 to read from
  803. * @param alpha defines the alpha component (1.0 by default)
  804. * @returns a new Color4 object
  805. */
  806. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  807. /**
  808. * Creates a new Color4 from the starting index element of the given array
  809. * @param array defines the source array to read from
  810. * @param offset defines the offset in the source array
  811. * @returns a new Color4 object
  812. */
  813. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  814. /**
  815. * Creates a new Color3 from integer values (< 256)
  816. * @param r defines the red component to read from (value between 0 and 255)
  817. * @param g defines the green component to read from (value between 0 and 255)
  818. * @param b defines the blue component to read from (value between 0 and 255)
  819. * @param a defines the alpha component to read from (value between 0 and 255)
  820. * @returns a new Color3 object
  821. */
  822. static FromInts(r: number, g: number, b: number, a: number): Color4;
  823. /**
  824. * Check the content of a given array and convert it to an array containing RGBA data
  825. * If the original array was already containing count * 4 values then it is returned directly
  826. * @param colors defines the array to check
  827. * @param count defines the number of RGBA data to expect
  828. * @returns an array containing count * 4 values (RGBA)
  829. */
  830. static CheckColors4(colors: number[], count: number): number[];
  831. }
  832. /**
  833. * Class representing a vector containing 2 coordinates
  834. */
  835. export class Vector2 {
  836. /** defines the first coordinate */
  837. x: number;
  838. /** defines the second coordinate */
  839. y: number;
  840. /**
  841. * Creates a new Vector2 from the given x and y coordinates
  842. * @param x defines the first coordinate
  843. * @param y defines the second coordinate
  844. */
  845. constructor(
  846. /** defines the first coordinate */
  847. x?: number,
  848. /** defines the second coordinate */
  849. y?: number);
  850. /**
  851. * Gets a string with the Vector2 coordinates
  852. * @returns a string with the Vector2 coordinates
  853. */
  854. toString(): string;
  855. /**
  856. * Gets class name
  857. * @returns the string "Vector2"
  858. */
  859. getClassName(): string;
  860. /**
  861. * Gets current vector hash code
  862. * @returns the Vector2 hash code as a number
  863. */
  864. getHashCode(): number;
  865. /**
  866. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  867. * @param array defines the source array
  868. * @param index defines the offset in source array
  869. * @returns the current Vector2
  870. */
  871. toArray(array: FloatArray, index?: number): Vector2;
  872. /**
  873. * Copy the current vector to an array
  874. * @returns a new array with 2 elements: the Vector2 coordinates.
  875. */
  876. asArray(): number[];
  877. /**
  878. * Sets the Vector2 coordinates with the given Vector2 coordinates
  879. * @param source defines the source Vector2
  880. * @returns the current updated Vector2
  881. */
  882. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  883. /**
  884. * Sets the Vector2 coordinates with the given floats
  885. * @param x defines the first coordinate
  886. * @param y defines the second coordinate
  887. * @returns the current updated Vector2
  888. */
  889. copyFromFloats(x: number, y: number): Vector2;
  890. /**
  891. * Sets the Vector2 coordinates with the given floats
  892. * @param x defines the first coordinate
  893. * @param y defines the second coordinate
  894. * @returns the current updated Vector2
  895. */
  896. set(x: number, y: number): Vector2;
  897. /**
  898. * Add another vector with the current one
  899. * @param otherVector defines the other vector
  900. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  901. */
  902. add(otherVector: DeepImmutable<Vector2>): Vector2;
  903. /**
  904. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  905. * @param otherVector defines the other vector
  906. * @param result defines the target vector
  907. * @returns the unmodified current Vector2
  908. */
  909. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  910. /**
  911. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  912. * @param otherVector defines the other vector
  913. * @returns the current updated Vector2
  914. */
  915. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  916. /**
  917. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  918. * @param otherVector defines the other vector
  919. * @returns a new Vector2
  920. */
  921. addVector3(otherVector: Vector3): Vector2;
  922. /**
  923. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  924. * @param otherVector defines the other vector
  925. * @returns a new Vector2
  926. */
  927. subtract(otherVector: Vector2): Vector2;
  928. /**
  929. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  930. * @param otherVector defines the other vector
  931. * @param result defines the target vector
  932. * @returns the unmodified current Vector2
  933. */
  934. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  935. /**
  936. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  937. * @param otherVector defines the other vector
  938. * @returns the current updated Vector2
  939. */
  940. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  941. /**
  942. * Multiplies in place the current Vector2 coordinates by the given ones
  943. * @param otherVector defines the other vector
  944. * @returns the current updated Vector2
  945. */
  946. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  947. /**
  948. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  949. * @param otherVector defines the other vector
  950. * @returns a new Vector2
  951. */
  952. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  953. /**
  954. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  955. * @param otherVector defines the other vector
  956. * @param result defines the target vector
  957. * @returns the unmodified current Vector2
  958. */
  959. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  960. /**
  961. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  962. * @param x defines the first coordinate
  963. * @param y defines the second coordinate
  964. * @returns a new Vector2
  965. */
  966. multiplyByFloats(x: number, y: number): Vector2;
  967. /**
  968. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  969. * @param otherVector defines the other vector
  970. * @returns a new Vector2
  971. */
  972. divide(otherVector: Vector2): Vector2;
  973. /**
  974. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  975. * @param otherVector defines the other vector
  976. * @param result defines the target vector
  977. * @returns the unmodified current Vector2
  978. */
  979. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  980. /**
  981. * Divides the current Vector2 coordinates by the given ones
  982. * @param otherVector defines the other vector
  983. * @returns the current updated Vector2
  984. */
  985. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  986. /**
  987. * Gets a new Vector2 with current Vector2 negated coordinates
  988. * @returns a new Vector2
  989. */
  990. negate(): Vector2;
  991. /**
  992. * Multiply the Vector2 coordinates by scale
  993. * @param scale defines the scaling factor
  994. * @returns the current updated Vector2
  995. */
  996. scaleInPlace(scale: number): Vector2;
  997. /**
  998. * Returns a new Vector2 scaled by "scale" from the current Vector2
  999. * @param scale defines the scaling factor
  1000. * @returns a new Vector2
  1001. */
  1002. scale(scale: number): Vector2;
  1003. /**
  1004. * Scale the current Vector2 values by a factor to a given Vector2
  1005. * @param scale defines the scale factor
  1006. * @param result defines the Vector2 object where to store the result
  1007. * @returns the unmodified current Vector2
  1008. */
  1009. scaleToRef(scale: number, result: Vector2): Vector2;
  1010. /**
  1011. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  1012. * @param scale defines the scale factor
  1013. * @param result defines the Vector2 object where to store the result
  1014. * @returns the unmodified current Vector2
  1015. */
  1016. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  1017. /**
  1018. * Gets a boolean if two vectors are equals
  1019. * @param otherVector defines the other vector
  1020. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  1021. */
  1022. equals(otherVector: DeepImmutable<Vector2>): boolean;
  1023. /**
  1024. * Gets a boolean if two vectors are equals (using an epsilon value)
  1025. * @param otherVector defines the other vector
  1026. * @param epsilon defines the minimal distance to consider equality
  1027. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  1028. */
  1029. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  1030. /**
  1031. * Gets a new Vector2 from current Vector2 floored values
  1032. * @returns a new Vector2
  1033. */
  1034. floor(): Vector2;
  1035. /**
  1036. * Gets a new Vector2 from current Vector2 floored values
  1037. * @returns a new Vector2
  1038. */
  1039. fract(): Vector2;
  1040. /**
  1041. * Gets the length of the vector
  1042. * @returns the vector length (float)
  1043. */
  1044. length(): number;
  1045. /**
  1046. * Gets the vector squared length
  1047. * @returns the vector squared length (float)
  1048. */
  1049. lengthSquared(): number;
  1050. /**
  1051. * Normalize the vector
  1052. * @returns the current updated Vector2
  1053. */
  1054. normalize(): Vector2;
  1055. /**
  1056. * Gets a new Vector2 copied from the Vector2
  1057. * @returns a new Vector2
  1058. */
  1059. clone(): Vector2;
  1060. /**
  1061. * Gets a new Vector2(0, 0)
  1062. * @returns a new Vector2
  1063. */
  1064. static Zero(): Vector2;
  1065. /**
  1066. * Gets a new Vector2(1, 1)
  1067. * @returns a new Vector2
  1068. */
  1069. static One(): Vector2;
  1070. /**
  1071. * Gets a new Vector2 set from the given index element of the given array
  1072. * @param array defines the data source
  1073. * @param offset defines the offset in the data source
  1074. * @returns a new Vector2
  1075. */
  1076. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  1077. /**
  1078. * Sets "result" from the given index element of the given array
  1079. * @param array defines the data source
  1080. * @param offset defines the offset in the data source
  1081. * @param result defines the target vector
  1082. */
  1083. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  1084. /**
  1085. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  1086. * @param value1 defines 1st point of control
  1087. * @param value2 defines 2nd point of control
  1088. * @param value3 defines 3rd point of control
  1089. * @param value4 defines 4th point of control
  1090. * @param amount defines the interpolation factor
  1091. * @returns a new Vector2
  1092. */
  1093. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  1094. /**
  1095. * Returns a new Vector2 set with same the coordinates than "value" ones if the vector "value" is in the square defined by "min" and "max".
  1096. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  1097. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  1098. * @param value defines the value to clamp
  1099. * @param min defines the lower limit
  1100. * @param max defines the upper limit
  1101. * @returns a new Vector2
  1102. */
  1103. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  1104. /**
  1105. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  1106. * @param value1 defines the 1st control point
  1107. * @param tangent1 defines the outgoing tangent
  1108. * @param value2 defines the 2nd control point
  1109. * @param tangent2 defines the incoming tangent
  1110. * @param amount defines the interpolation factor
  1111. * @returns a new Vector2
  1112. */
  1113. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  1114. /**
  1115. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  1116. * @param start defines the start vector
  1117. * @param end defines the end vector
  1118. * @param amount defines the interpolation factor
  1119. * @returns a new Vector2
  1120. */
  1121. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  1122. /**
  1123. * Gets the dot product of the vector "left" and the vector "right"
  1124. * @param left defines first vector
  1125. * @param right defines second vector
  1126. * @returns the dot product (float)
  1127. */
  1128. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  1129. /**
  1130. * Returns a new Vector2 equal to the normalized given vector
  1131. * @param vector defines the vector to normalize
  1132. * @returns a new Vector2
  1133. */
  1134. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  1135. /**
  1136. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  1137. * @param left defines 1st vector
  1138. * @param right defines 2nd vector
  1139. * @returns a new Vector2
  1140. */
  1141. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1142. /**
  1143. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  1144. * @param left defines 1st vector
  1145. * @param right defines 2nd vector
  1146. * @returns a new Vector2
  1147. */
  1148. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  1149. /**
  1150. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  1151. * @param vector defines the vector to transform
  1152. * @param transformation defines the matrix to apply
  1153. * @returns a new Vector2
  1154. */
  1155. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  1156. /**
  1157. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  1158. * @param vector defines the vector to transform
  1159. * @param transformation defines the matrix to apply
  1160. * @param result defines the target vector
  1161. */
  1162. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  1163. /**
  1164. * Determines if a given vector is included in a triangle
  1165. * @param p defines the vector to test
  1166. * @param p0 defines 1st triangle point
  1167. * @param p1 defines 2nd triangle point
  1168. * @param p2 defines 3rd triangle point
  1169. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  1170. */
  1171. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  1172. /**
  1173. * Gets the distance between the vectors "value1" and "value2"
  1174. * @param value1 defines first vector
  1175. * @param value2 defines second vector
  1176. * @returns the distance between vectors
  1177. */
  1178. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1179. /**
  1180. * Returns the squared distance between the vectors "value1" and "value2"
  1181. * @param value1 defines first vector
  1182. * @param value2 defines second vector
  1183. * @returns the squared distance between vectors
  1184. */
  1185. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  1186. /**
  1187. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  1188. * @param value1 defines first vector
  1189. * @param value2 defines second vector
  1190. * @returns a new Vector2
  1191. */
  1192. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  1193. /**
  1194. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  1195. * @param p defines the middle point
  1196. * @param segA defines one point of the segment
  1197. * @param segB defines the other point of the segment
  1198. * @returns the shortest distance
  1199. */
  1200. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  1201. }
  1202. /**
  1203. * Classed used to store (x,y,z) vector representation
  1204. * A Vector3 is the main object used in 3D geometry
  1205. * It can represent etiher the coordinates of a point the space, either a direction
  1206. * Reminder: js uses a left handed forward facing system
  1207. */
  1208. export class Vector3 {
  1209. /**
  1210. * Defines the first coordinates (on X axis)
  1211. */
  1212. x: number;
  1213. /**
  1214. * Defines the second coordinates (on Y axis)
  1215. */
  1216. y: number;
  1217. /**
  1218. * Defines the third coordinates (on Z axis)
  1219. */
  1220. z: number;
  1221. private static _UpReadOnly;
  1222. /**
  1223. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  1224. * @param x defines the first coordinates (on X axis)
  1225. * @param y defines the second coordinates (on Y axis)
  1226. * @param z defines the third coordinates (on Z axis)
  1227. */
  1228. constructor(
  1229. /**
  1230. * Defines the first coordinates (on X axis)
  1231. */
  1232. x?: number,
  1233. /**
  1234. * Defines the second coordinates (on Y axis)
  1235. */
  1236. y?: number,
  1237. /**
  1238. * Defines the third coordinates (on Z axis)
  1239. */
  1240. z?: number);
  1241. /**
  1242. * Creates a string representation of the Vector3
  1243. * @returns a string with the Vector3 coordinates.
  1244. */
  1245. toString(): string;
  1246. /**
  1247. * Gets the class name
  1248. * @returns the string "Vector3"
  1249. */
  1250. getClassName(): string;
  1251. /**
  1252. * Creates the Vector3 hash code
  1253. * @returns a number which tends to be unique between Vector3 instances
  1254. */
  1255. getHashCode(): number;
  1256. /**
  1257. * Creates an array containing three elements : the coordinates of the Vector3
  1258. * @returns a new array of numbers
  1259. */
  1260. asArray(): number[];
  1261. /**
  1262. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  1263. * @param array defines the destination array
  1264. * @param index defines the offset in the destination array
  1265. * @returns the current Vector3
  1266. */
  1267. toArray(array: FloatArray, index?: number): Vector3;
  1268. /**
  1269. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  1270. * @returns a new Quaternion object, computed from the Vector3 coordinates
  1271. */
  1272. toQuaternion(): Quaternion;
  1273. /**
  1274. * Adds the given vector to the current Vector3
  1275. * @param otherVector defines the second operand
  1276. * @returns the current updated Vector3
  1277. */
  1278. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1279. /**
  1280. * Adds the given coordinates to the current Vector3
  1281. * @param x defines the x coordinate of the operand
  1282. * @param y defines the y coordinate of the operand
  1283. * @param z defines the z coordinate of the operand
  1284. * @returns the current updated Vector3
  1285. */
  1286. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1287. /**
  1288. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  1289. * @param otherVector defines the second operand
  1290. * @returns the resulting Vector3
  1291. */
  1292. add(otherVector: DeepImmutable<Vector3>): Vector3;
  1293. /**
  1294. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  1295. * @param otherVector defines the second operand
  1296. * @param result defines the Vector3 object where to store the result
  1297. * @returns the current Vector3
  1298. */
  1299. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1300. /**
  1301. * Subtract the given vector from the current Vector3
  1302. * @param otherVector defines the second operand
  1303. * @returns the current updated Vector3
  1304. */
  1305. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1306. /**
  1307. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  1308. * @param otherVector defines the second operand
  1309. * @returns the resulting Vector3
  1310. */
  1311. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  1312. /**
  1313. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  1314. * @param otherVector defines the second operand
  1315. * @param result defines the Vector3 object where to store the result
  1316. * @returns the current Vector3
  1317. */
  1318. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1319. /**
  1320. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  1321. * @param x defines the x coordinate of the operand
  1322. * @param y defines the y coordinate of the operand
  1323. * @param z defines the z coordinate of the operand
  1324. * @returns the resulting Vector3
  1325. */
  1326. subtractFromFloats(x: number, y: number, z: number): Vector3;
  1327. /**
  1328. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  1329. * @param x defines the x coordinate of the operand
  1330. * @param y defines the y coordinate of the operand
  1331. * @param z defines the z coordinate of the operand
  1332. * @param result defines the Vector3 object where to store the result
  1333. * @returns the current Vector3
  1334. */
  1335. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  1336. /**
  1337. * Gets a new Vector3 set with the current Vector3 negated coordinates
  1338. * @returns a new Vector3
  1339. */
  1340. negate(): Vector3;
  1341. /**
  1342. * Multiplies the Vector3 coordinates by the float "scale"
  1343. * @param scale defines the multiplier factor
  1344. * @returns the current updated Vector3
  1345. */
  1346. scaleInPlace(scale: number): Vector3;
  1347. /**
  1348. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  1349. * @param scale defines the multiplier factor
  1350. * @returns a new Vector3
  1351. */
  1352. scale(scale: number): Vector3;
  1353. /**
  1354. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  1355. * @param scale defines the multiplier factor
  1356. * @param result defines the Vector3 object where to store the result
  1357. * @returns the current Vector3
  1358. */
  1359. scaleToRef(scale: number, result: Vector3): Vector3;
  1360. /**
  1361. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  1362. * @param scale defines the scale factor
  1363. * @param result defines the Vector3 object where to store the result
  1364. * @returns the unmodified current Vector3
  1365. */
  1366. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  1367. /**
  1368. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  1369. * @param otherVector defines the second operand
  1370. * @returns true if both vectors are equals
  1371. */
  1372. equals(otherVector: DeepImmutable<Vector3>): boolean;
  1373. /**
  1374. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  1375. * @param otherVector defines the second operand
  1376. * @param epsilon defines the minimal distance to define values as equals
  1377. * @returns true if both vectors are distant less than epsilon
  1378. */
  1379. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  1380. /**
  1381. * Returns true if the current Vector3 coordinates equals the given floats
  1382. * @param x defines the x coordinate of the operand
  1383. * @param y defines the y coordinate of the operand
  1384. * @param z defines the z coordinate of the operand
  1385. * @returns true if both vectors are equals
  1386. */
  1387. equalsToFloats(x: number, y: number, z: number): boolean;
  1388. /**
  1389. * Multiplies the current Vector3 coordinates by the given ones
  1390. * @param otherVector defines the second operand
  1391. * @returns the current updated Vector3
  1392. */
  1393. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  1394. /**
  1395. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  1396. * @param otherVector defines the second operand
  1397. * @returns the new Vector3
  1398. */
  1399. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  1400. /**
  1401. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  1402. * @param otherVector defines the second operand
  1403. * @param result defines the Vector3 object where to store the result
  1404. * @returns the current Vector3
  1405. */
  1406. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1407. /**
  1408. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  1409. * @param x defines the x coordinate of the operand
  1410. * @param y defines the y coordinate of the operand
  1411. * @param z defines the z coordinate of the operand
  1412. * @returns the new Vector3
  1413. */
  1414. multiplyByFloats(x: number, y: number, z: number): Vector3;
  1415. /**
  1416. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  1417. * @param otherVector defines the second operand
  1418. * @returns the new Vector3
  1419. */
  1420. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  1421. /**
  1422. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  1423. * @param otherVector defines the second operand
  1424. * @param result defines the Vector3 object where to store the result
  1425. * @returns the current Vector3
  1426. */
  1427. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  1428. /**
  1429. * Divides the current Vector3 coordinates by the given ones.
  1430. * @param otherVector defines the second operand
  1431. * @returns the current updated Vector3
  1432. */
  1433. divideInPlace(otherVector: Vector3): Vector3;
  1434. /**
  1435. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  1436. * @param other defines the second operand
  1437. * @returns the current updated Vector3
  1438. */
  1439. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1440. /**
  1441. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  1442. * @param other defines the second operand
  1443. * @returns the current updated Vector3
  1444. */
  1445. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  1446. /**
  1447. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  1448. * @param x defines the x coordinate of the operand
  1449. * @param y defines the y coordinate of the operand
  1450. * @param z defines the z coordinate of the operand
  1451. * @returns the current updated Vector3
  1452. */
  1453. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1454. /**
  1455. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  1456. * @param x defines the x coordinate of the operand
  1457. * @param y defines the y coordinate of the operand
  1458. * @param z defines the z coordinate of the operand
  1459. * @returns the current updated Vector3
  1460. */
  1461. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  1462. /**
  1463. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  1464. * Check if is non uniform within a certain amount of decimal places to account for this
  1465. * @param epsilon the amount the values can differ
  1466. * @returns if the the vector is non uniform to a certain number of decimal places
  1467. */
  1468. isNonUniformWithinEpsilon(epsilon: number): boolean;
  1469. /**
  1470. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  1471. */
  1472. readonly isNonUniform: boolean;
  1473. /**
  1474. * Gets a new Vector3 from current Vector3 floored values
  1475. * @returns a new Vector3
  1476. */
  1477. floor(): Vector3;
  1478. /**
  1479. * Gets a new Vector3 from current Vector3 floored values
  1480. * @returns a new Vector3
  1481. */
  1482. fract(): Vector3;
  1483. /**
  1484. * Gets the length of the Vector3
  1485. * @returns the length of the Vecto3
  1486. */
  1487. length(): number;
  1488. /**
  1489. * Gets the squared length of the Vector3
  1490. * @returns squared length of the Vector3
  1491. */
  1492. lengthSquared(): number;
  1493. /**
  1494. * Normalize the current Vector3.
  1495. * Please note that this is an in place operation.
  1496. * @returns the current updated Vector3
  1497. */
  1498. normalize(): Vector3;
  1499. /**
  1500. * Reorders the x y z properties of the vector in place
  1501. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  1502. * @returns the current updated vector
  1503. */
  1504. reorderInPlace(order: string): this;
  1505. /**
  1506. * Rotates the vector around 0,0,0 by a quaternion
  1507. * @param quaternion the rotation quaternion
  1508. * @param result vector to store the result
  1509. * @returns the resulting vector
  1510. */
  1511. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  1512. /**
  1513. * Rotates a vector around a given point
  1514. * @param quaternion the rotation quaternion
  1515. * @param point the point to rotate around
  1516. * @param result vector to store the result
  1517. * @returns the resulting vector
  1518. */
  1519. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  1520. /**
  1521. * Normalize the current Vector3 with the given input length.
  1522. * Please note that this is an in place operation.
  1523. * @param len the length of the vector
  1524. * @returns the current updated Vector3
  1525. */
  1526. normalizeFromLength(len: number): Vector3;
  1527. /**
  1528. * Normalize the current Vector3 to a new vector
  1529. * @returns the new Vector3
  1530. */
  1531. normalizeToNew(): Vector3;
  1532. /**
  1533. * Normalize the current Vector3 to the reference
  1534. * @param reference define the Vector3 to update
  1535. * @returns the updated Vector3
  1536. */
  1537. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  1538. /**
  1539. * Creates a new Vector3 copied from the current Vector3
  1540. * @returns the new Vector3
  1541. */
  1542. clone(): Vector3;
  1543. /**
  1544. * Copies the given vector coordinates to the current Vector3 ones
  1545. * @param source defines the source Vector3
  1546. * @returns the current updated Vector3
  1547. */
  1548. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  1549. /**
  1550. * Copies the given floats to the current Vector3 coordinates
  1551. * @param x defines the x coordinate of the operand
  1552. * @param y defines the y coordinate of the operand
  1553. * @param z defines the z coordinate of the operand
  1554. * @returns the current updated Vector3
  1555. */
  1556. copyFromFloats(x: number, y: number, z: number): Vector3;
  1557. /**
  1558. * Copies the given floats to the current Vector3 coordinates
  1559. * @param x defines the x coordinate of the operand
  1560. * @param y defines the y coordinate of the operand
  1561. * @param z defines the z coordinate of the operand
  1562. * @returns the current updated Vector3
  1563. */
  1564. set(x: number, y: number, z: number): Vector3;
  1565. /**
  1566. * Copies the given float to the current Vector3 coordinates
  1567. * @param v defines the x, y and z coordinates of the operand
  1568. * @returns the current updated Vector3
  1569. */
  1570. setAll(v: number): Vector3;
  1571. /**
  1572. * Get the clip factor between two vectors
  1573. * @param vector0 defines the first operand
  1574. * @param vector1 defines the second operand
  1575. * @param axis defines the axis to use
  1576. * @param size defines the size along the axis
  1577. * @returns the clip factor
  1578. */
  1579. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  1580. /**
  1581. * Get angle between two vectors
  1582. * @param vector0 angle between vector0 and vector1
  1583. * @param vector1 angle between vector0 and vector1
  1584. * @param normal direction of the normal
  1585. * @return the angle between vector0 and vector1
  1586. */
  1587. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  1588. /**
  1589. * Returns a new Vector3 set from the index "offset" of the given array
  1590. * @param array defines the source array
  1591. * @param offset defines the offset in the source array
  1592. * @returns the new Vector3
  1593. */
  1594. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  1595. /**
  1596. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  1597. * This function is deprecated. Use FromArray instead
  1598. * @param array defines the source array
  1599. * @param offset defines the offset in the source array
  1600. * @returns the new Vector3
  1601. */
  1602. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  1603. /**
  1604. * Sets the given vector "result" with the element values from the index "offset" of the given array
  1605. * @param array defines the source array
  1606. * @param offset defines the offset in the source array
  1607. * @param result defines the Vector3 where to store the result
  1608. */
  1609. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  1610. /**
  1611. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  1612. * This function is deprecated. Use FromArrayToRef instead.
  1613. * @param array defines the source array
  1614. * @param offset defines the offset in the source array
  1615. * @param result defines the Vector3 where to store the result
  1616. */
  1617. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  1618. /**
  1619. * Sets the given vector "result" with the given floats.
  1620. * @param x defines the x coordinate of the source
  1621. * @param y defines the y coordinate of the source
  1622. * @param z defines the z coordinate of the source
  1623. * @param result defines the Vector3 where to store the result
  1624. */
  1625. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  1626. /**
  1627. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  1628. * @returns a new empty Vector3
  1629. */
  1630. static Zero(): Vector3;
  1631. /**
  1632. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  1633. * @returns a new unit Vector3
  1634. */
  1635. static One(): Vector3;
  1636. /**
  1637. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  1638. * @returns a new up Vector3
  1639. */
  1640. static Up(): Vector3;
  1641. /**
  1642. * Gets a up Vector3 that must not be updated
  1643. */
  1644. static readonly UpReadOnly: DeepImmutable<Vector3>;
  1645. /**
  1646. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  1647. * @returns a new down Vector3
  1648. */
  1649. static Down(): Vector3;
  1650. /**
  1651. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  1652. * @returns a new forward Vector3
  1653. */
  1654. static Forward(): Vector3;
  1655. /**
  1656. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  1657. * @returns a new forward Vector3
  1658. */
  1659. static Backward(): Vector3;
  1660. /**
  1661. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  1662. * @returns a new right Vector3
  1663. */
  1664. static Right(): Vector3;
  1665. /**
  1666. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  1667. * @returns a new left Vector3
  1668. */
  1669. static Left(): Vector3;
  1670. /**
  1671. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  1672. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1673. * @param vector defines the Vector3 to transform
  1674. * @param transformation defines the transformation matrix
  1675. * @returns the transformed Vector3
  1676. */
  1677. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1678. /**
  1679. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  1680. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  1681. * @param vector defines the Vector3 to transform
  1682. * @param transformation defines the transformation matrix
  1683. * @param result defines the Vector3 where to store the result
  1684. */
  1685. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1686. /**
  1687. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  1688. * This method computes tranformed coordinates only, not transformed direction vectors
  1689. * @param x define the x coordinate of the source vector
  1690. * @param y define the y coordinate of the source vector
  1691. * @param z define the z coordinate of the source vector
  1692. * @param transformation defines the transformation matrix
  1693. * @param result defines the Vector3 where to store the result
  1694. */
  1695. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1696. /**
  1697. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  1698. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1699. * @param vector defines the Vector3 to transform
  1700. * @param transformation defines the transformation matrix
  1701. * @returns the new Vector3
  1702. */
  1703. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  1704. /**
  1705. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  1706. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1707. * @param vector defines the Vector3 to transform
  1708. * @param transformation defines the transformation matrix
  1709. * @param result defines the Vector3 where to store the result
  1710. */
  1711. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1712. /**
  1713. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  1714. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  1715. * @param x define the x coordinate of the source vector
  1716. * @param y define the y coordinate of the source vector
  1717. * @param z define the z coordinate of the source vector
  1718. * @param transformation defines the transformation matrix
  1719. * @param result defines the Vector3 where to store the result
  1720. */
  1721. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  1722. /**
  1723. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  1724. * @param value1 defines the first control point
  1725. * @param value2 defines the second control point
  1726. * @param value3 defines the third control point
  1727. * @param value4 defines the fourth control point
  1728. * @param amount defines the amount on the spline to use
  1729. * @returns the new Vector3
  1730. */
  1731. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  1732. /**
  1733. * Returns a new Vector3 set with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1734. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1735. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1736. * @param value defines the current value
  1737. * @param min defines the lower range value
  1738. * @param max defines the upper range value
  1739. * @returns the new Vector3
  1740. */
  1741. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  1742. /**
  1743. * Sets the given vector "result" with the coordinates of "value", if the vector "value" is in the cube defined by the vectors "min" and "max"
  1744. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  1745. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  1746. * @param value defines the current value
  1747. * @param min defines the lower range value
  1748. * @param max defines the upper range value
  1749. * @param result defines the Vector3 where to store the result
  1750. */
  1751. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  1752. /**
  1753. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  1754. * @param value1 defines the first control point
  1755. * @param tangent1 defines the first tangent vector
  1756. * @param value2 defines the second control point
  1757. * @param tangent2 defines the second tangent vector
  1758. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  1759. * @returns the new Vector3
  1760. */
  1761. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  1762. /**
  1763. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  1764. * @param start defines the start value
  1765. * @param end defines the end value
  1766. * @param amount max defines amount between both (between 0 and 1)
  1767. * @returns the new Vector3
  1768. */
  1769. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  1770. /**
  1771. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  1772. * @param start defines the start value
  1773. * @param end defines the end value
  1774. * @param amount max defines amount between both (between 0 and 1)
  1775. * @param result defines the Vector3 where to store the result
  1776. */
  1777. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  1778. /**
  1779. * Returns the dot product (float) between the vectors "left" and "right"
  1780. * @param left defines the left operand
  1781. * @param right defines the right operand
  1782. * @returns the dot product
  1783. */
  1784. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  1785. /**
  1786. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  1787. * The cross product is then orthogonal to both "left" and "right"
  1788. * @param left defines the left operand
  1789. * @param right defines the right operand
  1790. * @returns the cross product
  1791. */
  1792. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1793. /**
  1794. * Sets the given vector "result" with the cross product of "left" and "right"
  1795. * The cross product is then orthogonal to both "left" and "right"
  1796. * @param left defines the left operand
  1797. * @param right defines the right operand
  1798. * @param result defines the Vector3 where to store the result
  1799. */
  1800. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  1801. /**
  1802. * Returns a new Vector3 as the normalization of the given vector
  1803. * @param vector defines the Vector3 to normalize
  1804. * @returns the new Vector3
  1805. */
  1806. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  1807. /**
  1808. * Sets the given vector "result" with the normalization of the given first vector
  1809. * @param vector defines the Vector3 to normalize
  1810. * @param result defines the Vector3 where to store the result
  1811. */
  1812. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  1813. /**
  1814. * Project a Vector3 onto screen space
  1815. * @param vector defines the Vector3 to project
  1816. * @param world defines the world matrix to use
  1817. * @param transform defines the transform (view x projection) matrix to use
  1818. * @param viewport defines the screen viewport to use
  1819. * @returns the new Vector3
  1820. */
  1821. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  1822. /** @hidden */
  1823. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  1824. /**
  1825. * Unproject from screen space to object space
  1826. * @param source defines the screen space Vector3 to use
  1827. * @param viewportWidth defines the current width of the viewport
  1828. * @param viewportHeight defines the current height of the viewport
  1829. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1830. * @param transform defines the transform (view x projection) matrix to use
  1831. * @returns the new Vector3
  1832. */
  1833. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  1834. /**
  1835. * Unproject from screen space to object space
  1836. * @param source defines the screen space Vector3 to use
  1837. * @param viewportWidth defines the current width of the viewport
  1838. * @param viewportHeight defines the current height of the viewport
  1839. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1840. * @param view defines the view matrix to use
  1841. * @param projection defines the projection matrix to use
  1842. * @returns the new Vector3
  1843. */
  1844. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  1845. /**
  1846. * Unproject from screen space to object space
  1847. * @param source defines the screen space Vector3 to use
  1848. * @param viewportWidth defines the current width of the viewport
  1849. * @param viewportHeight defines the current height of the viewport
  1850. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1851. * @param view defines the view matrix to use
  1852. * @param projection defines the projection matrix to use
  1853. * @param result defines the Vector3 where to store the result
  1854. */
  1855. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1856. /**
  1857. * Unproject from screen space to object space
  1858. * @param sourceX defines the screen space x coordinate to use
  1859. * @param sourceY defines the screen space y coordinate to use
  1860. * @param sourceZ defines the screen space z coordinate to use
  1861. * @param viewportWidth defines the current width of the viewport
  1862. * @param viewportHeight defines the current height of the viewport
  1863. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  1864. * @param view defines the view matrix to use
  1865. * @param projection defines the projection matrix to use
  1866. * @param result defines the Vector3 where to store the result
  1867. */
  1868. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  1869. /**
  1870. * Gets the minimal coordinate values between two Vector3
  1871. * @param left defines the first operand
  1872. * @param right defines the second operand
  1873. * @returns the new Vector3
  1874. */
  1875. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1876. /**
  1877. * Gets the maximal coordinate values between two Vector3
  1878. * @param left defines the first operand
  1879. * @param right defines the second operand
  1880. * @returns the new Vector3
  1881. */
  1882. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  1883. /**
  1884. * Returns the distance between the vectors "value1" and "value2"
  1885. * @param value1 defines the first operand
  1886. * @param value2 defines the second operand
  1887. * @returns the distance
  1888. */
  1889. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1890. /**
  1891. * Returns the squared distance between the vectors "value1" and "value2"
  1892. * @param value1 defines the first operand
  1893. * @param value2 defines the second operand
  1894. * @returns the squared distance
  1895. */
  1896. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  1897. /**
  1898. * Returns a new Vector3 located at the center between "value1" and "value2"
  1899. * @param value1 defines the first operand
  1900. * @param value2 defines the second operand
  1901. * @returns the new Vector3
  1902. */
  1903. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  1904. /**
  1905. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  1906. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  1907. * to something in order to rotate it from its local system to the given target system
  1908. * Note: axis1, axis2 and axis3 are normalized during this operation
  1909. * @param axis1 defines the first axis
  1910. * @param axis2 defines the second axis
  1911. * @param axis3 defines the third axis
  1912. * @returns a new Vector3
  1913. */
  1914. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  1915. /**
  1916. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  1917. * @param axis1 defines the first axis
  1918. * @param axis2 defines the second axis
  1919. * @param axis3 defines the third axis
  1920. * @param ref defines the Vector3 where to store the result
  1921. */
  1922. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  1923. }
  1924. /**
  1925. * Vector4 class created for EulerAngle class conversion to Quaternion
  1926. */
  1927. export class Vector4 {
  1928. /** x value of the vector */
  1929. x: number;
  1930. /** y value of the vector */
  1931. y: number;
  1932. /** z value of the vector */
  1933. z: number;
  1934. /** w value of the vector */
  1935. w: number;
  1936. /**
  1937. * Creates a Vector4 object from the given floats.
  1938. * @param x x value of the vector
  1939. * @param y y value of the vector
  1940. * @param z z value of the vector
  1941. * @param w w value of the vector
  1942. */
  1943. constructor(
  1944. /** x value of the vector */
  1945. x: number,
  1946. /** y value of the vector */
  1947. y: number,
  1948. /** z value of the vector */
  1949. z: number,
  1950. /** w value of the vector */
  1951. w: number);
  1952. /**
  1953. * Returns the string with the Vector4 coordinates.
  1954. * @returns a string containing all the vector values
  1955. */
  1956. toString(): string;
  1957. /**
  1958. * Returns the string "Vector4".
  1959. * @returns "Vector4"
  1960. */
  1961. getClassName(): string;
  1962. /**
  1963. * Returns the Vector4 hash code.
  1964. * @returns a unique hash code
  1965. */
  1966. getHashCode(): number;
  1967. /**
  1968. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  1969. * @returns the resulting array
  1970. */
  1971. asArray(): number[];
  1972. /**
  1973. * Populates the given array from the given index with the Vector4 coordinates.
  1974. * @param array array to populate
  1975. * @param index index of the array to start at (default: 0)
  1976. * @returns the Vector4.
  1977. */
  1978. toArray(array: FloatArray, index?: number): Vector4;
  1979. /**
  1980. * Adds the given vector to the current Vector4.
  1981. * @param otherVector the vector to add
  1982. * @returns the updated Vector4.
  1983. */
  1984. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  1985. /**
  1986. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  1987. * @param otherVector the vector to add
  1988. * @returns the resulting vector
  1989. */
  1990. add(otherVector: DeepImmutable<Vector4>): Vector4;
  1991. /**
  1992. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  1993. * @param otherVector the vector to add
  1994. * @param result the vector to store the result
  1995. * @returns the current Vector4.
  1996. */
  1997. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  1998. /**
  1999. * Subtract in place the given vector from the current Vector4.
  2000. * @param otherVector the vector to subtract
  2001. * @returns the updated Vector4.
  2002. */
  2003. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2004. /**
  2005. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  2006. * @param otherVector the vector to add
  2007. * @returns the new vector with the result
  2008. */
  2009. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  2010. /**
  2011. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  2012. * @param otherVector the vector to subtract
  2013. * @param result the vector to store the result
  2014. * @returns the current Vector4.
  2015. */
  2016. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2017. /**
  2018. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2019. */
  2020. /**
  2021. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2022. * @param x value to subtract
  2023. * @param y value to subtract
  2024. * @param z value to subtract
  2025. * @param w value to subtract
  2026. * @returns new vector containing the result
  2027. */
  2028. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2029. /**
  2030. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  2031. * @param x value to subtract
  2032. * @param y value to subtract
  2033. * @param z value to subtract
  2034. * @param w value to subtract
  2035. * @param result the vector to store the result in
  2036. * @returns the current Vector4.
  2037. */
  2038. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  2039. /**
  2040. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  2041. * @returns a new vector with the negated values
  2042. */
  2043. negate(): Vector4;
  2044. /**
  2045. * Multiplies the current Vector4 coordinates by scale (float).
  2046. * @param scale the number to scale with
  2047. * @returns the updated Vector4.
  2048. */
  2049. scaleInPlace(scale: number): Vector4;
  2050. /**
  2051. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  2052. * @param scale the number to scale with
  2053. * @returns a new vector with the result
  2054. */
  2055. scale(scale: number): Vector4;
  2056. /**
  2057. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  2058. * @param scale the number to scale with
  2059. * @param result a vector to store the result in
  2060. * @returns the current Vector4.
  2061. */
  2062. scaleToRef(scale: number, result: Vector4): Vector4;
  2063. /**
  2064. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  2065. * @param scale defines the scale factor
  2066. * @param result defines the Vector4 object where to store the result
  2067. * @returns the unmodified current Vector4
  2068. */
  2069. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  2070. /**
  2071. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  2072. * @param otherVector the vector to compare against
  2073. * @returns true if they are equal
  2074. */
  2075. equals(otherVector: DeepImmutable<Vector4>): boolean;
  2076. /**
  2077. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  2078. * @param otherVector vector to compare against
  2079. * @param epsilon (Default: very small number)
  2080. * @returns true if they are equal
  2081. */
  2082. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  2083. /**
  2084. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  2085. * @param x x value to compare against
  2086. * @param y y value to compare against
  2087. * @param z z value to compare against
  2088. * @param w w value to compare against
  2089. * @returns true if equal
  2090. */
  2091. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  2092. /**
  2093. * Multiplies in place the current Vector4 by the given one.
  2094. * @param otherVector vector to multiple with
  2095. * @returns the updated Vector4.
  2096. */
  2097. multiplyInPlace(otherVector: Vector4): Vector4;
  2098. /**
  2099. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  2100. * @param otherVector vector to multiple with
  2101. * @returns resulting new vector
  2102. */
  2103. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  2104. /**
  2105. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  2106. * @param otherVector vector to multiple with
  2107. * @param result vector to store the result
  2108. * @returns the current Vector4.
  2109. */
  2110. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2111. /**
  2112. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  2113. * @param x x value multiply with
  2114. * @param y y value multiply with
  2115. * @param z z value multiply with
  2116. * @param w w value multiply with
  2117. * @returns resulting new vector
  2118. */
  2119. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  2120. /**
  2121. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  2122. * @param otherVector vector to devide with
  2123. * @returns resulting new vector
  2124. */
  2125. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  2126. /**
  2127. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  2128. * @param otherVector vector to devide with
  2129. * @param result vector to store the result
  2130. * @returns the current Vector4.
  2131. */
  2132. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  2133. /**
  2134. * Divides the current Vector3 coordinates by the given ones.
  2135. * @param otherVector vector to devide with
  2136. * @returns the updated Vector3.
  2137. */
  2138. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  2139. /**
  2140. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  2141. * @param other defines the second operand
  2142. * @returns the current updated Vector4
  2143. */
  2144. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2145. /**
  2146. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  2147. * @param other defines the second operand
  2148. * @returns the current updated Vector4
  2149. */
  2150. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  2151. /**
  2152. * Gets a new Vector4 from current Vector4 floored values
  2153. * @returns a new Vector4
  2154. */
  2155. floor(): Vector4;
  2156. /**
  2157. * Gets a new Vector4 from current Vector3 floored values
  2158. * @returns a new Vector4
  2159. */
  2160. fract(): Vector4;
  2161. /**
  2162. * Returns the Vector4 length (float).
  2163. * @returns the length
  2164. */
  2165. length(): number;
  2166. /**
  2167. * Returns the Vector4 squared length (float).
  2168. * @returns the length squared
  2169. */
  2170. lengthSquared(): number;
  2171. /**
  2172. * Normalizes in place the Vector4.
  2173. * @returns the updated Vector4.
  2174. */
  2175. normalize(): Vector4;
  2176. /**
  2177. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  2178. * @returns this converted to a new vector3
  2179. */
  2180. toVector3(): Vector3;
  2181. /**
  2182. * Returns a new Vector4 copied from the current one.
  2183. * @returns the new cloned vector
  2184. */
  2185. clone(): Vector4;
  2186. /**
  2187. * Updates the current Vector4 with the given one coordinates.
  2188. * @param source the source vector to copy from
  2189. * @returns the updated Vector4.
  2190. */
  2191. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  2192. /**
  2193. * Updates the current Vector4 coordinates with the given floats.
  2194. * @param x float to copy from
  2195. * @param y float to copy from
  2196. * @param z float to copy from
  2197. * @param w float to copy from
  2198. * @returns the updated Vector4.
  2199. */
  2200. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  2201. /**
  2202. * Updates the current Vector4 coordinates with the given floats.
  2203. * @param x float to set from
  2204. * @param y float to set from
  2205. * @param z float to set from
  2206. * @param w float to set from
  2207. * @returns the updated Vector4.
  2208. */
  2209. set(x: number, y: number, z: number, w: number): Vector4;
  2210. /**
  2211. * Copies the given float to the current Vector3 coordinates
  2212. * @param v defines the x, y, z and w coordinates of the operand
  2213. * @returns the current updated Vector3
  2214. */
  2215. setAll(v: number): Vector4;
  2216. /**
  2217. * Returns a new Vector4 set from the starting index of the given array.
  2218. * @param array the array to pull values from
  2219. * @param offset the offset into the array to start at
  2220. * @returns the new vector
  2221. */
  2222. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  2223. /**
  2224. * Updates the given vector "result" from the starting index of the given array.
  2225. * @param array the array to pull values from
  2226. * @param offset the offset into the array to start at
  2227. * @param result the vector to store the result in
  2228. */
  2229. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  2230. /**
  2231. * Updates the given vector "result" from the starting index of the given Float32Array.
  2232. * @param array the array to pull values from
  2233. * @param offset the offset into the array to start at
  2234. * @param result the vector to store the result in
  2235. */
  2236. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  2237. /**
  2238. * Updates the given vector "result" coordinates from the given floats.
  2239. * @param x float to set from
  2240. * @param y float to set from
  2241. * @param z float to set from
  2242. * @param w float to set from
  2243. * @param result the vector to the floats in
  2244. */
  2245. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  2246. /**
  2247. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  2248. * @returns the new vector
  2249. */
  2250. static Zero(): Vector4;
  2251. /**
  2252. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  2253. * @returns the new vector
  2254. */
  2255. static One(): Vector4;
  2256. /**
  2257. * Returns a new normalized Vector4 from the given one.
  2258. * @param vector the vector to normalize
  2259. * @returns the vector
  2260. */
  2261. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  2262. /**
  2263. * Updates the given vector "result" from the normalization of the given one.
  2264. * @param vector the vector to normalize
  2265. * @param result the vector to store the result in
  2266. */
  2267. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  2268. /**
  2269. * Returns a vector with the minimum values from the left and right vectors
  2270. * @param left left vector to minimize
  2271. * @param right right vector to minimize
  2272. * @returns a new vector with the minimum of the left and right vector values
  2273. */
  2274. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2275. /**
  2276. * Returns a vector with the maximum values from the left and right vectors
  2277. * @param left left vector to maximize
  2278. * @param right right vector to maximize
  2279. * @returns a new vector with the maximum of the left and right vector values
  2280. */
  2281. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  2282. /**
  2283. * Returns the distance (float) between the vectors "value1" and "value2".
  2284. * @param value1 value to calulate the distance between
  2285. * @param value2 value to calulate the distance between
  2286. * @return the distance between the two vectors
  2287. */
  2288. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2289. /**
  2290. * Returns the squared distance (float) between the vectors "value1" and "value2".
  2291. * @param value1 value to calulate the distance between
  2292. * @param value2 value to calulate the distance between
  2293. * @return the distance between the two vectors squared
  2294. */
  2295. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  2296. /**
  2297. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  2298. * @param value1 value to calulate the center between
  2299. * @param value2 value to calulate the center between
  2300. * @return the center between the two vectors
  2301. */
  2302. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  2303. /**
  2304. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  2305. * This methods computes transformed normalized direction vectors only.
  2306. * @param vector the vector to transform
  2307. * @param transformation the transformation matrix to apply
  2308. * @returns the new vector
  2309. */
  2310. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  2311. /**
  2312. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  2313. * This methods computes transformed normalized direction vectors only.
  2314. * @param vector the vector to transform
  2315. * @param transformation the transformation matrix to apply
  2316. * @param result the vector to store the result in
  2317. */
  2318. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2319. /**
  2320. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  2321. * This methods computes transformed normalized direction vectors only.
  2322. * @param x value to transform
  2323. * @param y value to transform
  2324. * @param z value to transform
  2325. * @param w value to transform
  2326. * @param transformation the transformation matrix to apply
  2327. * @param result the vector to store the results in
  2328. */
  2329. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  2330. /**
  2331. * Creates a new Vector4 from a Vector3
  2332. * @param source defines the source data
  2333. * @param w defines the 4th component (default is 0)
  2334. * @returns a new Vector4
  2335. */
  2336. static FromVector3(source: Vector3, w?: number): Vector4;
  2337. }
  2338. /**
  2339. * Interface for the size containing width and height
  2340. */
  2341. export interface ISize {
  2342. /**
  2343. * Width
  2344. */
  2345. width: number;
  2346. /**
  2347. * Heighht
  2348. */
  2349. height: number;
  2350. }
  2351. /**
  2352. * Size containing widht and height
  2353. */
  2354. export class Size implements ISize {
  2355. /**
  2356. * Width
  2357. */
  2358. width: number;
  2359. /**
  2360. * Height
  2361. */
  2362. height: number;
  2363. /**
  2364. * Creates a Size object from the given width and height (floats).
  2365. * @param width width of the new size
  2366. * @param height height of the new size
  2367. */
  2368. constructor(width: number, height: number);
  2369. /**
  2370. * Returns a string with the Size width and height
  2371. * @returns a string with the Size width and height
  2372. */
  2373. toString(): string;
  2374. /**
  2375. * "Size"
  2376. * @returns the string "Size"
  2377. */
  2378. getClassName(): string;
  2379. /**
  2380. * Returns the Size hash code.
  2381. * @returns a hash code for a unique width and height
  2382. */
  2383. getHashCode(): number;
  2384. /**
  2385. * Updates the current size from the given one.
  2386. * @param src the given size
  2387. */
  2388. copyFrom(src: Size): void;
  2389. /**
  2390. * Updates in place the current Size from the given floats.
  2391. * @param width width of the new size
  2392. * @param height height of the new size
  2393. * @returns the updated Size.
  2394. */
  2395. copyFromFloats(width: number, height: number): Size;
  2396. /**
  2397. * Updates in place the current Size from the given floats.
  2398. * @param width width to set
  2399. * @param height height to set
  2400. * @returns the updated Size.
  2401. */
  2402. set(width: number, height: number): Size;
  2403. /**
  2404. * Multiplies the width and height by numbers
  2405. * @param w factor to multiple the width by
  2406. * @param h factor to multiple the height by
  2407. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  2408. */
  2409. multiplyByFloats(w: number, h: number): Size;
  2410. /**
  2411. * Clones the size
  2412. * @returns a new Size copied from the given one.
  2413. */
  2414. clone(): Size;
  2415. /**
  2416. * True if the current Size and the given one width and height are strictly equal.
  2417. * @param other the other size to compare against
  2418. * @returns True if the current Size and the given one width and height are strictly equal.
  2419. */
  2420. equals(other: Size): boolean;
  2421. /**
  2422. * The surface of the Size : width * height (float).
  2423. */
  2424. readonly surface: number;
  2425. /**
  2426. * Create a new size of zero
  2427. * @returns a new Size set to (0.0, 0.0)
  2428. */
  2429. static Zero(): Size;
  2430. /**
  2431. * Sums the width and height of two sizes
  2432. * @param otherSize size to add to this size
  2433. * @returns a new Size set as the addition result of the current Size and the given one.
  2434. */
  2435. add(otherSize: Size): Size;
  2436. /**
  2437. * Subtracts the width and height of two
  2438. * @param otherSize size to subtract to this size
  2439. * @returns a new Size set as the subtraction result of the given one from the current Size.
  2440. */
  2441. subtract(otherSize: Size): Size;
  2442. /**
  2443. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  2444. * @param start starting size to lerp between
  2445. * @param end end size to lerp between
  2446. * @param amount amount to lerp between the start and end values
  2447. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  2448. */
  2449. static Lerp(start: Size, end: Size, amount: number): Size;
  2450. }
  2451. /**
  2452. * Class used to store quaternion data
  2453. * @see https://en.wikipedia.org/wiki/Quaternion
  2454. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  2455. */
  2456. export class Quaternion {
  2457. /** defines the first component (0 by default) */
  2458. x: number;
  2459. /** defines the second component (0 by default) */
  2460. y: number;
  2461. /** defines the third component (0 by default) */
  2462. z: number;
  2463. /** defines the fourth component (1.0 by default) */
  2464. w: number;
  2465. /**
  2466. * Creates a new Quaternion from the given floats
  2467. * @param x defines the first component (0 by default)
  2468. * @param y defines the second component (0 by default)
  2469. * @param z defines the third component (0 by default)
  2470. * @param w defines the fourth component (1.0 by default)
  2471. */
  2472. constructor(
  2473. /** defines the first component (0 by default) */
  2474. x?: number,
  2475. /** defines the second component (0 by default) */
  2476. y?: number,
  2477. /** defines the third component (0 by default) */
  2478. z?: number,
  2479. /** defines the fourth component (1.0 by default) */
  2480. w?: number);
  2481. /**
  2482. * Gets a string representation for the current quaternion
  2483. * @returns a string with the Quaternion coordinates
  2484. */
  2485. toString(): string;
  2486. /**
  2487. * Gets the class name of the quaternion
  2488. * @returns the string "Quaternion"
  2489. */
  2490. getClassName(): string;
  2491. /**
  2492. * Gets a hash code for this quaternion
  2493. * @returns the quaternion hash code
  2494. */
  2495. getHashCode(): number;
  2496. /**
  2497. * Copy the quaternion to an array
  2498. * @returns a new array populated with 4 elements from the quaternion coordinates
  2499. */
  2500. asArray(): number[];
  2501. /**
  2502. * Check if two quaternions are equals
  2503. * @param otherQuaternion defines the second operand
  2504. * @return true if the current quaternion and the given one coordinates are strictly equals
  2505. */
  2506. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  2507. /**
  2508. * Clone the current quaternion
  2509. * @returns a new quaternion copied from the current one
  2510. */
  2511. clone(): Quaternion;
  2512. /**
  2513. * Copy a quaternion to the current one
  2514. * @param other defines the other quaternion
  2515. * @returns the updated current quaternion
  2516. */
  2517. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  2518. /**
  2519. * Updates the current quaternion with the given float coordinates
  2520. * @param x defines the x coordinate
  2521. * @param y defines the y coordinate
  2522. * @param z defines the z coordinate
  2523. * @param w defines the w coordinate
  2524. * @returns the updated current quaternion
  2525. */
  2526. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  2527. /**
  2528. * Updates the current quaternion from the given float coordinates
  2529. * @param x defines the x coordinate
  2530. * @param y defines the y coordinate
  2531. * @param z defines the z coordinate
  2532. * @param w defines the w coordinate
  2533. * @returns the updated current quaternion
  2534. */
  2535. set(x: number, y: number, z: number, w: number): Quaternion;
  2536. /**
  2537. * Adds two quaternions
  2538. * @param other defines the second operand
  2539. * @returns a new quaternion as the addition result of the given one and the current quaternion
  2540. */
  2541. add(other: DeepImmutable<Quaternion>): Quaternion;
  2542. /**
  2543. * Add a quaternion to the current one
  2544. * @param other defines the quaternion to add
  2545. * @returns the current quaternion
  2546. */
  2547. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  2548. /**
  2549. * Subtract two quaternions
  2550. * @param other defines the second operand
  2551. * @returns a new quaternion as the subtraction result of the given one from the current one
  2552. */
  2553. subtract(other: Quaternion): Quaternion;
  2554. /**
  2555. * Multiplies the current quaternion by a scale factor
  2556. * @param value defines the scale factor
  2557. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  2558. */
  2559. scale(value: number): Quaternion;
  2560. /**
  2561. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  2562. * @param scale defines the scale factor
  2563. * @param result defines the Quaternion object where to store the result
  2564. * @returns the unmodified current quaternion
  2565. */
  2566. scaleToRef(scale: number, result: Quaternion): Quaternion;
  2567. /**
  2568. * Multiplies in place the current quaternion by a scale factor
  2569. * @param value defines the scale factor
  2570. * @returns the current modified quaternion
  2571. */
  2572. scaleInPlace(value: number): Quaternion;
  2573. /**
  2574. * Scale the current quaternion values by a factor and add the result to a given quaternion
  2575. * @param scale defines the scale factor
  2576. * @param result defines the Quaternion object where to store the result
  2577. * @returns the unmodified current quaternion
  2578. */
  2579. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  2580. /**
  2581. * Multiplies two quaternions
  2582. * @param q1 defines the second operand
  2583. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  2584. */
  2585. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  2586. /**
  2587. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  2588. * @param q1 defines the second operand
  2589. * @param result defines the target quaternion
  2590. * @returns the current quaternion
  2591. */
  2592. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  2593. /**
  2594. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  2595. * @param q1 defines the second operand
  2596. * @returns the currentupdated quaternion
  2597. */
  2598. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  2599. /**
  2600. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  2601. * @param ref defines the target quaternion
  2602. * @returns the current quaternion
  2603. */
  2604. conjugateToRef(ref: Quaternion): Quaternion;
  2605. /**
  2606. * Conjugates in place (1-q) the current quaternion
  2607. * @returns the current updated quaternion
  2608. */
  2609. conjugateInPlace(): Quaternion;
  2610. /**
  2611. * Conjugates in place (1-q) the current quaternion
  2612. * @returns a new quaternion
  2613. */
  2614. conjugate(): Quaternion;
  2615. /**
  2616. * Gets length of current quaternion
  2617. * @returns the quaternion length (float)
  2618. */
  2619. length(): number;
  2620. /**
  2621. * Normalize in place the current quaternion
  2622. * @returns the current updated quaternion
  2623. */
  2624. normalize(): Quaternion;
  2625. /**
  2626. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  2627. * @param order is a reserved parameter and is ignore for now
  2628. * @returns a new Vector3 containing the Euler angles
  2629. */
  2630. toEulerAngles(order?: string): Vector3;
  2631. /**
  2632. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  2633. * @param result defines the vector which will be filled with the Euler angles
  2634. * @param order is a reserved parameter and is ignore for now
  2635. * @returns the current unchanged quaternion
  2636. */
  2637. toEulerAnglesToRef(result: Vector3): Quaternion;
  2638. /**
  2639. * Updates the given rotation matrix with the current quaternion values
  2640. * @param result defines the target matrix
  2641. * @returns the current unchanged quaternion
  2642. */
  2643. toRotationMatrix(result: Matrix): Quaternion;
  2644. /**
  2645. * Updates the current quaternion from the given rotation matrix values
  2646. * @param matrix defines the source matrix
  2647. * @returns the current updated quaternion
  2648. */
  2649. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2650. /**
  2651. * Creates a new quaternion from a rotation matrix
  2652. * @param matrix defines the source matrix
  2653. * @returns a new quaternion created from the given rotation matrix values
  2654. */
  2655. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  2656. /**
  2657. * Updates the given quaternion with the given rotation matrix values
  2658. * @param matrix defines the source matrix
  2659. * @param result defines the target quaternion
  2660. */
  2661. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  2662. /**
  2663. * Returns the dot product (float) between the quaternions "left" and "right"
  2664. * @param left defines the left operand
  2665. * @param right defines the right operand
  2666. * @returns the dot product
  2667. */
  2668. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  2669. /**
  2670. * Checks if the two quaternions are close to each other
  2671. * @param quat0 defines the first quaternion to check
  2672. * @param quat1 defines the second quaternion to check
  2673. * @returns true if the two quaternions are close to each other
  2674. */
  2675. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  2676. /**
  2677. * Creates an empty quaternion
  2678. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  2679. */
  2680. static Zero(): Quaternion;
  2681. /**
  2682. * Inverse a given quaternion
  2683. * @param q defines the source quaternion
  2684. * @returns a new quaternion as the inverted current quaternion
  2685. */
  2686. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  2687. /**
  2688. * Inverse a given quaternion
  2689. * @param q defines the source quaternion
  2690. * @param result the quaternion the result will be stored in
  2691. * @returns the result quaternion
  2692. */
  2693. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  2694. /**
  2695. * Creates an identity quaternion
  2696. * @returns the identity quaternion
  2697. */
  2698. static Identity(): Quaternion;
  2699. /**
  2700. * Gets a boolean indicating if the given quaternion is identity
  2701. * @param quaternion defines the quaternion to check
  2702. * @returns true if the quaternion is identity
  2703. */
  2704. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  2705. /**
  2706. * Creates a quaternion from a rotation around an axis
  2707. * @param axis defines the axis to use
  2708. * @param angle defines the angle to use
  2709. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  2710. */
  2711. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  2712. /**
  2713. * Creates a rotation around an axis and stores it into the given quaternion
  2714. * @param axis defines the axis to use
  2715. * @param angle defines the angle to use
  2716. * @param result defines the target quaternion
  2717. * @returns the target quaternion
  2718. */
  2719. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  2720. /**
  2721. * Creates a new quaternion from data stored into an array
  2722. * @param array defines the data source
  2723. * @param offset defines the offset in the source array where the data starts
  2724. * @returns a new quaternion
  2725. */
  2726. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  2727. /**
  2728. * Create a quaternion from Euler rotation angles
  2729. * @param x Pitch
  2730. * @param y Yaw
  2731. * @param z Roll
  2732. * @returns the new Quaternion
  2733. */
  2734. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  2735. /**
  2736. * Updates a quaternion from Euler rotation angles
  2737. * @param x Pitch
  2738. * @param y Yaw
  2739. * @param z Roll
  2740. * @param result the quaternion to store the result
  2741. * @returns the updated quaternion
  2742. */
  2743. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  2744. /**
  2745. * Create a quaternion from Euler rotation vector
  2746. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2747. * @returns the new Quaternion
  2748. */
  2749. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  2750. /**
  2751. * Updates a quaternion from Euler rotation vector
  2752. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  2753. * @param result the quaternion to store the result
  2754. * @returns the updated quaternion
  2755. */
  2756. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  2757. /**
  2758. * Creates a new quaternion from the given Euler float angles (y, x, z)
  2759. * @param yaw defines the rotation around Y axis
  2760. * @param pitch defines the rotation around X axis
  2761. * @param roll defines the rotation around Z axis
  2762. * @returns the new quaternion
  2763. */
  2764. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  2765. /**
  2766. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  2767. * @param yaw defines the rotation around Y axis
  2768. * @param pitch defines the rotation around X axis
  2769. * @param roll defines the rotation around Z axis
  2770. * @param result defines the target quaternion
  2771. */
  2772. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  2773. /**
  2774. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  2775. * @param alpha defines the rotation around first axis
  2776. * @param beta defines the rotation around second axis
  2777. * @param gamma defines the rotation around third axis
  2778. * @returns the new quaternion
  2779. */
  2780. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  2781. /**
  2782. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  2783. * @param alpha defines the rotation around first axis
  2784. * @param beta defines the rotation around second axis
  2785. * @param gamma defines the rotation around third axis
  2786. * @param result defines the target quaternion
  2787. */
  2788. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  2789. /**
  2790. * Creates a new quaternion containing the rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation)
  2791. * @param axis1 defines the first axis
  2792. * @param axis2 defines the second axis
  2793. * @param axis3 defines the third axis
  2794. * @returns the new quaternion
  2795. */
  2796. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  2797. /**
  2798. * Creates a rotation value to reach the target (axis1, axis2, axis3) orientation as a rotated XYZ system (axis1, axis2 and axis3 are normalized during this operation) and stores it in the target quaternion
  2799. * @param axis1 defines the first axis
  2800. * @param axis2 defines the second axis
  2801. * @param axis3 defines the third axis
  2802. * @param ref defines the target quaternion
  2803. */
  2804. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  2805. /**
  2806. * Interpolates between two quaternions
  2807. * @param left defines first quaternion
  2808. * @param right defines second quaternion
  2809. * @param amount defines the gradient to use
  2810. * @returns the new interpolated quaternion
  2811. */
  2812. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2813. /**
  2814. * Interpolates between two quaternions and stores it into a target quaternion
  2815. * @param left defines first quaternion
  2816. * @param right defines second quaternion
  2817. * @param amount defines the gradient to use
  2818. * @param result defines the target quaternion
  2819. */
  2820. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  2821. /**
  2822. * Interpolate between two quaternions using Hermite interpolation
  2823. * @param value1 defines first quaternion
  2824. * @param tangent1 defines the incoming tangent
  2825. * @param value2 defines second quaternion
  2826. * @param tangent2 defines the outgoing tangent
  2827. * @param amount defines the target quaternion
  2828. * @returns the new interpolated quaternion
  2829. */
  2830. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  2831. }
  2832. /**
  2833. * Class used to store matrix data (4x4)
  2834. */
  2835. export class Matrix {
  2836. private static _updateFlagSeed;
  2837. private static _identityReadOnly;
  2838. private _isIdentity;
  2839. private _isIdentityDirty;
  2840. private _isIdentity3x2;
  2841. private _isIdentity3x2Dirty;
  2842. /**
  2843. * Gets the update flag of the matrix which is an unique number for the matrix.
  2844. * It will be incremented every time the matrix data change.
  2845. * You can use it to speed the comparison between two versions of the same matrix.
  2846. */
  2847. updateFlag: number;
  2848. private readonly _m;
  2849. /**
  2850. * Gets the internal data of the matrix
  2851. */
  2852. readonly m: DeepImmutable<Float32Array>;
  2853. /** @hidden */
  2854. _markAsUpdated(): void;
  2855. /** @hidden */
  2856. private _updateIdentityStatus;
  2857. /**
  2858. * Creates an empty matrix (filled with zeros)
  2859. */
  2860. constructor();
  2861. /**
  2862. * Check if the current matrix is identity
  2863. * @returns true is the matrix is the identity matrix
  2864. */
  2865. isIdentity(): boolean;
  2866. /**
  2867. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  2868. * @returns true is the matrix is the identity matrix
  2869. */
  2870. isIdentityAs3x2(): boolean;
  2871. /**
  2872. * Gets the determinant of the matrix
  2873. * @returns the matrix determinant
  2874. */
  2875. determinant(): number;
  2876. /**
  2877. * Returns the matrix as a Float32Array
  2878. * @returns the matrix underlying array
  2879. */
  2880. toArray(): DeepImmutable<Float32Array>;
  2881. /**
  2882. * Returns the matrix as a Float32Array
  2883. * @returns the matrix underlying array.
  2884. */
  2885. asArray(): DeepImmutable<Float32Array>;
  2886. /**
  2887. * Inverts the current matrix in place
  2888. * @returns the current inverted matrix
  2889. */
  2890. invert(): Matrix;
  2891. /**
  2892. * Sets all the matrix elements to zero
  2893. * @returns the current matrix
  2894. */
  2895. reset(): Matrix;
  2896. /**
  2897. * Adds the current matrix with a second one
  2898. * @param other defines the matrix to add
  2899. * @returns a new matrix as the addition of the current matrix and the given one
  2900. */
  2901. add(other: DeepImmutable<Matrix>): Matrix;
  2902. /**
  2903. * Sets the given matrix "result" to the addition of the current matrix and the given one
  2904. * @param other defines the matrix to add
  2905. * @param result defines the target matrix
  2906. * @returns the current matrix
  2907. */
  2908. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2909. /**
  2910. * Adds in place the given matrix to the current matrix
  2911. * @param other defines the second operand
  2912. * @returns the current updated matrix
  2913. */
  2914. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  2915. /**
  2916. * Sets the given matrix to the current inverted Matrix
  2917. * @param other defines the target matrix
  2918. * @returns the unmodified current matrix
  2919. */
  2920. invertToRef(other: Matrix): Matrix;
  2921. /**
  2922. * add a value at the specified position in the current Matrix
  2923. * @param index the index of the value within the matrix. between 0 and 15.
  2924. * @param value the value to be added
  2925. * @returns the current updated matrix
  2926. */
  2927. addAtIndex(index: number, value: number): Matrix;
  2928. /**
  2929. * mutiply the specified position in the current Matrix by a value
  2930. * @param index the index of the value within the matrix. between 0 and 15.
  2931. * @param value the value to be added
  2932. * @returns the current updated matrix
  2933. */
  2934. multiplyAtIndex(index: number, value: number): Matrix;
  2935. /**
  2936. * Inserts the translation vector (using 3 floats) in the current matrix
  2937. * @param x defines the 1st component of the translation
  2938. * @param y defines the 2nd component of the translation
  2939. * @param z defines the 3rd component of the translation
  2940. * @returns the current updated matrix
  2941. */
  2942. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2943. /**
  2944. * Adds the translation vector (using 3 floats) in the current matrix
  2945. * @param x defines the 1st component of the translation
  2946. * @param y defines the 2nd component of the translation
  2947. * @param z defines the 3rd component of the translation
  2948. * @returns the current updated matrix
  2949. */
  2950. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  2951. /**
  2952. * Inserts the translation vector in the current matrix
  2953. * @param vector3 defines the translation to insert
  2954. * @returns the current updated matrix
  2955. */
  2956. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  2957. /**
  2958. * Gets the translation value of the current matrix
  2959. * @returns a new Vector3 as the extracted translation from the matrix
  2960. */
  2961. getTranslation(): Vector3;
  2962. /**
  2963. * Fill a Vector3 with the extracted translation from the matrix
  2964. * @param result defines the Vector3 where to store the translation
  2965. * @returns the current matrix
  2966. */
  2967. getTranslationToRef(result: Vector3): Matrix;
  2968. /**
  2969. * Remove rotation and scaling part from the matrix
  2970. * @returns the updated matrix
  2971. */
  2972. removeRotationAndScaling(): Matrix;
  2973. /**
  2974. * Multiply two matrices
  2975. * @param other defines the second operand
  2976. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  2977. */
  2978. multiply(other: DeepImmutable<Matrix>): Matrix;
  2979. /**
  2980. * Copy the current matrix from the given one
  2981. * @param other defines the source matrix
  2982. * @returns the current updated matrix
  2983. */
  2984. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  2985. /**
  2986. * Populates the given array from the starting index with the current matrix values
  2987. * @param array defines the target array
  2988. * @param offset defines the offset in the target array where to start storing values
  2989. * @returns the current matrix
  2990. */
  2991. copyToArray(array: Float32Array, offset?: number): Matrix;
  2992. /**
  2993. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  2994. * @param other defines the second operand
  2995. * @param result defines the matrix where to store the multiplication
  2996. * @returns the current matrix
  2997. */
  2998. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  2999. /**
  3000. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  3001. * @param other defines the second operand
  3002. * @param result defines the array where to store the multiplication
  3003. * @param offset defines the offset in the target array where to start storing values
  3004. * @returns the current matrix
  3005. */
  3006. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  3007. /**
  3008. * Check equality between this matrix and a second one
  3009. * @param value defines the second matrix to compare
  3010. * @returns true is the current matrix and the given one values are strictly equal
  3011. */
  3012. equals(value: DeepImmutable<Matrix>): boolean;
  3013. /**
  3014. * Clone the current matrix
  3015. * @returns a new matrix from the current matrix
  3016. */
  3017. clone(): Matrix;
  3018. /**
  3019. * Returns the name of the current matrix class
  3020. * @returns the string "Matrix"
  3021. */
  3022. getClassName(): string;
  3023. /**
  3024. * Gets the hash code of the current matrix
  3025. * @returns the hash code
  3026. */
  3027. getHashCode(): number;
  3028. /**
  3029. * Decomposes the current Matrix into a translation, rotation and scaling components
  3030. * @param scale defines the scale vector3 given as a reference to update
  3031. * @param rotation defines the rotation quaternion given as a reference to update
  3032. * @param translation defines the translation vector3 given as a reference to update
  3033. * @returns true if operation was successful
  3034. */
  3035. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  3036. /**
  3037. * Gets specific row of the matrix
  3038. * @param index defines the number of the row to get
  3039. * @returns the index-th row of the current matrix as a new Vector4
  3040. */
  3041. getRow(index: number): Nullable<Vector4>;
  3042. /**
  3043. * Sets the index-th row of the current matrix to the vector4 values
  3044. * @param index defines the number of the row to set
  3045. * @param row defines the target vector4
  3046. * @returns the updated current matrix
  3047. */
  3048. setRow(index: number, row: Vector4): Matrix;
  3049. /**
  3050. * Compute the transpose of the matrix
  3051. * @returns the new transposed matrix
  3052. */
  3053. transpose(): Matrix;
  3054. /**
  3055. * Compute the transpose of the matrix and store it in a given matrix
  3056. * @param result defines the target matrix
  3057. * @returns the current matrix
  3058. */
  3059. transposeToRef(result: Matrix): Matrix;
  3060. /**
  3061. * Sets the index-th row of the current matrix with the given 4 x float values
  3062. * @param index defines the row index
  3063. * @param x defines the x component to set
  3064. * @param y defines the y component to set
  3065. * @param z defines the z component to set
  3066. * @param w defines the w component to set
  3067. * @returns the updated current matrix
  3068. */
  3069. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  3070. /**
  3071. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  3072. * @param scale defines the scale factor
  3073. * @returns a new matrix
  3074. */
  3075. scale(scale: number): Matrix;
  3076. /**
  3077. * Scale the current matrix values by a factor to a given result matrix
  3078. * @param scale defines the scale factor
  3079. * @param result defines the matrix to store the result
  3080. * @returns the current matrix
  3081. */
  3082. scaleToRef(scale: number, result: Matrix): Matrix;
  3083. /**
  3084. * Scale the current matrix values by a factor and add the result to a given matrix
  3085. * @param scale defines the scale factor
  3086. * @param result defines the Matrix to store the result
  3087. * @returns the current matrix
  3088. */
  3089. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  3090. /**
  3091. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  3092. * @param ref matrix to store the result
  3093. */
  3094. toNormalMatrix(ref: Matrix): void;
  3095. /**
  3096. * Gets only rotation part of the current matrix
  3097. * @returns a new matrix sets to the extracted rotation matrix from the current one
  3098. */
  3099. getRotationMatrix(): Matrix;
  3100. /**
  3101. * Extracts the rotation matrix from the current one and sets it as the given "result"
  3102. * @param result defines the target matrix to store data to
  3103. * @returns the current matrix
  3104. */
  3105. getRotationMatrixToRef(result: Matrix): Matrix;
  3106. /**
  3107. * Toggles model matrix from being right handed to left handed in place and vice versa
  3108. */
  3109. toggleModelMatrixHandInPlace(): void;
  3110. /**
  3111. * Toggles projection matrix from being right handed to left handed in place and vice versa
  3112. */
  3113. toggleProjectionMatrixHandInPlace(): void;
  3114. /**
  3115. * Creates a matrix from an array
  3116. * @param array defines the source array
  3117. * @param offset defines an offset in the source array
  3118. * @returns a new Matrix set from the starting index of the given array
  3119. */
  3120. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  3121. /**
  3122. * Copy the content of an array into a given matrix
  3123. * @param array defines the source array
  3124. * @param offset defines an offset in the source array
  3125. * @param result defines the target matrix
  3126. */
  3127. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  3128. /**
  3129. * Stores an array into a matrix after having multiplied each component by a given factor
  3130. * @param array defines the source array
  3131. * @param offset defines the offset in the source array
  3132. * @param scale defines the scaling factor
  3133. * @param result defines the target matrix
  3134. */
  3135. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  3136. /**
  3137. * Gets an identity matrix that must not be updated
  3138. */
  3139. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  3140. /**
  3141. * Stores a list of values (16) inside a given matrix
  3142. * @param initialM11 defines 1st value of 1st row
  3143. * @param initialM12 defines 2nd value of 1st row
  3144. * @param initialM13 defines 3rd value of 1st row
  3145. * @param initialM14 defines 4th value of 1st row
  3146. * @param initialM21 defines 1st value of 2nd row
  3147. * @param initialM22 defines 2nd value of 2nd row
  3148. * @param initialM23 defines 3rd value of 2nd row
  3149. * @param initialM24 defines 4th value of 2nd row
  3150. * @param initialM31 defines 1st value of 3rd row
  3151. * @param initialM32 defines 2nd value of 3rd row
  3152. * @param initialM33 defines 3rd value of 3rd row
  3153. * @param initialM34 defines 4th value of 3rd row
  3154. * @param initialM41 defines 1st value of 4th row
  3155. * @param initialM42 defines 2nd value of 4th row
  3156. * @param initialM43 defines 3rd value of 4th row
  3157. * @param initialM44 defines 4th value of 4th row
  3158. * @param result defines the target matrix
  3159. */
  3160. static FromValuesToRef(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number, result: Matrix): void;
  3161. /**
  3162. * Creates new matrix from a list of values (16)
  3163. * @param initialM11 defines 1st value of 1st row
  3164. * @param initialM12 defines 2nd value of 1st row
  3165. * @param initialM13 defines 3rd value of 1st row
  3166. * @param initialM14 defines 4th value of 1st row
  3167. * @param initialM21 defines 1st value of 2nd row
  3168. * @param initialM22 defines 2nd value of 2nd row
  3169. * @param initialM23 defines 3rd value of 2nd row
  3170. * @param initialM24 defines 4th value of 2nd row
  3171. * @param initialM31 defines 1st value of 3rd row
  3172. * @param initialM32 defines 2nd value of 3rd row
  3173. * @param initialM33 defines 3rd value of 3rd row
  3174. * @param initialM34 defines 4th value of 3rd row
  3175. * @param initialM41 defines 1st value of 4th row
  3176. * @param initialM42 defines 2nd value of 4th row
  3177. * @param initialM43 defines 3rd value of 4th row
  3178. * @param initialM44 defines 4th value of 4th row
  3179. * @returns the new matrix
  3180. */
  3181. static FromValues(initialM11: number, initialM12: number, initialM13: number, initialM14: number, initialM21: number, initialM22: number, initialM23: number, initialM24: number, initialM31: number, initialM32: number, initialM33: number, initialM34: number, initialM41: number, initialM42: number, initialM43: number, initialM44: number): Matrix;
  3182. /**
  3183. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3184. * @param scale defines the scale vector3
  3185. * @param rotation defines the rotation quaternion
  3186. * @param translation defines the translation vector3
  3187. * @returns a new matrix
  3188. */
  3189. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  3190. /**
  3191. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  3192. * @param scale defines the scale vector3
  3193. * @param rotation defines the rotation quaternion
  3194. * @param translation defines the translation vector3
  3195. * @param result defines the target matrix
  3196. */
  3197. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  3198. /**
  3199. * Creates a new identity matrix
  3200. * @returns a new identity matrix
  3201. */
  3202. static Identity(): Matrix;
  3203. /**
  3204. * Creates a new identity matrix and stores the result in a given matrix
  3205. * @param result defines the target matrix
  3206. */
  3207. static IdentityToRef(result: Matrix): void;
  3208. /**
  3209. * Creates a new zero matrix
  3210. * @returns a new zero matrix
  3211. */
  3212. static Zero(): Matrix;
  3213. /**
  3214. * Creates a new rotation matrix for "angle" radians around the X axis
  3215. * @param angle defines the angle (in radians) to use
  3216. * @return the new matrix
  3217. */
  3218. static RotationX(angle: number): Matrix;
  3219. /**
  3220. * Creates a new matrix as the invert of a given matrix
  3221. * @param source defines the source matrix
  3222. * @returns the new matrix
  3223. */
  3224. static Invert(source: DeepImmutable<Matrix>): Matrix;
  3225. /**
  3226. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  3227. * @param angle defines the angle (in radians) to use
  3228. * @param result defines the target matrix
  3229. */
  3230. static RotationXToRef(angle: number, result: Matrix): void;
  3231. /**
  3232. * Creates a new rotation matrix for "angle" radians around the Y axis
  3233. * @param angle defines the angle (in radians) to use
  3234. * @return the new matrix
  3235. */
  3236. static RotationY(angle: number): Matrix;
  3237. /**
  3238. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  3239. * @param angle defines the angle (in radians) to use
  3240. * @param result defines the target matrix
  3241. */
  3242. static RotationYToRef(angle: number, result: Matrix): void;
  3243. /**
  3244. * Creates a new rotation matrix for "angle" radians around the Z axis
  3245. * @param angle defines the angle (in radians) to use
  3246. * @return the new matrix
  3247. */
  3248. static RotationZ(angle: number): Matrix;
  3249. /**
  3250. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  3251. * @param angle defines the angle (in radians) to use
  3252. * @param result defines the target matrix
  3253. */
  3254. static RotationZToRef(angle: number, result: Matrix): void;
  3255. /**
  3256. * Creates a new rotation matrix for "angle" radians around the given axis
  3257. * @param axis defines the axis to use
  3258. * @param angle defines the angle (in radians) to use
  3259. * @return the new matrix
  3260. */
  3261. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  3262. /**
  3263. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  3264. * @param axis defines the axis to use
  3265. * @param angle defines the angle (in radians) to use
  3266. * @param result defines the target matrix
  3267. */
  3268. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  3269. /**
  3270. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  3271. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  3272. * @param from defines the vector to align
  3273. * @param to defines the vector to align to
  3274. * @param result defines the target matrix
  3275. */
  3276. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  3277. /**
  3278. * Creates a rotation matrix
  3279. * @param yaw defines the yaw angle in radians (Y axis)
  3280. * @param pitch defines the pitch angle in radians (X axis)
  3281. * @param roll defines the roll angle in radians (X axis)
  3282. * @returns the new rotation matrix
  3283. */
  3284. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  3285. /**
  3286. * Creates a rotation matrix and stores it in a given matrix
  3287. * @param yaw defines the yaw angle in radians (Y axis)
  3288. * @param pitch defines the pitch angle in radians (X axis)
  3289. * @param roll defines the roll angle in radians (X axis)
  3290. * @param result defines the target matrix
  3291. */
  3292. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  3293. /**
  3294. * Creates a scaling matrix
  3295. * @param x defines the scale factor on X axis
  3296. * @param y defines the scale factor on Y axis
  3297. * @param z defines the scale factor on Z axis
  3298. * @returns the new matrix
  3299. */
  3300. static Scaling(x: number, y: number, z: number): Matrix;
  3301. /**
  3302. * Creates a scaling matrix and stores it in a given matrix
  3303. * @param x defines the scale factor on X axis
  3304. * @param y defines the scale factor on Y axis
  3305. * @param z defines the scale factor on Z axis
  3306. * @param result defines the target matrix
  3307. */
  3308. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  3309. /**
  3310. * Creates a translation matrix
  3311. * @param x defines the translation on X axis
  3312. * @param y defines the translation on Y axis
  3313. * @param z defines the translationon Z axis
  3314. * @returns the new matrix
  3315. */
  3316. static Translation(x: number, y: number, z: number): Matrix;
  3317. /**
  3318. * Creates a translation matrix and stores it in a given matrix
  3319. * @param x defines the translation on X axis
  3320. * @param y defines the translation on Y axis
  3321. * @param z defines the translationon Z axis
  3322. * @param result defines the target matrix
  3323. */
  3324. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  3325. /**
  3326. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3327. * @param startValue defines the start value
  3328. * @param endValue defines the end value
  3329. * @param gradient defines the gradient factor
  3330. * @returns the new matrix
  3331. */
  3332. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3333. /**
  3334. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  3335. * @param startValue defines the start value
  3336. * @param endValue defines the end value
  3337. * @param gradient defines the gradient factor
  3338. * @param result defines the Matrix object where to store data
  3339. */
  3340. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3341. /**
  3342. * Builds a new matrix whose values are computed by:
  3343. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3344. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3345. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3346. * @param startValue defines the first matrix
  3347. * @param endValue defines the second matrix
  3348. * @param gradient defines the gradient between the two matrices
  3349. * @returns the new matrix
  3350. */
  3351. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  3352. /**
  3353. * Update a matrix to values which are computed by:
  3354. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  3355. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  3356. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  3357. * @param startValue defines the first matrix
  3358. * @param endValue defines the second matrix
  3359. * @param gradient defines the gradient between the two matrices
  3360. * @param result defines the target matrix
  3361. */
  3362. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  3363. /**
  3364. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3365. * This function works in left handed mode
  3366. * @param eye defines the final position of the entity
  3367. * @param target defines where the entity should look at
  3368. * @param up defines the up vector for the entity
  3369. * @returns the new matrix
  3370. */
  3371. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3372. /**
  3373. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3374. * This function works in left handed mode
  3375. * @param eye defines the final position of the entity
  3376. * @param target defines where the entity should look at
  3377. * @param up defines the up vector for the entity
  3378. * @param result defines the target matrix
  3379. */
  3380. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3381. /**
  3382. * Gets a new rotation matrix used to rotate an entity so as it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up"
  3383. * This function works in right handed mode
  3384. * @param eye defines the final position of the entity
  3385. * @param target defines where the entity should look at
  3386. * @param up defines the up vector for the entity
  3387. * @returns the new matrix
  3388. */
  3389. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  3390. /**
  3391. * Sets the given "result" Matrix to a rotation matrix used to rotate an entity so that it looks at the target vector3, from the eye vector3 position, the up vector3 being oriented like "up".
  3392. * This function works in right handed mode
  3393. * @param eye defines the final position of the entity
  3394. * @param target defines where the entity should look at
  3395. * @param up defines the up vector for the entity
  3396. * @param result defines the target matrix
  3397. */
  3398. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  3399. /**
  3400. * Create a left-handed orthographic projection matrix
  3401. * @param width defines the viewport width
  3402. * @param height defines the viewport height
  3403. * @param znear defines the near clip plane
  3404. * @param zfar defines the far clip plane
  3405. * @returns a new matrix as a left-handed orthographic projection matrix
  3406. */
  3407. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3408. /**
  3409. * Store a left-handed orthographic projection to a given matrix
  3410. * @param width defines the viewport width
  3411. * @param height defines the viewport height
  3412. * @param znear defines the near clip plane
  3413. * @param zfar defines the far clip plane
  3414. * @param result defines the target matrix
  3415. */
  3416. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  3417. /**
  3418. * Create a left-handed orthographic projection matrix
  3419. * @param left defines the viewport left coordinate
  3420. * @param right defines the viewport right coordinate
  3421. * @param bottom defines the viewport bottom coordinate
  3422. * @param top defines the viewport top coordinate
  3423. * @param znear defines the near clip plane
  3424. * @param zfar defines the far clip plane
  3425. * @returns a new matrix as a left-handed orthographic projection matrix
  3426. */
  3427. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3428. /**
  3429. * Stores a left-handed orthographic projection into a given matrix
  3430. * @param left defines the viewport left coordinate
  3431. * @param right defines the viewport right coordinate
  3432. * @param bottom defines the viewport bottom coordinate
  3433. * @param top defines the viewport top coordinate
  3434. * @param znear defines the near clip plane
  3435. * @param zfar defines the far clip plane
  3436. * @param result defines the target matrix
  3437. */
  3438. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3439. /**
  3440. * Creates a right-handed orthographic projection matrix
  3441. * @param left defines the viewport left coordinate
  3442. * @param right defines the viewport right coordinate
  3443. * @param bottom defines the viewport bottom coordinate
  3444. * @param top defines the viewport top coordinate
  3445. * @param znear defines the near clip plane
  3446. * @param zfar defines the far clip plane
  3447. * @returns a new matrix as a right-handed orthographic projection matrix
  3448. */
  3449. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  3450. /**
  3451. * Stores a right-handed orthographic projection into a given matrix
  3452. * @param left defines the viewport left coordinate
  3453. * @param right defines the viewport right coordinate
  3454. * @param bottom defines the viewport bottom coordinate
  3455. * @param top defines the viewport top coordinate
  3456. * @param znear defines the near clip plane
  3457. * @param zfar defines the far clip plane
  3458. * @param result defines the target matrix
  3459. */
  3460. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  3461. /**
  3462. * Creates a left-handed perspective projection matrix
  3463. * @param width defines the viewport width
  3464. * @param height defines the viewport height
  3465. * @param znear defines the near clip plane
  3466. * @param zfar defines the far clip plane
  3467. * @returns a new matrix as a left-handed perspective projection matrix
  3468. */
  3469. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  3470. /**
  3471. * Creates a left-handed perspective projection matrix
  3472. * @param fov defines the horizontal field of view
  3473. * @param aspect defines the aspect ratio
  3474. * @param znear defines the near clip plane
  3475. * @param zfar defines the far clip plane
  3476. * @returns a new matrix as a left-handed perspective projection matrix
  3477. */
  3478. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3479. /**
  3480. * Stores a left-handed perspective projection into a given matrix
  3481. * @param fov defines the horizontal field of view
  3482. * @param aspect defines the aspect ratio
  3483. * @param znear defines the near clip plane
  3484. * @param zfar defines the far clip plane
  3485. * @param result defines the target matrix
  3486. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3487. */
  3488. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3489. /**
  3490. * Creates a right-handed perspective projection matrix
  3491. * @param fov defines the horizontal field of view
  3492. * @param aspect defines the aspect ratio
  3493. * @param znear defines the near clip plane
  3494. * @param zfar defines the far clip plane
  3495. * @returns a new matrix as a right-handed perspective projection matrix
  3496. */
  3497. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  3498. /**
  3499. * Stores a right-handed perspective projection into a given matrix
  3500. * @param fov defines the horizontal field of view
  3501. * @param aspect defines the aspect ratio
  3502. * @param znear defines the near clip plane
  3503. * @param zfar defines the far clip plane
  3504. * @param result defines the target matrix
  3505. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  3506. */
  3507. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  3508. /**
  3509. * Stores a perspective projection for WebVR info a given matrix
  3510. * @param fov defines the field of view
  3511. * @param znear defines the near clip plane
  3512. * @param zfar defines the far clip plane
  3513. * @param result defines the target matrix
  3514. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  3515. */
  3516. static PerspectiveFovWebVRToRef(fov: {
  3517. upDegrees: number;
  3518. downDegrees: number;
  3519. leftDegrees: number;
  3520. rightDegrees: number;
  3521. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  3522. /**
  3523. * Computes a complete transformation matrix
  3524. * @param viewport defines the viewport to use
  3525. * @param world defines the world matrix
  3526. * @param view defines the view matrix
  3527. * @param projection defines the projection matrix
  3528. * @param zmin defines the near clip plane
  3529. * @param zmax defines the far clip plane
  3530. * @returns the transformation matrix
  3531. */
  3532. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  3533. /**
  3534. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  3535. * @param matrix defines the matrix to use
  3536. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  3537. */
  3538. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  3539. /**
  3540. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  3541. * @param matrix defines the matrix to use
  3542. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  3543. */
  3544. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  3545. /**
  3546. * Compute the transpose of a given matrix
  3547. * @param matrix defines the matrix to transpose
  3548. * @returns the new matrix
  3549. */
  3550. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  3551. /**
  3552. * Compute the transpose of a matrix and store it in a target matrix
  3553. * @param matrix defines the matrix to transpose
  3554. * @param result defines the target matrix
  3555. */
  3556. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  3557. /**
  3558. * Computes a reflection matrix from a plane
  3559. * @param plane defines the reflection plane
  3560. * @returns a new matrix
  3561. */
  3562. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  3563. /**
  3564. * Computes a reflection matrix from a plane
  3565. * @param plane defines the reflection plane
  3566. * @param result defines the target matrix
  3567. */
  3568. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  3569. /**
  3570. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  3571. * @param xaxis defines the value of the 1st axis
  3572. * @param yaxis defines the value of the 2nd axis
  3573. * @param zaxis defines the value of the 3rd axis
  3574. * @param result defines the target matrix
  3575. */
  3576. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  3577. /**
  3578. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  3579. * @param quat defines the quaternion to use
  3580. * @param result defines the target matrix
  3581. */
  3582. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  3583. }
  3584. /**
  3585. * Represens a plane by the equation ax + by + cz + d = 0
  3586. */
  3587. export class Plane {
  3588. /**
  3589. * Normal of the plane (a,b,c)
  3590. */
  3591. normal: Vector3;
  3592. /**
  3593. * d component of the plane
  3594. */
  3595. d: number;
  3596. /**
  3597. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  3598. * @param a a component of the plane
  3599. * @param b b component of the plane
  3600. * @param c c component of the plane
  3601. * @param d d component of the plane
  3602. */
  3603. constructor(a: number, b: number, c: number, d: number);
  3604. /**
  3605. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  3606. */
  3607. asArray(): number[];
  3608. /**
  3609. * @returns a new plane copied from the current Plane.
  3610. */
  3611. clone(): Plane;
  3612. /**
  3613. * @returns the string "Plane".
  3614. */
  3615. getClassName(): string;
  3616. /**
  3617. * @returns the Plane hash code.
  3618. */
  3619. getHashCode(): number;
  3620. /**
  3621. * Normalize the current Plane in place.
  3622. * @returns the updated Plane.
  3623. */
  3624. normalize(): Plane;
  3625. /**
  3626. * Applies a transformation the plane and returns the result
  3627. * @param transformation the transformation matrix to be applied to the plane
  3628. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  3629. */
  3630. transform(transformation: DeepImmutable<Matrix>): Plane;
  3631. /**
  3632. * Calcualtte the dot product between the point and the plane normal
  3633. * @param point point to calculate the dot product with
  3634. * @returns the dot product (float) of the point coordinates and the plane normal.
  3635. */
  3636. dotCoordinate(point: DeepImmutable<Vector3>): number;
  3637. /**
  3638. * Updates the current Plane from the plane defined by the three given points.
  3639. * @param point1 one of the points used to contruct the plane
  3640. * @param point2 one of the points used to contruct the plane
  3641. * @param point3 one of the points used to contruct the plane
  3642. * @returns the updated Plane.
  3643. */
  3644. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3645. /**
  3646. * Checks if the plane is facing a given direction
  3647. * @param direction the direction to check if the plane is facing
  3648. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  3649. * @returns True is the vector "direction" is the same side than the plane normal.
  3650. */
  3651. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  3652. /**
  3653. * Calculates the distance to a point
  3654. * @param point point to calculate distance to
  3655. * @returns the signed distance (float) from the given point to the Plane.
  3656. */
  3657. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  3658. /**
  3659. * Creates a plane from an array
  3660. * @param array the array to create a plane from
  3661. * @returns a new Plane from the given array.
  3662. */
  3663. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  3664. /**
  3665. * Creates a plane from three points
  3666. * @param point1 point used to create the plane
  3667. * @param point2 point used to create the plane
  3668. * @param point3 point used to create the plane
  3669. * @returns a new Plane defined by the three given points.
  3670. */
  3671. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  3672. /**
  3673. * Creates a plane from an origin point and a normal
  3674. * @param origin origin of the plane to be constructed
  3675. * @param normal normal of the plane to be constructed
  3676. * @returns a new Plane the normal vector to this plane at the given origin point.
  3677. * Note : the vector "normal" is updated because normalized.
  3678. */
  3679. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  3680. /**
  3681. * Calculates the distance from a plane and a point
  3682. * @param origin origin of the plane to be constructed
  3683. * @param normal normal of the plane to be constructed
  3684. * @param point point to calculate distance to
  3685. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  3686. */
  3687. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  3688. }
  3689. /**
  3690. * Class used to represent a viewport on screen
  3691. */
  3692. export class Viewport {
  3693. /** viewport left coordinate */
  3694. x: number;
  3695. /** viewport top coordinate */
  3696. y: number;
  3697. /**viewport width */
  3698. width: number;
  3699. /** viewport height */
  3700. height: number;
  3701. /**
  3702. * Creates a Viewport object located at (x, y) and sized (width, height)
  3703. * @param x defines viewport left coordinate
  3704. * @param y defines viewport top coordinate
  3705. * @param width defines the viewport width
  3706. * @param height defines the viewport height
  3707. */
  3708. constructor(
  3709. /** viewport left coordinate */
  3710. x: number,
  3711. /** viewport top coordinate */
  3712. y: number,
  3713. /**viewport width */
  3714. width: number,
  3715. /** viewport height */
  3716. height: number);
  3717. /**
  3718. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  3719. * @param renderWidth defines the rendering width
  3720. * @param renderHeight defines the rendering height
  3721. * @returns a new Viewport
  3722. */
  3723. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  3724. /**
  3725. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  3726. * @param renderWidth defines the rendering width
  3727. * @param renderHeight defines the rendering height
  3728. * @param ref defines the target viewport
  3729. * @returns the current viewport
  3730. */
  3731. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  3732. /**
  3733. * Returns a new Viewport copied from the current one
  3734. * @returns a new Viewport
  3735. */
  3736. clone(): Viewport;
  3737. }
  3738. /**
  3739. * Reprasents a camera frustum
  3740. */
  3741. export class Frustum {
  3742. /**
  3743. * Gets the planes representing the frustum
  3744. * @param transform matrix to be applied to the returned planes
  3745. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  3746. */
  3747. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  3748. /**
  3749. * Gets the near frustum plane transformed by the transform matrix
  3750. * @param transform transformation matrix to be applied to the resulting frustum plane
  3751. * @param frustumPlane the resuling frustum plane
  3752. */
  3753. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3754. /**
  3755. * Gets the far frustum plane transformed by the transform matrix
  3756. * @param transform transformation matrix to be applied to the resulting frustum plane
  3757. * @param frustumPlane the resuling frustum plane
  3758. */
  3759. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3760. /**
  3761. * Gets the left frustum plane transformed by the transform matrix
  3762. * @param transform transformation matrix to be applied to the resulting frustum plane
  3763. * @param frustumPlane the resuling frustum plane
  3764. */
  3765. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3766. /**
  3767. * Gets the right frustum plane transformed by the transform matrix
  3768. * @param transform transformation matrix to be applied to the resulting frustum plane
  3769. * @param frustumPlane the resuling frustum plane
  3770. */
  3771. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3772. /**
  3773. * Gets the top frustum plane transformed by the transform matrix
  3774. * @param transform transformation matrix to be applied to the resulting frustum plane
  3775. * @param frustumPlane the resuling frustum plane
  3776. */
  3777. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3778. /**
  3779. * Gets the bottom frustum plane transformed by the transform matrix
  3780. * @param transform transformation matrix to be applied to the resulting frustum plane
  3781. * @param frustumPlane the resuling frustum plane
  3782. */
  3783. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  3784. /**
  3785. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  3786. * @param transform transformation matrix to be applied to the resulting frustum planes
  3787. * @param frustumPlanes the resuling frustum planes
  3788. */
  3789. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  3790. }
  3791. /** Defines supported spaces */
  3792. export enum Space {
  3793. /** Local (object) space */
  3794. LOCAL = 0,
  3795. /** World space */
  3796. WORLD = 1,
  3797. /** Bone space */
  3798. BONE = 2
  3799. }
  3800. /** Defines the 3 main axes */
  3801. export class Axis {
  3802. /** X axis */
  3803. static X: Vector3;
  3804. /** Y axis */
  3805. static Y: Vector3;
  3806. /** Z axis */
  3807. static Z: Vector3;
  3808. }
  3809. /** Class used to represent a Bezier curve */
  3810. export class BezierCurve {
  3811. /**
  3812. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  3813. * @param t defines the time
  3814. * @param x1 defines the left coordinate on X axis
  3815. * @param y1 defines the left coordinate on Y axis
  3816. * @param x2 defines the right coordinate on X axis
  3817. * @param y2 defines the right coordinate on Y axis
  3818. * @returns the interpolated value
  3819. */
  3820. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  3821. }
  3822. /**
  3823. * Defines potential orientation for back face culling
  3824. */
  3825. export enum Orientation {
  3826. /**
  3827. * Clockwise
  3828. */
  3829. CW = 0,
  3830. /** Counter clockwise */
  3831. CCW = 1
  3832. }
  3833. /**
  3834. * Defines angle representation
  3835. */
  3836. export class Angle {
  3837. private _radians;
  3838. /**
  3839. * Creates an Angle object of "radians" radians (float).
  3840. * @param radians the angle in radians
  3841. */
  3842. constructor(radians: number);
  3843. /**
  3844. * Get value in degrees
  3845. * @returns the Angle value in degrees (float)
  3846. */
  3847. degrees(): number;
  3848. /**
  3849. * Get value in radians
  3850. * @returns the Angle value in radians (float)
  3851. */
  3852. radians(): number;
  3853. /**
  3854. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  3855. * @param a defines first vector
  3856. * @param b defines second vector
  3857. * @returns a new Angle
  3858. */
  3859. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  3860. /**
  3861. * Gets a new Angle object from the given float in radians
  3862. * @param radians defines the angle value in radians
  3863. * @returns a new Angle
  3864. */
  3865. static FromRadians(radians: number): Angle;
  3866. /**
  3867. * Gets a new Angle object from the given float in degrees
  3868. * @param degrees defines the angle value in degrees
  3869. * @returns a new Angle
  3870. */
  3871. static FromDegrees(degrees: number): Angle;
  3872. }
  3873. /**
  3874. * This represents an arc in a 2d space.
  3875. */
  3876. export class Arc2 {
  3877. /** Defines the start point of the arc */
  3878. startPoint: Vector2;
  3879. /** Defines the mid point of the arc */
  3880. midPoint: Vector2;
  3881. /** Defines the end point of the arc */
  3882. endPoint: Vector2;
  3883. /**
  3884. * Defines the center point of the arc.
  3885. */
  3886. centerPoint: Vector2;
  3887. /**
  3888. * Defines the radius of the arc.
  3889. */
  3890. radius: number;
  3891. /**
  3892. * Defines the angle of the arc (from mid point to end point).
  3893. */
  3894. angle: Angle;
  3895. /**
  3896. * Defines the start angle of the arc (from start point to middle point).
  3897. */
  3898. startAngle: Angle;
  3899. /**
  3900. * Defines the orientation of the arc (clock wise/counter clock wise).
  3901. */
  3902. orientation: Orientation;
  3903. /**
  3904. * Creates an Arc object from the three given points : start, middle and end.
  3905. * @param startPoint Defines the start point of the arc
  3906. * @param midPoint Defines the midlle point of the arc
  3907. * @param endPoint Defines the end point of the arc
  3908. */
  3909. constructor(
  3910. /** Defines the start point of the arc */
  3911. startPoint: Vector2,
  3912. /** Defines the mid point of the arc */
  3913. midPoint: Vector2,
  3914. /** Defines the end point of the arc */
  3915. endPoint: Vector2);
  3916. }
  3917. /**
  3918. * Represents a 2D path made up of multiple 2D points
  3919. */
  3920. export class Path2 {
  3921. private _points;
  3922. private _length;
  3923. /**
  3924. * If the path start and end point are the same
  3925. */
  3926. closed: boolean;
  3927. /**
  3928. * Creates a Path2 object from the starting 2D coordinates x and y.
  3929. * @param x the starting points x value
  3930. * @param y the starting points y value
  3931. */
  3932. constructor(x: number, y: number);
  3933. /**
  3934. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  3935. * @param x the added points x value
  3936. * @param y the added points y value
  3937. * @returns the updated Path2.
  3938. */
  3939. addLineTo(x: number, y: number): Path2;
  3940. /**
  3941. * Adds _numberOfSegments_ segments according to the arc definition (middle point coordinates, end point coordinates, the arc start point being the current Path2 last point) to the current Path2.
  3942. * @param midX middle point x value
  3943. * @param midY middle point y value
  3944. * @param endX end point x value
  3945. * @param endY end point y value
  3946. * @param numberOfSegments (default: 36)
  3947. * @returns the updated Path2.
  3948. */
  3949. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  3950. /**
  3951. * Closes the Path2.
  3952. * @returns the Path2.
  3953. */
  3954. close(): Path2;
  3955. /**
  3956. * Gets the sum of the distance between each sequential point in the path
  3957. * @returns the Path2 total length (float).
  3958. */
  3959. length(): number;
  3960. /**
  3961. * Gets the points which construct the path
  3962. * @returns the Path2 internal array of points.
  3963. */
  3964. getPoints(): Vector2[];
  3965. /**
  3966. * Retreives the point at the distance aways from the starting point
  3967. * @param normalizedLengthPosition the length along the path to retreive the point from
  3968. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  3969. */
  3970. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  3971. /**
  3972. * Creates a new path starting from an x and y position
  3973. * @param x starting x value
  3974. * @param y starting y value
  3975. * @returns a new Path2 starting at the coordinates (x, y).
  3976. */
  3977. static StartingAt(x: number, y: number): Path2;
  3978. }
  3979. /**
  3980. * Represents a 3D path made up of multiple 3D points
  3981. */
  3982. export class Path3D {
  3983. /**
  3984. * an array of Vector3, the curve axis of the Path3D
  3985. */
  3986. path: Vector3[];
  3987. private _curve;
  3988. private _distances;
  3989. private _tangents;
  3990. private _normals;
  3991. private _binormals;
  3992. private _raw;
  3993. /**
  3994. * new Path3D(path, normal, raw)
  3995. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  3996. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  3997. * @param path an array of Vector3, the curve axis of the Path3D
  3998. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  3999. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  4000. */
  4001. constructor(
  4002. /**
  4003. * an array of Vector3, the curve axis of the Path3D
  4004. */
  4005. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  4006. /**
  4007. * Returns the Path3D array of successive Vector3 designing its curve.
  4008. * @returns the Path3D array of successive Vector3 designing its curve.
  4009. */
  4010. getCurve(): Vector3[];
  4011. /**
  4012. * Returns an array populated with tangent vectors on each Path3D curve point.
  4013. * @returns an array populated with tangent vectors on each Path3D curve point.
  4014. */
  4015. getTangents(): Vector3[];
  4016. /**
  4017. * Returns an array populated with normal vectors on each Path3D curve point.
  4018. * @returns an array populated with normal vectors on each Path3D curve point.
  4019. */
  4020. getNormals(): Vector3[];
  4021. /**
  4022. * Returns an array populated with binormal vectors on each Path3D curve point.
  4023. * @returns an array populated with binormal vectors on each Path3D curve point.
  4024. */
  4025. getBinormals(): Vector3[];
  4026. /**
  4027. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  4028. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  4029. */
  4030. getDistances(): number[];
  4031. /**
  4032. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  4033. * @param path path which all values are copied into the curves points
  4034. * @param firstNormal which should be projected onto the curve
  4035. * @returns the same object updated.
  4036. */
  4037. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  4038. private _compute;
  4039. private _getFirstNonNullVector;
  4040. private _getLastNonNullVector;
  4041. private _normalVector;
  4042. }
  4043. /**
  4044. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4045. * A Curve3 is designed from a series of successive Vector3.
  4046. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  4047. */
  4048. export class Curve3 {
  4049. private _points;
  4050. private _length;
  4051. /**
  4052. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  4053. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  4054. * @param v1 (Vector3) the control point
  4055. * @param v2 (Vector3) the end point of the Quadratic Bezier
  4056. * @param nbPoints (integer) the wanted number of points in the curve
  4057. * @returns the created Curve3
  4058. */
  4059. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4060. /**
  4061. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  4062. * @param v0 (Vector3) the origin point of the Cubic Bezier
  4063. * @param v1 (Vector3) the first control point
  4064. * @param v2 (Vector3) the second control point
  4065. * @param v3 (Vector3) the end point of the Cubic Bezier
  4066. * @param nbPoints (integer) the wanted number of points in the curve
  4067. * @returns the created Curve3
  4068. */
  4069. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4070. /**
  4071. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  4072. * @param p1 (Vector3) the origin point of the Hermite Spline
  4073. * @param t1 (Vector3) the tangent vector at the origin point
  4074. * @param p2 (Vector3) the end point of the Hermite Spline
  4075. * @param t2 (Vector3) the tangent vector at the end point
  4076. * @param nbPoints (integer) the wanted number of points in the curve
  4077. * @returns the created Curve3
  4078. */
  4079. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  4080. /**
  4081. * Returns a Curve3 object along a CatmullRom Spline curve :
  4082. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  4083. * @param nbPoints (integer) the wanted number of points between each curve control points
  4084. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  4085. * @returns the created Curve3
  4086. */
  4087. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  4088. /**
  4089. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  4090. * A Curve3 is designed from a series of successive Vector3.
  4091. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  4092. * @param points points which make up the curve
  4093. */
  4094. constructor(points: Vector3[]);
  4095. /**
  4096. * @returns the Curve3 stored array of successive Vector3
  4097. */
  4098. getPoints(): Vector3[];
  4099. /**
  4100. * @returns the computed length (float) of the curve.
  4101. */
  4102. length(): number;
  4103. /**
  4104. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  4105. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  4106. * curveA and curveB keep unchanged.
  4107. * @param curve the curve to continue from this curve
  4108. * @returns the newly constructed curve
  4109. */
  4110. continue(curve: DeepImmutable<Curve3>): Curve3;
  4111. private _computeLength;
  4112. }
  4113. /**
  4114. * Contains position and normal vectors for a vertex
  4115. */
  4116. export class PositionNormalVertex {
  4117. /** the position of the vertex (defaut: 0,0,0) */
  4118. position: Vector3;
  4119. /** the normal of the vertex (defaut: 0,1,0) */
  4120. normal: Vector3;
  4121. /**
  4122. * Creates a PositionNormalVertex
  4123. * @param position the position of the vertex (defaut: 0,0,0)
  4124. * @param normal the normal of the vertex (defaut: 0,1,0)
  4125. */
  4126. constructor(
  4127. /** the position of the vertex (defaut: 0,0,0) */
  4128. position?: Vector3,
  4129. /** the normal of the vertex (defaut: 0,1,0) */
  4130. normal?: Vector3);
  4131. /**
  4132. * Clones the PositionNormalVertex
  4133. * @returns the cloned PositionNormalVertex
  4134. */
  4135. clone(): PositionNormalVertex;
  4136. }
  4137. /**
  4138. * Contains position, normal and uv vectors for a vertex
  4139. */
  4140. export class PositionNormalTextureVertex {
  4141. /** the position of the vertex (defaut: 0,0,0) */
  4142. position: Vector3;
  4143. /** the normal of the vertex (defaut: 0,1,0) */
  4144. normal: Vector3;
  4145. /** the uv of the vertex (default: 0,0) */
  4146. uv: Vector2;
  4147. /**
  4148. * Creates a PositionNormalTextureVertex
  4149. * @param position the position of the vertex (defaut: 0,0,0)
  4150. * @param normal the normal of the vertex (defaut: 0,1,0)
  4151. * @param uv the uv of the vertex (default: 0,0)
  4152. */
  4153. constructor(
  4154. /** the position of the vertex (defaut: 0,0,0) */
  4155. position?: Vector3,
  4156. /** the normal of the vertex (defaut: 0,1,0) */
  4157. normal?: Vector3,
  4158. /** the uv of the vertex (default: 0,0) */
  4159. uv?: Vector2);
  4160. /**
  4161. * Clones the PositionNormalTextureVertex
  4162. * @returns the cloned PositionNormalTextureVertex
  4163. */
  4164. clone(): PositionNormalTextureVertex;
  4165. }
  4166. /**
  4167. * @hidden
  4168. */
  4169. export class Tmp {
  4170. static Color3: Color3[];
  4171. static Color4: Color4[];
  4172. static Vector2: Vector2[];
  4173. static Vector3: Vector3[];
  4174. static Vector4: Vector4[];
  4175. static Quaternion: Quaternion[];
  4176. static Matrix: Matrix[];
  4177. }
  4178. }
  4179. declare module "babylonjs/Offline/IOfflineProvider" {
  4180. /**
  4181. * Class used to enable access to offline support
  4182. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  4183. */
  4184. export interface IOfflineProvider {
  4185. /**
  4186. * Gets a boolean indicating if scene must be saved in the database
  4187. */
  4188. enableSceneOffline: boolean;
  4189. /**
  4190. * Gets a boolean indicating if textures must be saved in the database
  4191. */
  4192. enableTexturesOffline: boolean;
  4193. /**
  4194. * Open the offline support and make it available
  4195. * @param successCallback defines the callback to call on success
  4196. * @param errorCallback defines the callback to call on error
  4197. */
  4198. open(successCallback: () => void, errorCallback: () => void): void;
  4199. /**
  4200. * Loads an image from the offline support
  4201. * @param url defines the url to load from
  4202. * @param image defines the target DOM image
  4203. */
  4204. loadImage(url: string, image: HTMLImageElement): void;
  4205. /**
  4206. * Loads a file from offline support
  4207. * @param url defines the URL to load from
  4208. * @param sceneLoaded defines a callback to call on success
  4209. * @param progressCallBack defines a callback to call when progress changed
  4210. * @param errorCallback defines a callback to call on error
  4211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  4212. */
  4213. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  4214. }
  4215. }
  4216. declare module "babylonjs/Misc/observable" {
  4217. import { Nullable } from "babylonjs/types";
  4218. /**
  4219. * A class serves as a medium between the observable and its observers
  4220. */
  4221. export class EventState {
  4222. /**
  4223. * Create a new EventState
  4224. * @param mask defines the mask associated with this state
  4225. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4226. * @param target defines the original target of the state
  4227. * @param currentTarget defines the current target of the state
  4228. */
  4229. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  4230. /**
  4231. * Initialize the current event state
  4232. * @param mask defines the mask associated with this state
  4233. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  4234. * @param target defines the original target of the state
  4235. * @param currentTarget defines the current target of the state
  4236. * @returns the current event state
  4237. */
  4238. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  4239. /**
  4240. * An Observer can set this property to true to prevent subsequent observers of being notified
  4241. */
  4242. skipNextObservers: boolean;
  4243. /**
  4244. * Get the mask value that were used to trigger the event corresponding to this EventState object
  4245. */
  4246. mask: number;
  4247. /**
  4248. * The object that originally notified the event
  4249. */
  4250. target?: any;
  4251. /**
  4252. * The current object in the bubbling phase
  4253. */
  4254. currentTarget?: any;
  4255. /**
  4256. * This will be populated with the return value of the last function that was executed.
  4257. * If it is the first function in the callback chain it will be the event data.
  4258. */
  4259. lastReturnValue?: any;
  4260. }
  4261. /**
  4262. * Represent an Observer registered to a given Observable object.
  4263. */
  4264. export class Observer<T> {
  4265. /**
  4266. * Defines the callback to call when the observer is notified
  4267. */
  4268. callback: (eventData: T, eventState: EventState) => void;
  4269. /**
  4270. * Defines the mask of the observer (used to filter notifications)
  4271. */
  4272. mask: number;
  4273. /**
  4274. * Defines the current scope used to restore the JS context
  4275. */
  4276. scope: any;
  4277. /** @hidden */
  4278. _willBeUnregistered: boolean;
  4279. /**
  4280. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  4281. */
  4282. unregisterOnNextCall: boolean;
  4283. /**
  4284. * Creates a new observer
  4285. * @param callback defines the callback to call when the observer is notified
  4286. * @param mask defines the mask of the observer (used to filter notifications)
  4287. * @param scope defines the current scope used to restore the JS context
  4288. */
  4289. constructor(
  4290. /**
  4291. * Defines the callback to call when the observer is notified
  4292. */
  4293. callback: (eventData: T, eventState: EventState) => void,
  4294. /**
  4295. * Defines the mask of the observer (used to filter notifications)
  4296. */
  4297. mask: number,
  4298. /**
  4299. * Defines the current scope used to restore the JS context
  4300. */
  4301. scope?: any);
  4302. }
  4303. /**
  4304. * Represent a list of observers registered to multiple Observables object.
  4305. */
  4306. export class MultiObserver<T> {
  4307. private _observers;
  4308. private _observables;
  4309. /**
  4310. * Release associated resources
  4311. */
  4312. dispose(): void;
  4313. /**
  4314. * Raise a callback when one of the observable will notify
  4315. * @param observables defines a list of observables to watch
  4316. * @param callback defines the callback to call on notification
  4317. * @param mask defines the mask used to filter notifications
  4318. * @param scope defines the current scope used to restore the JS context
  4319. * @returns the new MultiObserver
  4320. */
  4321. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  4322. }
  4323. /**
  4324. * The Observable class is a simple implementation of the Observable pattern.
  4325. *
  4326. * There's one slight particularity though: a given Observable can notify its observer using a particular mask value, only the Observers registered with this mask value will be notified.
  4327. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  4328. * For instance you may have a given Observable that have four different types of notifications: Move (mask = 0x01), Stop (mask = 0x02), Turn Right (mask = 0X04), Turn Left (mask = 0X08).
  4329. * A given observer can register itself with only Move and Stop (mask = 0x03), then it will only be notified when one of these two occurs and will never be for Turn Left/Right.
  4330. */
  4331. export class Observable<T> {
  4332. private _observers;
  4333. private _eventState;
  4334. private _onObserverAdded;
  4335. /**
  4336. * Creates a new observable
  4337. * @param onObserverAdded defines a callback to call when a new observer is added
  4338. */
  4339. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  4340. /**
  4341. * Create a new Observer with the specified callback
  4342. * @param callback the callback that will be executed for that Observer
  4343. * @param mask the mask used to filter observers
  4344. * @param insertFirst if true the callback will be inserted at the first position, hence executed before the others ones. If false (default behavior) the callback will be inserted at the last position, executed after all the others already present.
  4345. * @param scope optional scope for the callback to be called from
  4346. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  4347. * @returns the new observer created for the callback
  4348. */
  4349. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  4350. /**
  4351. * Create a new Observer with the specified callback and unregisters after the next notification
  4352. * @param callback the callback that will be executed for that Observer
  4353. * @returns the new observer created for the callback
  4354. */
  4355. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  4356. /**
  4357. * Remove an Observer from the Observable object
  4358. * @param observer the instance of the Observer to remove
  4359. * @returns false if it doesn't belong to this Observable
  4360. */
  4361. remove(observer: Nullable<Observer<T>>): boolean;
  4362. /**
  4363. * Remove a callback from the Observable object
  4364. * @param callback the callback to remove
  4365. * @param scope optional scope. If used only the callbacks with this scope will be removed
  4366. * @returns false if it doesn't belong to this Observable
  4367. */
  4368. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  4369. private _deferUnregister;
  4370. private _remove;
  4371. /**
  4372. * Moves the observable to the top of the observer list making it get called first when notified
  4373. * @param observer the observer to move
  4374. */
  4375. makeObserverTopPriority(observer: Observer<T>): void;
  4376. /**
  4377. * Moves the observable to the bottom of the observer list making it get called last when notified
  4378. * @param observer the observer to move
  4379. */
  4380. makeObserverBottomPriority(observer: Observer<T>): void;
  4381. /**
  4382. * Notify all Observers by calling their respective callback with the given data
  4383. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  4384. * @param eventData defines the data to send to all observers
  4385. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  4386. * @param target defines the original target of the state
  4387. * @param currentTarget defines the current target of the state
  4388. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  4389. */
  4390. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  4391. /**
  4392. * Calling this will execute each callback, expecting it to be a promise or return a value.
  4393. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  4394. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  4395. * and it is crucial that all callbacks will be executed.
  4396. * The order of the callbacks is kept, callbacks are not executed parallel.
  4397. *
  4398. * @param eventData The data to be sent to each callback
  4399. * @param mask is used to filter observers defaults to -1
  4400. * @param target defines the callback target (see EventState)
  4401. * @param currentTarget defines he current object in the bubbling phase
  4402. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  4403. */
  4404. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  4405. /**
  4406. * Notify a specific observer
  4407. * @param observer defines the observer to notify
  4408. * @param eventData defines the data to be sent to each callback
  4409. * @param mask is used to filter observers defaults to -1
  4410. */
  4411. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  4412. /**
  4413. * Gets a boolean indicating if the observable has at least one observer
  4414. * @returns true is the Observable has at least one Observer registered
  4415. */
  4416. hasObservers(): boolean;
  4417. /**
  4418. * Clear the list of observers
  4419. */
  4420. clear(): void;
  4421. /**
  4422. * Clone the current observable
  4423. * @returns a new observable
  4424. */
  4425. clone(): Observable<T>;
  4426. /**
  4427. * Does this observable handles observer registered with a given mask
  4428. * @param mask defines the mask to be tested
  4429. * @return whether or not one observer registered with the given mask is handeled
  4430. **/
  4431. hasSpecificMask(mask?: number): boolean;
  4432. }
  4433. }
  4434. declare module "babylonjs/Misc/filesInputStore" {
  4435. /**
  4436. * Class used to help managing file picking and drag'n'drop
  4437. * File Storage
  4438. */
  4439. export class FilesInputStore {
  4440. /**
  4441. * List of files ready to be loaded
  4442. */
  4443. static FilesToLoad: {
  4444. [key: string]: File;
  4445. };
  4446. }
  4447. }
  4448. declare module "babylonjs/Engines/constants" {
  4449. /** Defines the cross module used constants to avoid circular dependncies */
  4450. export class Constants {
  4451. /** Defines that alpha blending is disabled */
  4452. static readonly ALPHA_DISABLE: number;
  4453. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  4454. static readonly ALPHA_ADD: number;
  4455. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  4456. static readonly ALPHA_COMBINE: number;
  4457. /** Defines that alpha blending to DEST - SRC * DEST */
  4458. static readonly ALPHA_SUBTRACT: number;
  4459. /** Defines that alpha blending to SRC * DEST */
  4460. static readonly ALPHA_MULTIPLY: number;
  4461. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  4462. static readonly ALPHA_MAXIMIZED: number;
  4463. /** Defines that alpha blending to SRC + DEST */
  4464. static readonly ALPHA_ONEONE: number;
  4465. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  4466. static readonly ALPHA_PREMULTIPLIED: number;
  4467. /**
  4468. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  4469. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  4470. */
  4471. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  4472. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  4473. static readonly ALPHA_INTERPOLATE: number;
  4474. /**
  4475. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  4476. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  4477. */
  4478. static readonly ALPHA_SCREENMODE: number;
  4479. /** Defines that the ressource is not delayed*/
  4480. static readonly DELAYLOADSTATE_NONE: number;
  4481. /** Defines that the ressource was successfully delay loaded */
  4482. static readonly DELAYLOADSTATE_LOADED: number;
  4483. /** Defines that the ressource is currently delay loading */
  4484. static readonly DELAYLOADSTATE_LOADING: number;
  4485. /** Defines that the ressource is delayed and has not started loading */
  4486. static readonly DELAYLOADSTATE_NOTLOADED: number;
  4487. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  4488. static readonly NEVER: number;
  4489. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will always pass. i.e. Pixels will be drawn in the order they are drawn */
  4490. static readonly ALWAYS: number;
  4491. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  4492. static readonly LESS: number;
  4493. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  4494. static readonly EQUAL: number;
  4495. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than or equal to the stored value */
  4496. static readonly LEQUAL: number;
  4497. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  4498. static readonly GREATER: number;
  4499. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than or equal to the stored value */
  4500. static readonly GEQUAL: number;
  4501. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is not equal to the stored value */
  4502. static readonly NOTEQUAL: number;
  4503. /** Passed to stencilOperation to specify that stencil value must be kept */
  4504. static readonly KEEP: number;
  4505. /** Passed to stencilOperation to specify that stencil value must be replaced */
  4506. static readonly REPLACE: number;
  4507. /** Passed to stencilOperation to specify that stencil value must be incremented */
  4508. static readonly INCR: number;
  4509. /** Passed to stencilOperation to specify that stencil value must be decremented */
  4510. static readonly DECR: number;
  4511. /** Passed to stencilOperation to specify that stencil value must be inverted */
  4512. static readonly INVERT: number;
  4513. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  4514. static readonly INCR_WRAP: number;
  4515. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  4516. static readonly DECR_WRAP: number;
  4517. /** Texture is not repeating outside of 0..1 UVs */
  4518. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  4519. /** Texture is repeating outside of 0..1 UVs */
  4520. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  4521. /** Texture is repeating and mirrored */
  4522. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  4523. /** ALPHA */
  4524. static readonly TEXTUREFORMAT_ALPHA: number;
  4525. /** LUMINANCE */
  4526. static readonly TEXTUREFORMAT_LUMINANCE: number;
  4527. /** LUMINANCE_ALPHA */
  4528. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  4529. /** RGB */
  4530. static readonly TEXTUREFORMAT_RGB: number;
  4531. /** RGBA */
  4532. static readonly TEXTUREFORMAT_RGBA: number;
  4533. /** RED */
  4534. static readonly TEXTUREFORMAT_RED: number;
  4535. /** RED (2nd reference) */
  4536. static readonly TEXTUREFORMAT_R: number;
  4537. /** RG */
  4538. static readonly TEXTUREFORMAT_RG: number;
  4539. /** RED_INTEGER */
  4540. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  4541. /** RED_INTEGER (2nd reference) */
  4542. static readonly TEXTUREFORMAT_R_INTEGER: number;
  4543. /** RG_INTEGER */
  4544. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  4545. /** RGB_INTEGER */
  4546. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  4547. /** RGBA_INTEGER */
  4548. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  4549. /** UNSIGNED_BYTE */
  4550. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  4551. /** UNSIGNED_BYTE (2nd reference) */
  4552. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  4553. /** FLOAT */
  4554. static readonly TEXTURETYPE_FLOAT: number;
  4555. /** HALF_FLOAT */
  4556. static readonly TEXTURETYPE_HALF_FLOAT: number;
  4557. /** BYTE */
  4558. static readonly TEXTURETYPE_BYTE: number;
  4559. /** SHORT */
  4560. static readonly TEXTURETYPE_SHORT: number;
  4561. /** UNSIGNED_SHORT */
  4562. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  4563. /** INT */
  4564. static readonly TEXTURETYPE_INT: number;
  4565. /** UNSIGNED_INT */
  4566. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  4567. /** UNSIGNED_SHORT_4_4_4_4 */
  4568. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  4569. /** UNSIGNED_SHORT_5_5_5_1 */
  4570. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  4571. /** UNSIGNED_SHORT_5_6_5 */
  4572. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  4573. /** UNSIGNED_INT_2_10_10_10_REV */
  4574. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  4575. /** UNSIGNED_INT_24_8 */
  4576. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  4577. /** UNSIGNED_INT_10F_11F_11F_REV */
  4578. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  4579. /** UNSIGNED_INT_5_9_9_9_REV */
  4580. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  4581. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  4582. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  4583. /** nearest is mag = nearest and min = nearest and mip = linear */
  4584. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  4585. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4586. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  4587. /** Trilinear is mag = linear and min = linear and mip = linear */
  4588. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  4589. /** nearest is mag = nearest and min = nearest and mip = linear */
  4590. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  4591. /** Bilinear is mag = linear and min = linear and mip = nearest */
  4592. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  4593. /** Trilinear is mag = linear and min = linear and mip = linear */
  4594. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  4595. /** mag = nearest and min = nearest and mip = nearest */
  4596. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  4597. /** mag = nearest and min = linear and mip = nearest */
  4598. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  4599. /** mag = nearest and min = linear and mip = linear */
  4600. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  4601. /** mag = nearest and min = linear and mip = none */
  4602. static readonly TEXTURE_NEAREST_LINEAR: number;
  4603. /** mag = nearest and min = nearest and mip = none */
  4604. static readonly TEXTURE_NEAREST_NEAREST: number;
  4605. /** mag = linear and min = nearest and mip = nearest */
  4606. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  4607. /** mag = linear and min = nearest and mip = linear */
  4608. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  4609. /** mag = linear and min = linear and mip = none */
  4610. static readonly TEXTURE_LINEAR_LINEAR: number;
  4611. /** mag = linear and min = nearest and mip = none */
  4612. static readonly TEXTURE_LINEAR_NEAREST: number;
  4613. /** Explicit coordinates mode */
  4614. static readonly TEXTURE_EXPLICIT_MODE: number;
  4615. /** Spherical coordinates mode */
  4616. static readonly TEXTURE_SPHERICAL_MODE: number;
  4617. /** Planar coordinates mode */
  4618. static readonly TEXTURE_PLANAR_MODE: number;
  4619. /** Cubic coordinates mode */
  4620. static readonly TEXTURE_CUBIC_MODE: number;
  4621. /** Projection coordinates mode */
  4622. static readonly TEXTURE_PROJECTION_MODE: number;
  4623. /** Skybox coordinates mode */
  4624. static readonly TEXTURE_SKYBOX_MODE: number;
  4625. /** Inverse Cubic coordinates mode */
  4626. static readonly TEXTURE_INVCUBIC_MODE: number;
  4627. /** Equirectangular coordinates mode */
  4628. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  4629. /** Equirectangular Fixed coordinates mode */
  4630. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  4631. /** Equirectangular Fixed Mirrored coordinates mode */
  4632. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  4633. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  4634. static readonly SCALEMODE_FLOOR: number;
  4635. /** Defines that texture rescaling will look for the nearest power of 2 size */
  4636. static readonly SCALEMODE_NEAREST: number;
  4637. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  4638. static readonly SCALEMODE_CEILING: number;
  4639. /**
  4640. * The dirty texture flag value
  4641. */
  4642. static readonly MATERIAL_TextureDirtyFlag: number;
  4643. /**
  4644. * The dirty light flag value
  4645. */
  4646. static readonly MATERIAL_LightDirtyFlag: number;
  4647. /**
  4648. * The dirty fresnel flag value
  4649. */
  4650. static readonly MATERIAL_FresnelDirtyFlag: number;
  4651. /**
  4652. * The dirty attribute flag value
  4653. */
  4654. static readonly MATERIAL_AttributesDirtyFlag: number;
  4655. /**
  4656. * The dirty misc flag value
  4657. */
  4658. static readonly MATERIAL_MiscDirtyFlag: number;
  4659. /**
  4660. * The all dirty flag value
  4661. */
  4662. static readonly MATERIAL_AllDirtyFlag: number;
  4663. /**
  4664. * Returns the triangle fill mode
  4665. */
  4666. static readonly MATERIAL_TriangleFillMode: number;
  4667. /**
  4668. * Returns the wireframe mode
  4669. */
  4670. static readonly MATERIAL_WireFrameFillMode: number;
  4671. /**
  4672. * Returns the point fill mode
  4673. */
  4674. static readonly MATERIAL_PointFillMode: number;
  4675. /**
  4676. * Returns the point list draw mode
  4677. */
  4678. static readonly MATERIAL_PointListDrawMode: number;
  4679. /**
  4680. * Returns the line list draw mode
  4681. */
  4682. static readonly MATERIAL_LineListDrawMode: number;
  4683. /**
  4684. * Returns the line loop draw mode
  4685. */
  4686. static readonly MATERIAL_LineLoopDrawMode: number;
  4687. /**
  4688. * Returns the line strip draw mode
  4689. */
  4690. static readonly MATERIAL_LineStripDrawMode: number;
  4691. /**
  4692. * Returns the triangle strip draw mode
  4693. */
  4694. static readonly MATERIAL_TriangleStripDrawMode: number;
  4695. /**
  4696. * Returns the triangle fan draw mode
  4697. */
  4698. static readonly MATERIAL_TriangleFanDrawMode: number;
  4699. /**
  4700. * Stores the clock-wise side orientation
  4701. */
  4702. static readonly MATERIAL_ClockWiseSideOrientation: number;
  4703. /**
  4704. * Stores the counter clock-wise side orientation
  4705. */
  4706. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  4707. /**
  4708. * Nothing
  4709. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4710. */
  4711. static readonly ACTION_NothingTrigger: number;
  4712. /**
  4713. * On pick
  4714. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4715. */
  4716. static readonly ACTION_OnPickTrigger: number;
  4717. /**
  4718. * On left pick
  4719. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4720. */
  4721. static readonly ACTION_OnLeftPickTrigger: number;
  4722. /**
  4723. * On right pick
  4724. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4725. */
  4726. static readonly ACTION_OnRightPickTrigger: number;
  4727. /**
  4728. * On center pick
  4729. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4730. */
  4731. static readonly ACTION_OnCenterPickTrigger: number;
  4732. /**
  4733. * On pick down
  4734. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4735. */
  4736. static readonly ACTION_OnPickDownTrigger: number;
  4737. /**
  4738. * On double pick
  4739. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4740. */
  4741. static readonly ACTION_OnDoublePickTrigger: number;
  4742. /**
  4743. * On pick up
  4744. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4745. */
  4746. static readonly ACTION_OnPickUpTrigger: number;
  4747. /**
  4748. * On pick out.
  4749. * This trigger will only be raised if you also declared a OnPickDown
  4750. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4751. */
  4752. static readonly ACTION_OnPickOutTrigger: number;
  4753. /**
  4754. * On long press
  4755. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4756. */
  4757. static readonly ACTION_OnLongPressTrigger: number;
  4758. /**
  4759. * On pointer over
  4760. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4761. */
  4762. static readonly ACTION_OnPointerOverTrigger: number;
  4763. /**
  4764. * On pointer out
  4765. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4766. */
  4767. static readonly ACTION_OnPointerOutTrigger: number;
  4768. /**
  4769. * On every frame
  4770. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4771. */
  4772. static readonly ACTION_OnEveryFrameTrigger: number;
  4773. /**
  4774. * On intersection enter
  4775. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4776. */
  4777. static readonly ACTION_OnIntersectionEnterTrigger: number;
  4778. /**
  4779. * On intersection exit
  4780. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4781. */
  4782. static readonly ACTION_OnIntersectionExitTrigger: number;
  4783. /**
  4784. * On key down
  4785. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4786. */
  4787. static readonly ACTION_OnKeyDownTrigger: number;
  4788. /**
  4789. * On key up
  4790. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  4791. */
  4792. static readonly ACTION_OnKeyUpTrigger: number;
  4793. /**
  4794. * Billboard mode will only apply to Y axis
  4795. */
  4796. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  4797. /**
  4798. * Billboard mode will apply to all axes
  4799. */
  4800. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  4801. /**
  4802. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  4803. */
  4804. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  4805. /**
  4806. * Gets or sets base Assets URL
  4807. */
  4808. static readonly PARTICLES_BaseAssetsUrl: string;
  4809. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  4810. * Test order :
  4811. * Is the bounding sphere outside the frustum ?
  4812. * If not, are the bounding box vertices outside the frustum ?
  4813. * It not, then the cullable object is in the frustum.
  4814. */
  4815. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  4816. /** Culling strategy : Bounding Sphere Only.
  4817. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  4818. * It's also less accurate than the standard because some not visible objects can still be selected.
  4819. * Test : is the bounding sphere outside the frustum ?
  4820. * If not, then the cullable object is in the frustum.
  4821. */
  4822. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  4823. /** Culling strategy : Optimistic Inclusion.
  4824. * This in an inclusion test first, then the standard exclusion test.
  4825. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  4826. * This could also be a little slower than the standard test when the tested object center is not the frustum but one of its bounding box vertex is still inside.
  4827. * Anyway, it's as accurate as the standard strategy.
  4828. * Test :
  4829. * Is the cullable object bounding sphere center in the frustum ?
  4830. * If not, apply the default culling strategy.
  4831. */
  4832. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  4833. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  4834. * This in an inclusion test first, then the bounding sphere only exclusion test.
  4835. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  4836. * This could also be a little slower than the BoundingSphereOnly strategy when the tested object center is not in the frustum but its bounding sphere still intersects it.
  4837. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  4838. * Test :
  4839. * Is the cullable object bounding sphere center in the frustum ?
  4840. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  4841. */
  4842. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  4843. /**
  4844. * No logging while loading
  4845. */
  4846. static readonly SCENELOADER_NO_LOGGING: number;
  4847. /**
  4848. * Minimal logging while loading
  4849. */
  4850. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  4851. /**
  4852. * Summary logging while loading
  4853. */
  4854. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  4855. /**
  4856. * Detailled logging while loading
  4857. */
  4858. static readonly SCENELOADER_DETAILED_LOGGING: number;
  4859. }
  4860. }
  4861. declare module "babylonjs/Misc/domManagement" {
  4862. /**
  4863. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  4864. * Babylon.js
  4865. */
  4866. export class DomManagement {
  4867. /**
  4868. * Checks if the window object exists
  4869. * @returns true if the window object exists
  4870. */
  4871. static IsWindowObjectExist(): boolean;
  4872. /**
  4873. * Extracts text content from a DOM element hierarchy
  4874. * @param element defines the root element
  4875. * @returns a string
  4876. */
  4877. static GetDOMTextContent(element: HTMLElement): string;
  4878. }
  4879. }
  4880. declare module "babylonjs/Misc/logger" {
  4881. /**
  4882. * Logger used througouht the application to allow configuration of
  4883. * the log level required for the messages.
  4884. */
  4885. export class Logger {
  4886. /**
  4887. * No log
  4888. */
  4889. static readonly NoneLogLevel: number;
  4890. /**
  4891. * Only message logs
  4892. */
  4893. static readonly MessageLogLevel: number;
  4894. /**
  4895. * Only warning logs
  4896. */
  4897. static readonly WarningLogLevel: number;
  4898. /**
  4899. * Only error logs
  4900. */
  4901. static readonly ErrorLogLevel: number;
  4902. /**
  4903. * All logs
  4904. */
  4905. static readonly AllLogLevel: number;
  4906. private static _LogCache;
  4907. /**
  4908. * Gets a value indicating the number of loading errors
  4909. * @ignorenaming
  4910. */
  4911. static errorsCount: number;
  4912. /**
  4913. * Callback called when a new log is added
  4914. */
  4915. static OnNewCacheEntry: (entry: string) => void;
  4916. private static _AddLogEntry;
  4917. private static _FormatMessage;
  4918. private static _LogDisabled;
  4919. private static _LogEnabled;
  4920. private static _WarnDisabled;
  4921. private static _WarnEnabled;
  4922. private static _ErrorDisabled;
  4923. private static _ErrorEnabled;
  4924. /**
  4925. * Log a message to the console
  4926. */
  4927. static Log: (message: string) => void;
  4928. /**
  4929. * Write a warning message to the console
  4930. */
  4931. static Warn: (message: string) => void;
  4932. /**
  4933. * Write an error message to the console
  4934. */
  4935. static Error: (message: string) => void;
  4936. /**
  4937. * Gets current log cache (list of logs)
  4938. */
  4939. static readonly LogCache: string;
  4940. /**
  4941. * Clears the log cache
  4942. */
  4943. static ClearLogCache(): void;
  4944. /**
  4945. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  4946. */
  4947. static LogLevels: number;
  4948. }
  4949. }
  4950. declare module "babylonjs/Misc/typeStore" {
  4951. /** @hidden */
  4952. export class _TypeStore {
  4953. /** @hidden */
  4954. static RegisteredTypes: {
  4955. [key: string]: Object;
  4956. };
  4957. /** @hidden */
  4958. static GetClass(fqdn: string): any;
  4959. }
  4960. }
  4961. declare module "babylonjs/Misc/deepCopier" {
  4962. /**
  4963. * Class containing a set of static utilities functions for deep copy.
  4964. */
  4965. export class DeepCopier {
  4966. /**
  4967. * Tries to copy an object by duplicating every property
  4968. * @param source defines the source object
  4969. * @param destination defines the target object
  4970. * @param doNotCopyList defines a list of properties to avoid
  4971. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  4972. */
  4973. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  4974. }
  4975. }
  4976. declare module "babylonjs/Misc/precisionDate" {
  4977. /**
  4978. * Class containing a set of static utilities functions for precision date
  4979. */
  4980. export class PrecisionDate {
  4981. /**
  4982. * Gets either window.performance.now() if supported or Date.now() else
  4983. */
  4984. static readonly Now: number;
  4985. }
  4986. }
  4987. declare module "babylonjs/Misc/devTools" {
  4988. /** @hidden */
  4989. export class _DevTools {
  4990. static WarnImport(name: string): string;
  4991. }
  4992. }
  4993. declare module "babylonjs/Misc/webRequest" {
  4994. /**
  4995. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  4996. */
  4997. export class WebRequest {
  4998. private _xhr;
  4999. /**
  5000. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  5001. * i.e. when loading files, where the server/service expects an Authorization header
  5002. */
  5003. static CustomRequestHeaders: {
  5004. [key: string]: string;
  5005. };
  5006. /**
  5007. * Add callback functions in this array to update all the requests before they get sent to the network
  5008. */
  5009. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  5010. private _injectCustomRequestHeaders;
  5011. /**
  5012. * Gets or sets a function to be called when loading progress changes
  5013. */
  5014. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  5015. /**
  5016. * Returns client's state
  5017. */
  5018. readonly readyState: number;
  5019. /**
  5020. * Returns client's status
  5021. */
  5022. readonly status: number;
  5023. /**
  5024. * Returns client's status as a text
  5025. */
  5026. readonly statusText: string;
  5027. /**
  5028. * Returns client's response
  5029. */
  5030. readonly response: any;
  5031. /**
  5032. * Returns client's response url
  5033. */
  5034. readonly responseURL: string;
  5035. /**
  5036. * Returns client's response as text
  5037. */
  5038. readonly responseText: string;
  5039. /**
  5040. * Gets or sets the expected response type
  5041. */
  5042. responseType: XMLHttpRequestResponseType;
  5043. /** @hidden */
  5044. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  5045. /** @hidden */
  5046. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  5047. /**
  5048. * Cancels any network activity
  5049. */
  5050. abort(): void;
  5051. /**
  5052. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  5053. * @param body defines an optional request body
  5054. */
  5055. send(body?: Document | BodyInit | null): void;
  5056. /**
  5057. * Sets the request method, request URL
  5058. * @param method defines the method to use (GET, POST, etc..)
  5059. * @param url defines the url to connect with
  5060. */
  5061. open(method: string, url: string): void;
  5062. }
  5063. }
  5064. declare module "babylonjs/Misc/andOrNotEvaluator" {
  5065. /**
  5066. * Class used to evalaute queries containing `and` and `or` operators
  5067. */
  5068. export class AndOrNotEvaluator {
  5069. /**
  5070. * Evaluate a query
  5071. * @param query defines the query to evaluate
  5072. * @param evaluateCallback defines the callback used to filter result
  5073. * @returns true if the query matches
  5074. */
  5075. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  5076. private static _HandleParenthesisContent;
  5077. private static _SimplifyNegation;
  5078. }
  5079. }
  5080. declare module "babylonjs/Misc/tags" {
  5081. /**
  5082. * Class used to store custom tags
  5083. */
  5084. export class Tags {
  5085. /**
  5086. * Adds support for tags on the given object
  5087. * @param obj defines the object to use
  5088. */
  5089. static EnableFor(obj: any): void;
  5090. /**
  5091. * Removes tags support
  5092. * @param obj defines the object to use
  5093. */
  5094. static DisableFor(obj: any): void;
  5095. /**
  5096. * Gets a boolean indicating if the given object has tags
  5097. * @param obj defines the object to use
  5098. * @returns a boolean
  5099. */
  5100. static HasTags(obj: any): boolean;
  5101. /**
  5102. * Gets the tags available on a given object
  5103. * @param obj defines the object to use
  5104. * @param asString defines if the tags must be returned as a string instead of an array of strings
  5105. * @returns the tags
  5106. */
  5107. static GetTags(obj: any, asString?: boolean): any;
  5108. /**
  5109. * Adds tags to an object
  5110. * @param obj defines the object to use
  5111. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  5112. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  5113. */
  5114. static AddTagsTo(obj: any, tagsString: string): void;
  5115. /**
  5116. * @hidden
  5117. */
  5118. static _AddTagTo(obj: any, tag: string): void;
  5119. /**
  5120. * Removes specific tags from a specific object
  5121. * @param obj defines the object to use
  5122. * @param tagsString defines the tags to remove
  5123. */
  5124. static RemoveTagsFrom(obj: any, tagsString: string): void;
  5125. /**
  5126. * @hidden
  5127. */
  5128. static _RemoveTagFrom(obj: any, tag: string): void;
  5129. /**
  5130. * Defines if tags hosted on an object match a given query
  5131. * @param obj defines the object to use
  5132. * @param tagsQuery defines the tag query
  5133. * @returns a boolean
  5134. */
  5135. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  5136. }
  5137. }
  5138. declare module "babylonjs/Materials/materialDefines" {
  5139. /**
  5140. * Manages the defines for the Material
  5141. */
  5142. export class MaterialDefines {
  5143. private _keys;
  5144. private _isDirty;
  5145. /** @hidden */
  5146. _renderId: number;
  5147. /** @hidden */
  5148. _areLightsDirty: boolean;
  5149. /** @hidden */
  5150. _areAttributesDirty: boolean;
  5151. /** @hidden */
  5152. _areTexturesDirty: boolean;
  5153. /** @hidden */
  5154. _areFresnelDirty: boolean;
  5155. /** @hidden */
  5156. _areMiscDirty: boolean;
  5157. /** @hidden */
  5158. _areImageProcessingDirty: boolean;
  5159. /** @hidden */
  5160. _normals: boolean;
  5161. /** @hidden */
  5162. _uvs: boolean;
  5163. /** @hidden */
  5164. _needNormals: boolean;
  5165. /** @hidden */
  5166. _needUVs: boolean;
  5167. /**
  5168. * Specifies if the material needs to be re-calculated
  5169. */
  5170. readonly isDirty: boolean;
  5171. /**
  5172. * Marks the material to indicate that it has been re-calculated
  5173. */
  5174. markAsProcessed(): void;
  5175. /**
  5176. * Marks the material to indicate that it needs to be re-calculated
  5177. */
  5178. markAsUnprocessed(): void;
  5179. /**
  5180. * Marks the material to indicate all of its defines need to be re-calculated
  5181. */
  5182. markAllAsDirty(): void;
  5183. /**
  5184. * Marks the material to indicate that image processing needs to be re-calculated
  5185. */
  5186. markAsImageProcessingDirty(): void;
  5187. /**
  5188. * Marks the material to indicate the lights need to be re-calculated
  5189. */
  5190. markAsLightDirty(): void;
  5191. /**
  5192. * Marks the attribute state as changed
  5193. */
  5194. markAsAttributesDirty(): void;
  5195. /**
  5196. * Marks the texture state as changed
  5197. */
  5198. markAsTexturesDirty(): void;
  5199. /**
  5200. * Marks the fresnel state as changed
  5201. */
  5202. markAsFresnelDirty(): void;
  5203. /**
  5204. * Marks the misc state as changed
  5205. */
  5206. markAsMiscDirty(): void;
  5207. /**
  5208. * Rebuilds the material defines
  5209. */
  5210. rebuild(): void;
  5211. /**
  5212. * Specifies if two material defines are equal
  5213. * @param other - A material define instance to compare to
  5214. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  5215. */
  5216. isEqual(other: MaterialDefines): boolean;
  5217. /**
  5218. * Clones this instance's defines to another instance
  5219. * @param other - material defines to clone values to
  5220. */
  5221. cloneTo(other: MaterialDefines): void;
  5222. /**
  5223. * Resets the material define values
  5224. */
  5225. reset(): void;
  5226. /**
  5227. * Converts the material define values to a string
  5228. * @returns - String of material define information
  5229. */
  5230. toString(): string;
  5231. }
  5232. }
  5233. declare module "babylonjs/Misc/performanceMonitor" {
  5234. /**
  5235. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  5236. */
  5237. export class PerformanceMonitor {
  5238. private _enabled;
  5239. private _rollingFrameTime;
  5240. private _lastFrameTimeMs;
  5241. /**
  5242. * constructor
  5243. * @param frameSampleSize The number of samples required to saturate the sliding window
  5244. */
  5245. constructor(frameSampleSize?: number);
  5246. /**
  5247. * Samples current frame
  5248. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  5249. */
  5250. sampleFrame(timeMs?: number): void;
  5251. /**
  5252. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5253. */
  5254. readonly averageFrameTime: number;
  5255. /**
  5256. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  5257. */
  5258. readonly averageFrameTimeVariance: number;
  5259. /**
  5260. * Returns the frame time of the most recent frame
  5261. */
  5262. readonly instantaneousFrameTime: number;
  5263. /**
  5264. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  5265. */
  5266. readonly averageFPS: number;
  5267. /**
  5268. * Returns the average framerate in frames per second using the most recent frame time
  5269. */
  5270. readonly instantaneousFPS: number;
  5271. /**
  5272. * Returns true if enough samples have been taken to completely fill the sliding window
  5273. */
  5274. readonly isSaturated: boolean;
  5275. /**
  5276. * Enables contributions to the sliding window sample set
  5277. */
  5278. enable(): void;
  5279. /**
  5280. * Disables contributions to the sliding window sample set
  5281. * Samples will not be interpolated over the disabled period
  5282. */
  5283. disable(): void;
  5284. /**
  5285. * Returns true if sampling is enabled
  5286. */
  5287. readonly isEnabled: boolean;
  5288. /**
  5289. * Resets performance monitor
  5290. */
  5291. reset(): void;
  5292. }
  5293. /**
  5294. * RollingAverage
  5295. *
  5296. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  5297. */
  5298. export class RollingAverage {
  5299. /**
  5300. * Current average
  5301. */
  5302. average: number;
  5303. /**
  5304. * Current variance
  5305. */
  5306. variance: number;
  5307. protected _samples: Array<number>;
  5308. protected _sampleCount: number;
  5309. protected _pos: number;
  5310. protected _m2: number;
  5311. /**
  5312. * constructor
  5313. * @param length The number of samples required to saturate the sliding window
  5314. */
  5315. constructor(length: number);
  5316. /**
  5317. * Adds a sample to the sample set
  5318. * @param v The sample value
  5319. */
  5320. add(v: number): void;
  5321. /**
  5322. * Returns previously added values or null if outside of history or outside the sliding window domain
  5323. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  5324. * @return Value previously recorded with add() or null if outside of range
  5325. */
  5326. history(i: number): number;
  5327. /**
  5328. * Returns true if enough samples have been taken to completely fill the sliding window
  5329. * @return true if sample-set saturated
  5330. */
  5331. isSaturated(): boolean;
  5332. /**
  5333. * Resets the rolling average (equivalent to 0 samples taken so far)
  5334. */
  5335. reset(): void;
  5336. /**
  5337. * Wraps a value around the sample range boundaries
  5338. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  5339. * @return Wrapped position in sample range
  5340. */
  5341. protected _wrapPosition(i: number): number;
  5342. }
  5343. }
  5344. declare module "babylonjs/Misc/stringDictionary" {
  5345. import { Nullable } from "babylonjs/types";
  5346. /**
  5347. * This class implement a typical dictionary using a string as key and the generic type T as value.
  5348. * The underlying implementation relies on an associative array to ensure the best performances.
  5349. * The value can be anything including 'null' but except 'undefined'
  5350. */
  5351. export class StringDictionary<T> {
  5352. /**
  5353. * This will clear this dictionary and copy the content from the 'source' one.
  5354. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  5355. * @param source the dictionary to take the content from and copy to this dictionary
  5356. */
  5357. copyFrom(source: StringDictionary<T>): void;
  5358. /**
  5359. * Get a value based from its key
  5360. * @param key the given key to get the matching value from
  5361. * @return the value if found, otherwise undefined is returned
  5362. */
  5363. get(key: string): T | undefined;
  5364. /**
  5365. * Get a value from its key or add it if it doesn't exist.
  5366. * This method will ensure you that a given key/data will be present in the dictionary.
  5367. * @param key the given key to get the matching value from
  5368. * @param factory the factory that will create the value if the key is not present in the dictionary.
  5369. * The factory will only be invoked if there's no data for the given key.
  5370. * @return the value corresponding to the key.
  5371. */
  5372. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  5373. /**
  5374. * Get a value from its key if present in the dictionary otherwise add it
  5375. * @param key the key to get the value from
  5376. * @param val if there's no such key/value pair in the dictionary add it with this value
  5377. * @return the value corresponding to the key
  5378. */
  5379. getOrAdd(key: string, val: T): T;
  5380. /**
  5381. * Check if there's a given key in the dictionary
  5382. * @param key the key to check for
  5383. * @return true if the key is present, false otherwise
  5384. */
  5385. contains(key: string): boolean;
  5386. /**
  5387. * Add a new key and its corresponding value
  5388. * @param key the key to add
  5389. * @param value the value corresponding to the key
  5390. * @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
  5391. */
  5392. add(key: string, value: T): boolean;
  5393. /**
  5394. * Update a specific value associated to a key
  5395. * @param key defines the key to use
  5396. * @param value defines the value to store
  5397. * @returns true if the value was updated (or false if the key was not found)
  5398. */
  5399. set(key: string, value: T): boolean;
  5400. /**
  5401. * Get the element of the given key and remove it from the dictionary
  5402. * @param key defines the key to search
  5403. * @returns the value associated with the key or null if not found
  5404. */
  5405. getAndRemove(key: string): Nullable<T>;
  5406. /**
  5407. * Remove a key/value from the dictionary.
  5408. * @param key the key to remove
  5409. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  5410. */
  5411. remove(key: string): boolean;
  5412. /**
  5413. * Clear the whole content of the dictionary
  5414. */
  5415. clear(): void;
  5416. /**
  5417. * Gets the current count
  5418. */
  5419. readonly count: number;
  5420. /**
  5421. * Execute a callback on each key/val of the dictionary.
  5422. * Note that you can remove any element in this dictionary in the callback implementation
  5423. * @param callback the callback to execute on a given key/value pair
  5424. */
  5425. forEach(callback: (key: string, val: T) => void): void;
  5426. /**
  5427. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  5428. * If the callback returns null or undefined the method will iterate to the next key/value pair
  5429. * Note that you can remove any element in this dictionary in the callback implementation
  5430. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  5431. * @returns the first item
  5432. */
  5433. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  5434. private _count;
  5435. private _data;
  5436. }
  5437. }
  5438. declare module "babylonjs/Misc/promise" {
  5439. /**
  5440. * Helper class that provides a small promise polyfill
  5441. */
  5442. export class PromisePolyfill {
  5443. /**
  5444. * Static function used to check if the polyfill is required
  5445. * If this is the case then the function will inject the polyfill to window.Promise
  5446. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  5447. */
  5448. static Apply(force?: boolean): void;
  5449. }
  5450. }
  5451. declare module "babylonjs/Meshes/buffer" {
  5452. import { Nullable, DataArray } from "babylonjs/types";
  5453. /**
  5454. * Class used to store data that will be store in GPU memory
  5455. */
  5456. export class Buffer {
  5457. private _engine;
  5458. private _buffer;
  5459. /** @hidden */
  5460. _data: Nullable<DataArray>;
  5461. private _updatable;
  5462. private _instanced;
  5463. /**
  5464. * Gets the byte stride.
  5465. */
  5466. readonly byteStride: number;
  5467. /**
  5468. * Constructor
  5469. * @param engine the engine
  5470. * @param data the data to use for this buffer
  5471. * @param updatable whether the data is updatable
  5472. * @param stride the stride (optional)
  5473. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5474. * @param instanced whether the buffer is instanced (optional)
  5475. * @param useBytes set to true if the stride in in bytes (optional)
  5476. */
  5477. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  5478. /**
  5479. * Create a new VertexBuffer based on the current buffer
  5480. * @param kind defines the vertex buffer kind (position, normal, etc.)
  5481. * @param offset defines offset in the buffer (0 by default)
  5482. * @param size defines the size in floats of attributes (position is 3 for instance)
  5483. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  5484. * @param instanced defines if the vertex buffer contains indexed data
  5485. * @param useBytes defines if the offset and stride are in bytes
  5486. * @returns the new vertex buffer
  5487. */
  5488. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  5489. /**
  5490. * Gets a boolean indicating if the Buffer is updatable?
  5491. * @returns true if the buffer is updatable
  5492. */
  5493. isUpdatable(): boolean;
  5494. /**
  5495. * Gets current buffer's data
  5496. * @returns a DataArray or null
  5497. */
  5498. getData(): Nullable<DataArray>;
  5499. /**
  5500. * Gets underlying native buffer
  5501. * @returns underlying native buffer
  5502. */
  5503. getBuffer(): Nullable<WebGLBuffer>;
  5504. /**
  5505. * Gets the stride in float32 units (i.e. byte stride / 4).
  5506. * May not be an integer if the byte stride is not divisible by 4.
  5507. * DEPRECATED. Use byteStride instead.
  5508. * @returns the stride in float32 units
  5509. */
  5510. getStrideSize(): number;
  5511. /**
  5512. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5513. * @param data defines the data to store
  5514. */
  5515. create(data?: Nullable<DataArray>): void;
  5516. /** @hidden */
  5517. _rebuild(): void;
  5518. /**
  5519. * Update current buffer data
  5520. * @param data defines the data to store
  5521. */
  5522. update(data: DataArray): void;
  5523. /**
  5524. * Updates the data directly.
  5525. * @param data the new data
  5526. * @param offset the new offset
  5527. * @param vertexCount the vertex count (optional)
  5528. * @param useBytes set to true if the offset is in bytes
  5529. */
  5530. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  5531. /**
  5532. * Release all resources
  5533. */
  5534. dispose(): void;
  5535. }
  5536. /**
  5537. * Specialized buffer used to store vertex data
  5538. */
  5539. export class VertexBuffer {
  5540. /** @hidden */
  5541. _buffer: Buffer;
  5542. private _kind;
  5543. private _size;
  5544. private _ownsBuffer;
  5545. private _instanced;
  5546. private _instanceDivisor;
  5547. /**
  5548. * The byte type.
  5549. */
  5550. static readonly BYTE: number;
  5551. /**
  5552. * The unsigned byte type.
  5553. */
  5554. static readonly UNSIGNED_BYTE: number;
  5555. /**
  5556. * The short type.
  5557. */
  5558. static readonly SHORT: number;
  5559. /**
  5560. * The unsigned short type.
  5561. */
  5562. static readonly UNSIGNED_SHORT: number;
  5563. /**
  5564. * The integer type.
  5565. */
  5566. static readonly INT: number;
  5567. /**
  5568. * The unsigned integer type.
  5569. */
  5570. static readonly UNSIGNED_INT: number;
  5571. /**
  5572. * The float type.
  5573. */
  5574. static readonly FLOAT: number;
  5575. /**
  5576. * Gets or sets the instance divisor when in instanced mode
  5577. */
  5578. instanceDivisor: number;
  5579. /**
  5580. * Gets the byte stride.
  5581. */
  5582. readonly byteStride: number;
  5583. /**
  5584. * Gets the byte offset.
  5585. */
  5586. readonly byteOffset: number;
  5587. /**
  5588. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  5589. */
  5590. readonly normalized: boolean;
  5591. /**
  5592. * Gets the data type of each component in the array.
  5593. */
  5594. readonly type: number;
  5595. /**
  5596. * Constructor
  5597. * @param engine the engine
  5598. * @param data the data to use for this vertex buffer
  5599. * @param kind the vertex buffer kind
  5600. * @param updatable whether the data is updatable
  5601. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  5602. * @param stride the stride (optional)
  5603. * @param instanced whether the buffer is instanced (optional)
  5604. * @param offset the offset of the data (optional)
  5605. * @param size the number of components (optional)
  5606. * @param type the type of the component (optional)
  5607. * @param normalized whether the data contains normalized data (optional)
  5608. * @param useBytes set to true if stride and offset are in bytes (optional)
  5609. */
  5610. 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);
  5611. /** @hidden */
  5612. _rebuild(): void;
  5613. /**
  5614. * Returns the kind of the VertexBuffer (string)
  5615. * @returns a string
  5616. */
  5617. getKind(): string;
  5618. /**
  5619. * Gets a boolean indicating if the VertexBuffer is updatable?
  5620. * @returns true if the buffer is updatable
  5621. */
  5622. isUpdatable(): boolean;
  5623. /**
  5624. * Gets current buffer's data
  5625. * @returns a DataArray or null
  5626. */
  5627. getData(): Nullable<DataArray>;
  5628. /**
  5629. * Gets underlying native buffer
  5630. * @returns underlying native buffer
  5631. */
  5632. getBuffer(): Nullable<WebGLBuffer>;
  5633. /**
  5634. * Gets the stride in float32 units (i.e. byte stride / 4).
  5635. * May not be an integer if the byte stride is not divisible by 4.
  5636. * DEPRECATED. Use byteStride instead.
  5637. * @returns the stride in float32 units
  5638. */
  5639. getStrideSize(): number;
  5640. /**
  5641. * Returns the offset as a multiple of the type byte length.
  5642. * DEPRECATED. Use byteOffset instead.
  5643. * @returns the offset in bytes
  5644. */
  5645. getOffset(): number;
  5646. /**
  5647. * Returns the number of components per vertex attribute (integer)
  5648. * @returns the size in float
  5649. */
  5650. getSize(): number;
  5651. /**
  5652. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  5653. * @returns true if this buffer is instanced
  5654. */
  5655. getIsInstanced(): boolean;
  5656. /**
  5657. * Returns the instancing divisor, zero for non-instanced (integer).
  5658. * @returns a number
  5659. */
  5660. getInstanceDivisor(): number;
  5661. /**
  5662. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  5663. * @param data defines the data to store
  5664. */
  5665. create(data?: DataArray): void;
  5666. /**
  5667. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  5668. * This function will create a new buffer if the current one is not updatable
  5669. * @param data defines the data to store
  5670. */
  5671. update(data: DataArray): void;
  5672. /**
  5673. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  5674. * Returns the directly updated WebGLBuffer.
  5675. * @param data the new data
  5676. * @param offset the new offset
  5677. * @param useBytes set to true if the offset is in bytes
  5678. */
  5679. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  5680. /**
  5681. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  5682. */
  5683. dispose(): void;
  5684. /**
  5685. * Enumerates each value of this vertex buffer as numbers.
  5686. * @param count the number of values to enumerate
  5687. * @param callback the callback function called for each value
  5688. */
  5689. forEach(count: number, callback: (value: number, index: number) => void): void;
  5690. /**
  5691. * Positions
  5692. */
  5693. static readonly PositionKind: string;
  5694. /**
  5695. * Normals
  5696. */
  5697. static readonly NormalKind: string;
  5698. /**
  5699. * Tangents
  5700. */
  5701. static readonly TangentKind: string;
  5702. /**
  5703. * Texture coordinates
  5704. */
  5705. static readonly UVKind: string;
  5706. /**
  5707. * Texture coordinates 2
  5708. */
  5709. static readonly UV2Kind: string;
  5710. /**
  5711. * Texture coordinates 3
  5712. */
  5713. static readonly UV3Kind: string;
  5714. /**
  5715. * Texture coordinates 4
  5716. */
  5717. static readonly UV4Kind: string;
  5718. /**
  5719. * Texture coordinates 5
  5720. */
  5721. static readonly UV5Kind: string;
  5722. /**
  5723. * Texture coordinates 6
  5724. */
  5725. static readonly UV6Kind: string;
  5726. /**
  5727. * Colors
  5728. */
  5729. static readonly ColorKind: string;
  5730. /**
  5731. * Matrix indices (for bones)
  5732. */
  5733. static readonly MatricesIndicesKind: string;
  5734. /**
  5735. * Matrix weights (for bones)
  5736. */
  5737. static readonly MatricesWeightsKind: string;
  5738. /**
  5739. * Additional matrix indices (for bones)
  5740. */
  5741. static readonly MatricesIndicesExtraKind: string;
  5742. /**
  5743. * Additional matrix weights (for bones)
  5744. */
  5745. static readonly MatricesWeightsExtraKind: string;
  5746. /**
  5747. * Deduces the stride given a kind.
  5748. * @param kind The kind string to deduce
  5749. * @returns The deduced stride
  5750. */
  5751. static DeduceStride(kind: string): number;
  5752. /**
  5753. * Gets the byte length of the given type.
  5754. * @param type the type
  5755. * @returns the number of bytes
  5756. */
  5757. static GetTypeByteLength(type: number): number;
  5758. /**
  5759. * Enumerates each value of the given parameters as numbers.
  5760. * @param data the data to enumerate
  5761. * @param byteOffset the byte offset of the data
  5762. * @param byteStride the byte stride of the data
  5763. * @param componentCount the number of components per element
  5764. * @param componentType the type of the component
  5765. * @param count the total number of components
  5766. * @param normalized whether the data is normalized
  5767. * @param callback the callback function called for each value
  5768. */
  5769. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  5770. private static _GetFloatValue;
  5771. }
  5772. }
  5773. declare module "babylonjs/Maths/sphericalPolynomial" {
  5774. import { Vector3, Color3 } from "babylonjs/Maths/math";
  5775. /**
  5776. * Class representing spherical polynomial coefficients to the 3rd degree
  5777. */
  5778. export class SphericalPolynomial {
  5779. /**
  5780. * The x coefficients of the spherical polynomial
  5781. */
  5782. x: Vector3;
  5783. /**
  5784. * The y coefficients of the spherical polynomial
  5785. */
  5786. y: Vector3;
  5787. /**
  5788. * The z coefficients of the spherical polynomial
  5789. */
  5790. z: Vector3;
  5791. /**
  5792. * The xx coefficients of the spherical polynomial
  5793. */
  5794. xx: Vector3;
  5795. /**
  5796. * The yy coefficients of the spherical polynomial
  5797. */
  5798. yy: Vector3;
  5799. /**
  5800. * The zz coefficients of the spherical polynomial
  5801. */
  5802. zz: Vector3;
  5803. /**
  5804. * The xy coefficients of the spherical polynomial
  5805. */
  5806. xy: Vector3;
  5807. /**
  5808. * The yz coefficients of the spherical polynomial
  5809. */
  5810. yz: Vector3;
  5811. /**
  5812. * The zx coefficients of the spherical polynomial
  5813. */
  5814. zx: Vector3;
  5815. /**
  5816. * Adds an ambient color to the spherical polynomial
  5817. * @param color the color to add
  5818. */
  5819. addAmbient(color: Color3): void;
  5820. /**
  5821. * Scales the spherical polynomial by the given amount
  5822. * @param scale the amount to scale
  5823. */
  5824. scale(scale: number): void;
  5825. /**
  5826. * Gets the spherical polynomial from harmonics
  5827. * @param harmonics the spherical harmonics
  5828. * @returns the spherical polynomial
  5829. */
  5830. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  5831. /**
  5832. * Constructs a spherical polynomial from an array.
  5833. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  5834. * @returns the spherical polynomial
  5835. */
  5836. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  5837. }
  5838. /**
  5839. * Class representing spherical harmonics coefficients to the 3rd degree
  5840. */
  5841. export class SphericalHarmonics {
  5842. /**
  5843. * The l0,0 coefficients of the spherical harmonics
  5844. */
  5845. l00: Vector3;
  5846. /**
  5847. * The l1,-1 coefficients of the spherical harmonics
  5848. */
  5849. l1_1: Vector3;
  5850. /**
  5851. * The l1,0 coefficients of the spherical harmonics
  5852. */
  5853. l10: Vector3;
  5854. /**
  5855. * The l1,1 coefficients of the spherical harmonics
  5856. */
  5857. l11: Vector3;
  5858. /**
  5859. * The l2,-2 coefficients of the spherical harmonics
  5860. */
  5861. l2_2: Vector3;
  5862. /**
  5863. * The l2,-1 coefficients of the spherical harmonics
  5864. */
  5865. l2_1: Vector3;
  5866. /**
  5867. * The l2,0 coefficients of the spherical harmonics
  5868. */
  5869. l20: Vector3;
  5870. /**
  5871. * The l2,1 coefficients of the spherical harmonics
  5872. */
  5873. l21: Vector3;
  5874. /**
  5875. * The l2,2 coefficients of the spherical harmonics
  5876. */
  5877. lL22: Vector3;
  5878. /**
  5879. * Adds a light to the spherical harmonics
  5880. * @param direction the direction of the light
  5881. * @param color the color of the light
  5882. * @param deltaSolidAngle the delta solid angle of the light
  5883. */
  5884. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  5885. /**
  5886. * Scales the spherical harmonics by the given amount
  5887. * @param scale the amount to scale
  5888. */
  5889. scale(scale: number): void;
  5890. /**
  5891. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  5892. *
  5893. * ```
  5894. * E_lm = A_l * L_lm
  5895. * ```
  5896. *
  5897. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  5898. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  5899. * the scaling factors are given in equation 9.
  5900. */
  5901. convertIncidentRadianceToIrradiance(): void;
  5902. /**
  5903. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  5904. *
  5905. * ```
  5906. * L = (1/pi) * E * rho
  5907. * ```
  5908. *
  5909. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  5910. */
  5911. convertIrradianceToLambertianRadiance(): void;
  5912. /**
  5913. * Gets the spherical harmonics from polynomial
  5914. * @param polynomial the spherical polynomial
  5915. * @returns the spherical harmonics
  5916. */
  5917. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  5918. /**
  5919. * Constructs a spherical harmonics from an array.
  5920. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  5921. * @returns the spherical harmonics
  5922. */
  5923. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  5924. }
  5925. }
  5926. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  5927. import { Nullable } from "babylonjs/types";
  5928. /**
  5929. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  5930. */
  5931. export interface CubeMapInfo {
  5932. /**
  5933. * The pixel array for the front face.
  5934. * This is stored in format, left to right, up to down format.
  5935. */
  5936. front: Nullable<ArrayBufferView>;
  5937. /**
  5938. * The pixel array for the back face.
  5939. * This is stored in format, left to right, up to down format.
  5940. */
  5941. back: Nullable<ArrayBufferView>;
  5942. /**
  5943. * The pixel array for the left face.
  5944. * This is stored in format, left to right, up to down format.
  5945. */
  5946. left: Nullable<ArrayBufferView>;
  5947. /**
  5948. * The pixel array for the right face.
  5949. * This is stored in format, left to right, up to down format.
  5950. */
  5951. right: Nullable<ArrayBufferView>;
  5952. /**
  5953. * The pixel array for the up face.
  5954. * This is stored in format, left to right, up to down format.
  5955. */
  5956. up: Nullable<ArrayBufferView>;
  5957. /**
  5958. * The pixel array for the down face.
  5959. * This is stored in format, left to right, up to down format.
  5960. */
  5961. down: Nullable<ArrayBufferView>;
  5962. /**
  5963. * The size of the cubemap stored.
  5964. *
  5965. * Each faces will be size * size pixels.
  5966. */
  5967. size: number;
  5968. /**
  5969. * The format of the texture.
  5970. *
  5971. * RGBA, RGB.
  5972. */
  5973. format: number;
  5974. /**
  5975. * The type of the texture data.
  5976. *
  5977. * UNSIGNED_INT, FLOAT.
  5978. */
  5979. type: number;
  5980. /**
  5981. * Specifies whether the texture is in gamma space.
  5982. */
  5983. gammaSpace: boolean;
  5984. }
  5985. /**
  5986. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  5987. */
  5988. export class PanoramaToCubeMapTools {
  5989. private static FACE_FRONT;
  5990. private static FACE_BACK;
  5991. private static FACE_RIGHT;
  5992. private static FACE_LEFT;
  5993. private static FACE_DOWN;
  5994. private static FACE_UP;
  5995. /**
  5996. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  5997. *
  5998. * @param float32Array The source data.
  5999. * @param inputWidth The width of the input panorama.
  6000. * @param inputHeight The height of the input panorama.
  6001. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  6002. * @return The cubemap data
  6003. */
  6004. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  6005. private static CreateCubemapTexture;
  6006. private static CalcProjectionSpherical;
  6007. }
  6008. }
  6009. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  6010. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6011. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6012. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  6013. /**
  6014. * Helper class dealing with the extraction of spherical polynomial dataArray
  6015. * from a cube map.
  6016. */
  6017. export class CubeMapToSphericalPolynomialTools {
  6018. private static FileFaces;
  6019. /**
  6020. * Converts a texture to the according Spherical Polynomial data.
  6021. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6022. *
  6023. * @param texture The texture to extract the information from.
  6024. * @return The Spherical Polynomial data.
  6025. */
  6026. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  6027. /**
  6028. * Converts a cubemap to the according Spherical Polynomial data.
  6029. * This extracts the first 3 orders only as they are the only one used in the lighting.
  6030. *
  6031. * @param cubeInfo The Cube map to extract the information from.
  6032. * @return The Spherical Polynomial data.
  6033. */
  6034. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  6035. }
  6036. }
  6037. declare module "babylonjs/Engines/engineStore" {
  6038. import { Nullable } from "babylonjs/types";
  6039. import { Engine } from "babylonjs/Engines/engine";
  6040. import { Scene } from "babylonjs/scene";
  6041. /**
  6042. * The engine store class is responsible to hold all the instances of Engine and Scene created
  6043. * during the life time of the application.
  6044. */
  6045. export class EngineStore {
  6046. /** Gets the list of created engines */
  6047. static Instances: import("babylonjs/Engines/engine").Engine[];
  6048. /**
  6049. * Gets the latest created engine
  6050. */
  6051. static readonly LastCreatedEngine: Nullable<Engine>;
  6052. /**
  6053. * Gets the latest created scene
  6054. */
  6055. static readonly LastCreatedScene: Nullable<Scene>;
  6056. }
  6057. }
  6058. declare module "babylonjs/Materials/Textures/renderTargetCreationOptions" {
  6059. /**
  6060. * Define options used to create a render target texture
  6061. */
  6062. export class RenderTargetCreationOptions {
  6063. /**
  6064. * Specifies is mipmaps must be generated
  6065. */
  6066. generateMipMaps?: boolean;
  6067. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  6068. generateDepthBuffer?: boolean;
  6069. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  6070. generateStencilBuffer?: boolean;
  6071. /** Defines texture type (int by default) */
  6072. type?: number;
  6073. /** Defines sampling mode (trilinear by default) */
  6074. samplingMode?: number;
  6075. /** Defines format (RGBA by default) */
  6076. format?: number;
  6077. }
  6078. }
  6079. declare module "babylonjs/States/alphaCullingState" {
  6080. /**
  6081. * @hidden
  6082. **/
  6083. export class _AlphaState {
  6084. private _isAlphaBlendDirty;
  6085. private _isBlendFunctionParametersDirty;
  6086. private _isBlendEquationParametersDirty;
  6087. private _isBlendConstantsDirty;
  6088. private _alphaBlend;
  6089. private _blendFunctionParameters;
  6090. private _blendEquationParameters;
  6091. private _blendConstants;
  6092. /**
  6093. * Initializes the state.
  6094. */
  6095. constructor();
  6096. readonly isDirty: boolean;
  6097. alphaBlend: boolean;
  6098. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  6099. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  6100. setAlphaEquationParameters(rgb: number, alpha: number): void;
  6101. reset(): void;
  6102. apply(gl: WebGLRenderingContext): void;
  6103. }
  6104. }
  6105. declare module "babylonjs/States/depthCullingState" {
  6106. import { Nullable } from "babylonjs/types";
  6107. /**
  6108. * @hidden
  6109. **/
  6110. export class _DepthCullingState {
  6111. private _isDepthTestDirty;
  6112. private _isDepthMaskDirty;
  6113. private _isDepthFuncDirty;
  6114. private _isCullFaceDirty;
  6115. private _isCullDirty;
  6116. private _isZOffsetDirty;
  6117. private _isFrontFaceDirty;
  6118. private _depthTest;
  6119. private _depthMask;
  6120. private _depthFunc;
  6121. private _cull;
  6122. private _cullFace;
  6123. private _zOffset;
  6124. private _frontFace;
  6125. /**
  6126. * Initializes the state.
  6127. */
  6128. constructor();
  6129. readonly isDirty: boolean;
  6130. zOffset: number;
  6131. cullFace: Nullable<number>;
  6132. cull: Nullable<boolean>;
  6133. depthFunc: Nullable<number>;
  6134. depthMask: boolean;
  6135. depthTest: boolean;
  6136. frontFace: Nullable<number>;
  6137. reset(): void;
  6138. apply(gl: WebGLRenderingContext): void;
  6139. }
  6140. }
  6141. declare module "babylonjs/States/stencilState" {
  6142. /**
  6143. * @hidden
  6144. **/
  6145. export class _StencilState {
  6146. /** 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 */
  6147. static readonly ALWAYS: number;
  6148. /** Passed to stencilOperation to specify that stencil value must be kept */
  6149. static readonly KEEP: number;
  6150. /** Passed to stencilOperation to specify that stencil value must be replaced */
  6151. static readonly REPLACE: number;
  6152. private _isStencilTestDirty;
  6153. private _isStencilMaskDirty;
  6154. private _isStencilFuncDirty;
  6155. private _isStencilOpDirty;
  6156. private _stencilTest;
  6157. private _stencilMask;
  6158. private _stencilFunc;
  6159. private _stencilFuncRef;
  6160. private _stencilFuncMask;
  6161. private _stencilOpStencilFail;
  6162. private _stencilOpDepthFail;
  6163. private _stencilOpStencilDepthPass;
  6164. readonly isDirty: boolean;
  6165. stencilFunc: number;
  6166. stencilFuncRef: number;
  6167. stencilFuncMask: number;
  6168. stencilOpStencilFail: number;
  6169. stencilOpDepthFail: number;
  6170. stencilOpStencilDepthPass: number;
  6171. stencilMask: number;
  6172. stencilTest: boolean;
  6173. constructor();
  6174. reset(): void;
  6175. apply(gl: WebGLRenderingContext): void;
  6176. }
  6177. }
  6178. declare module "babylonjs/States/index" {
  6179. export * from "babylonjs/States/alphaCullingState";
  6180. export * from "babylonjs/States/depthCullingState";
  6181. export * from "babylonjs/States/stencilState";
  6182. }
  6183. declare module "babylonjs/Instrumentation/timeToken" {
  6184. import { Nullable } from "babylonjs/types";
  6185. /**
  6186. * @hidden
  6187. **/
  6188. export class _TimeToken {
  6189. _startTimeQuery: Nullable<WebGLQuery>;
  6190. _endTimeQuery: Nullable<WebGLQuery>;
  6191. _timeElapsedQuery: Nullable<WebGLQuery>;
  6192. _timeElapsedQueryEnded: boolean;
  6193. }
  6194. }
  6195. declare module "babylonjs/Materials/Textures/internalTexture" {
  6196. import { Observable } from "babylonjs/Misc/observable";
  6197. import { Nullable, int } from "babylonjs/types";
  6198. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  6199. import { Engine } from "babylonjs/Engines/engine";
  6200. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  6201. /**
  6202. * Class used to store data associated with WebGL texture data for the engine
  6203. * This class should not be used directly
  6204. */
  6205. export class InternalTexture {
  6206. /** hidden */
  6207. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  6208. /**
  6209. * The source of the texture data is unknown
  6210. */
  6211. static DATASOURCE_UNKNOWN: number;
  6212. /**
  6213. * Texture data comes from an URL
  6214. */
  6215. static DATASOURCE_URL: number;
  6216. /**
  6217. * Texture data is only used for temporary storage
  6218. */
  6219. static DATASOURCE_TEMP: number;
  6220. /**
  6221. * Texture data comes from raw data (ArrayBuffer)
  6222. */
  6223. static DATASOURCE_RAW: number;
  6224. /**
  6225. * Texture content is dynamic (video or dynamic texture)
  6226. */
  6227. static DATASOURCE_DYNAMIC: number;
  6228. /**
  6229. * Texture content is generated by rendering to it
  6230. */
  6231. static DATASOURCE_RENDERTARGET: number;
  6232. /**
  6233. * Texture content is part of a multi render target process
  6234. */
  6235. static DATASOURCE_MULTIRENDERTARGET: number;
  6236. /**
  6237. * Texture data comes from a cube data file
  6238. */
  6239. static DATASOURCE_CUBE: number;
  6240. /**
  6241. * Texture data comes from a raw cube data
  6242. */
  6243. static DATASOURCE_CUBERAW: number;
  6244. /**
  6245. * Texture data come from a prefiltered cube data file
  6246. */
  6247. static DATASOURCE_CUBEPREFILTERED: number;
  6248. /**
  6249. * Texture content is raw 3D data
  6250. */
  6251. static DATASOURCE_RAW3D: number;
  6252. /**
  6253. * Texture content is a depth texture
  6254. */
  6255. static DATASOURCE_DEPTHTEXTURE: number;
  6256. /**
  6257. * Texture data comes from a raw cube data encoded with RGBD
  6258. */
  6259. static DATASOURCE_CUBERAW_RGBD: number;
  6260. /**
  6261. * Defines if the texture is ready
  6262. */
  6263. isReady: boolean;
  6264. /**
  6265. * Defines if the texture is a cube texture
  6266. */
  6267. isCube: boolean;
  6268. /**
  6269. * Defines if the texture contains 3D data
  6270. */
  6271. is3D: boolean;
  6272. /**
  6273. * Defines if the texture contains multiview data
  6274. */
  6275. isMultiview: boolean;
  6276. /**
  6277. * Gets the URL used to load this texture
  6278. */
  6279. url: string;
  6280. /**
  6281. * Gets the sampling mode of the texture
  6282. */
  6283. samplingMode: number;
  6284. /**
  6285. * Gets a boolean indicating if the texture needs mipmaps generation
  6286. */
  6287. generateMipMaps: boolean;
  6288. /**
  6289. * Gets the number of samples used by the texture (WebGL2+ only)
  6290. */
  6291. samples: number;
  6292. /**
  6293. * Gets the type of the texture (int, float...)
  6294. */
  6295. type: number;
  6296. /**
  6297. * Gets the format of the texture (RGB, RGBA...)
  6298. */
  6299. format: number;
  6300. /**
  6301. * Observable called when the texture is loaded
  6302. */
  6303. onLoadedObservable: Observable<InternalTexture>;
  6304. /**
  6305. * Gets the width of the texture
  6306. */
  6307. width: number;
  6308. /**
  6309. * Gets the height of the texture
  6310. */
  6311. height: number;
  6312. /**
  6313. * Gets the depth of the texture
  6314. */
  6315. depth: number;
  6316. /**
  6317. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  6318. */
  6319. baseWidth: number;
  6320. /**
  6321. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  6322. */
  6323. baseHeight: number;
  6324. /**
  6325. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  6326. */
  6327. baseDepth: number;
  6328. /**
  6329. * Gets a boolean indicating if the texture is inverted on Y axis
  6330. */
  6331. invertY: boolean;
  6332. /** @hidden */
  6333. _invertVScale: boolean;
  6334. /** @hidden */
  6335. _associatedChannel: number;
  6336. /** @hidden */
  6337. _dataSource: number;
  6338. /** @hidden */
  6339. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  6340. /** @hidden */
  6341. _bufferView: Nullable<ArrayBufferView>;
  6342. /** @hidden */
  6343. _bufferViewArray: Nullable<ArrayBufferView[]>;
  6344. /** @hidden */
  6345. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  6346. /** @hidden */
  6347. _size: number;
  6348. /** @hidden */
  6349. _extension: string;
  6350. /** @hidden */
  6351. _files: Nullable<string[]>;
  6352. /** @hidden */
  6353. _workingCanvas: Nullable<HTMLCanvasElement>;
  6354. /** @hidden */
  6355. _workingContext: Nullable<CanvasRenderingContext2D>;
  6356. /** @hidden */
  6357. _framebuffer: Nullable<WebGLFramebuffer>;
  6358. /** @hidden */
  6359. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  6360. /** @hidden */
  6361. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  6362. /** @hidden */
  6363. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  6364. /** @hidden */
  6365. _attachments: Nullable<number[]>;
  6366. /** @hidden */
  6367. _cachedCoordinatesMode: Nullable<number>;
  6368. /** @hidden */
  6369. _cachedWrapU: Nullable<number>;
  6370. /** @hidden */
  6371. _cachedWrapV: Nullable<number>;
  6372. /** @hidden */
  6373. _cachedWrapR: Nullable<number>;
  6374. /** @hidden */
  6375. _cachedAnisotropicFilteringLevel: Nullable<number>;
  6376. /** @hidden */
  6377. _isDisabled: boolean;
  6378. /** @hidden */
  6379. _compression: Nullable<string>;
  6380. /** @hidden */
  6381. _generateStencilBuffer: boolean;
  6382. /** @hidden */
  6383. _generateDepthBuffer: boolean;
  6384. /** @hidden */
  6385. _comparisonFunction: number;
  6386. /** @hidden */
  6387. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  6388. /** @hidden */
  6389. _lodGenerationScale: number;
  6390. /** @hidden */
  6391. _lodGenerationOffset: number;
  6392. /** @hidden */
  6393. _colorTextureArray: Nullable<WebGLTexture>;
  6394. /** @hidden */
  6395. _depthStencilTextureArray: Nullable<WebGLTexture>;
  6396. /** @hidden */
  6397. _lodTextureHigh: Nullable<BaseTexture>;
  6398. /** @hidden */
  6399. _lodTextureMid: Nullable<BaseTexture>;
  6400. /** @hidden */
  6401. _lodTextureLow: Nullable<BaseTexture>;
  6402. /** @hidden */
  6403. _isRGBD: boolean;
  6404. /** @hidden */
  6405. _webGLTexture: Nullable<WebGLTexture>;
  6406. /** @hidden */
  6407. _references: number;
  6408. private _engine;
  6409. /**
  6410. * Gets the Engine the texture belongs to.
  6411. * @returns The babylon engine
  6412. */
  6413. getEngine(): Engine;
  6414. /**
  6415. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  6416. */
  6417. readonly dataSource: number;
  6418. /**
  6419. * Creates a new InternalTexture
  6420. * @param engine defines the engine to use
  6421. * @param dataSource defines the type of data that will be used
  6422. * @param delayAllocation if the texture allocation should be delayed (default: false)
  6423. */
  6424. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  6425. /**
  6426. * Increments the number of references (ie. the number of Texture that point to it)
  6427. */
  6428. incrementReferences(): void;
  6429. /**
  6430. * Change the size of the texture (not the size of the content)
  6431. * @param width defines the new width
  6432. * @param height defines the new height
  6433. * @param depth defines the new depth (1 by default)
  6434. */
  6435. updateSize(width: int, height: int, depth?: int): void;
  6436. /** @hidden */
  6437. _rebuild(): void;
  6438. /** @hidden */
  6439. _swapAndDie(target: InternalTexture): void;
  6440. /**
  6441. * Dispose the current allocated resources
  6442. */
  6443. dispose(): void;
  6444. }
  6445. }
  6446. declare module "babylonjs/Animations/easing" {
  6447. /**
  6448. * This represents the main contract an easing function should follow.
  6449. * Easing functions are used throughout the animation system.
  6450. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6451. */
  6452. export interface IEasingFunction {
  6453. /**
  6454. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6455. * of the easing function.
  6456. * The link below provides some of the most common examples of easing functions.
  6457. * @see https://easings.net/
  6458. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6459. * @returns the corresponding value on the curve defined by the easing function
  6460. */
  6461. ease(gradient: number): number;
  6462. }
  6463. /**
  6464. * Base class used for every default easing function.
  6465. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6466. */
  6467. export class EasingFunction implements IEasingFunction {
  6468. /**
  6469. * Interpolation follows the mathematical formula associated with the easing function.
  6470. */
  6471. static readonly EASINGMODE_EASEIN: number;
  6472. /**
  6473. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  6474. */
  6475. static readonly EASINGMODE_EASEOUT: number;
  6476. /**
  6477. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  6478. */
  6479. static readonly EASINGMODE_EASEINOUT: number;
  6480. private _easingMode;
  6481. /**
  6482. * Sets the easing mode of the current function.
  6483. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  6484. */
  6485. setEasingMode(easingMode: number): void;
  6486. /**
  6487. * Gets the current easing mode.
  6488. * @returns the easing mode
  6489. */
  6490. getEasingMode(): number;
  6491. /**
  6492. * @hidden
  6493. */
  6494. easeInCore(gradient: number): number;
  6495. /**
  6496. * Given an input gradient between 0 and 1, this returns the corrseponding value
  6497. * of the easing function.
  6498. * @param gradient Defines the value between 0 and 1 we want the easing value for
  6499. * @returns the corresponding value on the curve defined by the easing function
  6500. */
  6501. ease(gradient: number): number;
  6502. }
  6503. /**
  6504. * Easing function with a circle shape (see link below).
  6505. * @see https://easings.net/#easeInCirc
  6506. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6507. */
  6508. export class CircleEase extends EasingFunction implements IEasingFunction {
  6509. /** @hidden */
  6510. easeInCore(gradient: number): number;
  6511. }
  6512. /**
  6513. * Easing function with a ease back shape (see link below).
  6514. * @see https://easings.net/#easeInBack
  6515. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6516. */
  6517. export class BackEase extends EasingFunction implements IEasingFunction {
  6518. /** Defines the amplitude of the function */
  6519. amplitude: number;
  6520. /**
  6521. * Instantiates a back ease easing
  6522. * @see https://easings.net/#easeInBack
  6523. * @param amplitude Defines the amplitude of the function
  6524. */
  6525. constructor(
  6526. /** Defines the amplitude of the function */
  6527. amplitude?: number);
  6528. /** @hidden */
  6529. easeInCore(gradient: number): number;
  6530. }
  6531. /**
  6532. * Easing function with a bouncing shape (see link below).
  6533. * @see https://easings.net/#easeInBounce
  6534. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6535. */
  6536. export class BounceEase extends EasingFunction implements IEasingFunction {
  6537. /** Defines the number of bounces */
  6538. bounces: number;
  6539. /** Defines the amplitude of the bounce */
  6540. bounciness: number;
  6541. /**
  6542. * Instantiates a bounce easing
  6543. * @see https://easings.net/#easeInBounce
  6544. * @param bounces Defines the number of bounces
  6545. * @param bounciness Defines the amplitude of the bounce
  6546. */
  6547. constructor(
  6548. /** Defines the number of bounces */
  6549. bounces?: number,
  6550. /** Defines the amplitude of the bounce */
  6551. bounciness?: number);
  6552. /** @hidden */
  6553. easeInCore(gradient: number): number;
  6554. }
  6555. /**
  6556. * Easing function with a power of 3 shape (see link below).
  6557. * @see https://easings.net/#easeInCubic
  6558. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6559. */
  6560. export class CubicEase extends EasingFunction implements IEasingFunction {
  6561. /** @hidden */
  6562. easeInCore(gradient: number): number;
  6563. }
  6564. /**
  6565. * Easing function with an elastic shape (see link below).
  6566. * @see https://easings.net/#easeInElastic
  6567. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6568. */
  6569. export class ElasticEase extends EasingFunction implements IEasingFunction {
  6570. /** Defines the number of oscillations*/
  6571. oscillations: number;
  6572. /** Defines the amplitude of the oscillations*/
  6573. springiness: number;
  6574. /**
  6575. * Instantiates an elastic easing function
  6576. * @see https://easings.net/#easeInElastic
  6577. * @param oscillations Defines the number of oscillations
  6578. * @param springiness Defines the amplitude of the oscillations
  6579. */
  6580. constructor(
  6581. /** Defines the number of oscillations*/
  6582. oscillations?: number,
  6583. /** Defines the amplitude of the oscillations*/
  6584. springiness?: number);
  6585. /** @hidden */
  6586. easeInCore(gradient: number): number;
  6587. }
  6588. /**
  6589. * Easing function with an exponential shape (see link below).
  6590. * @see https://easings.net/#easeInExpo
  6591. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6592. */
  6593. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  6594. /** Defines the exponent of the function */
  6595. exponent: number;
  6596. /**
  6597. * Instantiates an exponential easing function
  6598. * @see https://easings.net/#easeInExpo
  6599. * @param exponent Defines the exponent of the function
  6600. */
  6601. constructor(
  6602. /** Defines the exponent of the function */
  6603. exponent?: number);
  6604. /** @hidden */
  6605. easeInCore(gradient: number): number;
  6606. }
  6607. /**
  6608. * Easing function with a power shape (see link below).
  6609. * @see https://easings.net/#easeInQuad
  6610. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6611. */
  6612. export class PowerEase extends EasingFunction implements IEasingFunction {
  6613. /** Defines the power of the function */
  6614. power: number;
  6615. /**
  6616. * Instantiates an power base easing function
  6617. * @see https://easings.net/#easeInQuad
  6618. * @param power Defines the power of the function
  6619. */
  6620. constructor(
  6621. /** Defines the power of the function */
  6622. power?: number);
  6623. /** @hidden */
  6624. easeInCore(gradient: number): number;
  6625. }
  6626. /**
  6627. * Easing function with a power of 2 shape (see link below).
  6628. * @see https://easings.net/#easeInQuad
  6629. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6630. */
  6631. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  6632. /** @hidden */
  6633. easeInCore(gradient: number): number;
  6634. }
  6635. /**
  6636. * Easing function with a power of 4 shape (see link below).
  6637. * @see https://easings.net/#easeInQuart
  6638. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6639. */
  6640. export class QuarticEase extends EasingFunction implements IEasingFunction {
  6641. /** @hidden */
  6642. easeInCore(gradient: number): number;
  6643. }
  6644. /**
  6645. * Easing function with a power of 5 shape (see link below).
  6646. * @see https://easings.net/#easeInQuint
  6647. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6648. */
  6649. export class QuinticEase extends EasingFunction implements IEasingFunction {
  6650. /** @hidden */
  6651. easeInCore(gradient: number): number;
  6652. }
  6653. /**
  6654. * Easing function with a sin shape (see link below).
  6655. * @see https://easings.net/#easeInSine
  6656. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6657. */
  6658. export class SineEase extends EasingFunction implements IEasingFunction {
  6659. /** @hidden */
  6660. easeInCore(gradient: number): number;
  6661. }
  6662. /**
  6663. * Easing function with a bezier shape (see link below).
  6664. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6665. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  6666. */
  6667. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  6668. /** Defines the x component of the start tangent in the bezier curve */
  6669. x1: number;
  6670. /** Defines the y component of the start tangent in the bezier curve */
  6671. y1: number;
  6672. /** Defines the x component of the end tangent in the bezier curve */
  6673. x2: number;
  6674. /** Defines the y component of the end tangent in the bezier curve */
  6675. y2: number;
  6676. /**
  6677. * Instantiates a bezier function
  6678. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  6679. * @param x1 Defines the x component of the start tangent in the bezier curve
  6680. * @param y1 Defines the y component of the start tangent in the bezier curve
  6681. * @param x2 Defines the x component of the end tangent in the bezier curve
  6682. * @param y2 Defines the y component of the end tangent in the bezier curve
  6683. */
  6684. constructor(
  6685. /** Defines the x component of the start tangent in the bezier curve */
  6686. x1?: number,
  6687. /** Defines the y component of the start tangent in the bezier curve */
  6688. y1?: number,
  6689. /** Defines the x component of the end tangent in the bezier curve */
  6690. x2?: number,
  6691. /** Defines the y component of the end tangent in the bezier curve */
  6692. y2?: number);
  6693. /** @hidden */
  6694. easeInCore(gradient: number): number;
  6695. }
  6696. }
  6697. declare module "babylonjs/Animations/animationKey" {
  6698. /**
  6699. * Defines an interface which represents an animation key frame
  6700. */
  6701. export interface IAnimationKey {
  6702. /**
  6703. * Frame of the key frame
  6704. */
  6705. frame: number;
  6706. /**
  6707. * Value at the specifies key frame
  6708. */
  6709. value: any;
  6710. /**
  6711. * The input tangent for the cubic hermite spline
  6712. */
  6713. inTangent?: any;
  6714. /**
  6715. * The output tangent for the cubic hermite spline
  6716. */
  6717. outTangent?: any;
  6718. /**
  6719. * The animation interpolation type
  6720. */
  6721. interpolation?: AnimationKeyInterpolation;
  6722. }
  6723. /**
  6724. * Enum for the animation key frame interpolation type
  6725. */
  6726. export enum AnimationKeyInterpolation {
  6727. /**
  6728. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6729. */
  6730. STEP = 1
  6731. }
  6732. }
  6733. declare module "babylonjs/Animations/animationRange" {
  6734. /**
  6735. * Represents the range of an animation
  6736. */
  6737. export class AnimationRange {
  6738. /**The name of the animation range**/
  6739. name: string;
  6740. /**The starting frame of the animation */
  6741. from: number;
  6742. /**The ending frame of the animation*/
  6743. to: number;
  6744. /**
  6745. * Initializes the range of an animation
  6746. * @param name The name of the animation range
  6747. * @param from The starting frame of the animation
  6748. * @param to The ending frame of the animation
  6749. */
  6750. constructor(
  6751. /**The name of the animation range**/
  6752. name: string,
  6753. /**The starting frame of the animation */
  6754. from: number,
  6755. /**The ending frame of the animation*/
  6756. to: number);
  6757. /**
  6758. * Makes a copy of the animation range
  6759. * @returns A copy of the animation range
  6760. */
  6761. clone(): AnimationRange;
  6762. }
  6763. }
  6764. declare module "babylonjs/Animations/animationEvent" {
  6765. /**
  6766. * Composed of a frame, and an action function
  6767. */
  6768. export class AnimationEvent {
  6769. /** The frame for which the event is triggered **/
  6770. frame: number;
  6771. /** The event to perform when triggered **/
  6772. action: (currentFrame: number) => void;
  6773. /** Specifies if the event should be triggered only once**/
  6774. onlyOnce?: boolean | undefined;
  6775. /**
  6776. * Specifies if the animation event is done
  6777. */
  6778. isDone: boolean;
  6779. /**
  6780. * Initializes the animation event
  6781. * @param frame The frame for which the event is triggered
  6782. * @param action The event to perform when triggered
  6783. * @param onlyOnce Specifies if the event should be triggered only once
  6784. */
  6785. constructor(
  6786. /** The frame for which the event is triggered **/
  6787. frame: number,
  6788. /** The event to perform when triggered **/
  6789. action: (currentFrame: number) => void,
  6790. /** Specifies if the event should be triggered only once**/
  6791. onlyOnce?: boolean | undefined);
  6792. /** @hidden */
  6793. _clone(): AnimationEvent;
  6794. }
  6795. }
  6796. declare module "babylonjs/Behaviors/behavior" {
  6797. import { Nullable } from "babylonjs/types";
  6798. /**
  6799. * Interface used to define a behavior
  6800. */
  6801. export interface Behavior<T> {
  6802. /** gets or sets behavior's name */
  6803. name: string;
  6804. /**
  6805. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6806. */
  6807. init(): void;
  6808. /**
  6809. * Called when the behavior is attached to a target
  6810. * @param target defines the target where the behavior is attached to
  6811. */
  6812. attach(target: T): void;
  6813. /**
  6814. * Called when the behavior is detached from its target
  6815. */
  6816. detach(): void;
  6817. }
  6818. /**
  6819. * Interface implemented by classes supporting behaviors
  6820. */
  6821. export interface IBehaviorAware<T> {
  6822. /**
  6823. * Attach a behavior
  6824. * @param behavior defines the behavior to attach
  6825. * @returns the current host
  6826. */
  6827. addBehavior(behavior: Behavior<T>): T;
  6828. /**
  6829. * Remove a behavior from the current object
  6830. * @param behavior defines the behavior to detach
  6831. * @returns the current host
  6832. */
  6833. removeBehavior(behavior: Behavior<T>): T;
  6834. /**
  6835. * Gets a behavior using its name to search
  6836. * @param name defines the name to search
  6837. * @returns the behavior or null if not found
  6838. */
  6839. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6840. }
  6841. }
  6842. declare module "babylonjs/Collisions/intersectionInfo" {
  6843. import { Nullable } from "babylonjs/types";
  6844. /**
  6845. * @hidden
  6846. */
  6847. export class IntersectionInfo {
  6848. bu: Nullable<number>;
  6849. bv: Nullable<number>;
  6850. distance: number;
  6851. faceId: number;
  6852. subMeshId: number;
  6853. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6854. }
  6855. }
  6856. declare module "babylonjs/Culling/boundingSphere" {
  6857. import { DeepImmutable } from "babylonjs/types";
  6858. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6859. /**
  6860. * Class used to store bounding sphere information
  6861. */
  6862. export class BoundingSphere {
  6863. /**
  6864. * Gets the center of the bounding sphere in local space
  6865. */
  6866. readonly center: Vector3;
  6867. /**
  6868. * Radius of the bounding sphere in local space
  6869. */
  6870. radius: number;
  6871. /**
  6872. * Gets the center of the bounding sphere in world space
  6873. */
  6874. readonly centerWorld: Vector3;
  6875. /**
  6876. * Radius of the bounding sphere in world space
  6877. */
  6878. radiusWorld: number;
  6879. /**
  6880. * Gets the minimum vector in local space
  6881. */
  6882. readonly minimum: Vector3;
  6883. /**
  6884. * Gets the maximum vector in local space
  6885. */
  6886. readonly maximum: Vector3;
  6887. private _worldMatrix;
  6888. private static readonly TmpVector3;
  6889. /**
  6890. * Creates a new bounding sphere
  6891. * @param min defines the minimum vector (in local space)
  6892. * @param max defines the maximum vector (in local space)
  6893. * @param worldMatrix defines the new world matrix
  6894. */
  6895. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6896. /**
  6897. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6898. * @param min defines the new minimum vector (in local space)
  6899. * @param max defines the new maximum vector (in local space)
  6900. * @param worldMatrix defines the new world matrix
  6901. */
  6902. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6903. /**
  6904. * Scale the current bounding sphere by applying a scale factor
  6905. * @param factor defines the scale factor to apply
  6906. * @returns the current bounding box
  6907. */
  6908. scale(factor: number): BoundingSphere;
  6909. /**
  6910. * Gets the world matrix of the bounding box
  6911. * @returns a matrix
  6912. */
  6913. getWorldMatrix(): DeepImmutable<Matrix>;
  6914. /** @hidden */
  6915. _update(worldMatrix: DeepImmutable<Matrix>): void;
  6916. /**
  6917. * Tests if the bounding sphere is intersecting the frustum planes
  6918. * @param frustumPlanes defines the frustum planes to test
  6919. * @returns true if there is an intersection
  6920. */
  6921. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6922. /**
  6923. * Tests if the bounding sphere center is in between the frustum planes.
  6924. * Used for optimistic fast inclusion.
  6925. * @param frustumPlanes defines the frustum planes to test
  6926. * @returns true if the sphere center is in between the frustum planes
  6927. */
  6928. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  6929. /**
  6930. * Tests if a point is inside the bounding sphere
  6931. * @param point defines the point to test
  6932. * @returns true if the point is inside the bounding sphere
  6933. */
  6934. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  6935. /**
  6936. * Checks if two sphere intersct
  6937. * @param sphere0 sphere 0
  6938. * @param sphere1 sphere 1
  6939. * @returns true if the speres intersect
  6940. */
  6941. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  6942. }
  6943. }
  6944. declare module "babylonjs/Culling/boundingBox" {
  6945. import { DeepImmutable } from "babylonjs/types";
  6946. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  6947. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  6948. import { ICullable } from "babylonjs/Culling/boundingInfo";
  6949. /**
  6950. * Class used to store bounding box information
  6951. */
  6952. export class BoundingBox implements ICullable {
  6953. /**
  6954. * Gets the 8 vectors representing the bounding box in local space
  6955. */
  6956. readonly vectors: Vector3[];
  6957. /**
  6958. * Gets the center of the bounding box in local space
  6959. */
  6960. readonly center: Vector3;
  6961. /**
  6962. * Gets the center of the bounding box in world space
  6963. */
  6964. readonly centerWorld: Vector3;
  6965. /**
  6966. * Gets the extend size in local space
  6967. */
  6968. readonly extendSize: Vector3;
  6969. /**
  6970. * Gets the extend size in world space
  6971. */
  6972. readonly extendSizeWorld: Vector3;
  6973. /**
  6974. * Gets the OBB (object bounding box) directions
  6975. */
  6976. readonly directions: Vector3[];
  6977. /**
  6978. * Gets the 8 vectors representing the bounding box in world space
  6979. */
  6980. readonly vectorsWorld: Vector3[];
  6981. /**
  6982. * Gets the minimum vector in world space
  6983. */
  6984. readonly minimumWorld: Vector3;
  6985. /**
  6986. * Gets the maximum vector in world space
  6987. */
  6988. readonly maximumWorld: Vector3;
  6989. /**
  6990. * Gets the minimum vector in local space
  6991. */
  6992. readonly minimum: Vector3;
  6993. /**
  6994. * Gets the maximum vector in local space
  6995. */
  6996. readonly maximum: Vector3;
  6997. private _worldMatrix;
  6998. private static readonly TmpVector3;
  6999. /**
  7000. * @hidden
  7001. */
  7002. _tag: number;
  7003. /**
  7004. * Creates a new bounding box
  7005. * @param min defines the minimum vector (in local space)
  7006. * @param max defines the maximum vector (in local space)
  7007. * @param worldMatrix defines the new world matrix
  7008. */
  7009. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7010. /**
  7011. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7012. * @param min defines the new minimum vector (in local space)
  7013. * @param max defines the new maximum vector (in local space)
  7014. * @param worldMatrix defines the new world matrix
  7015. */
  7016. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7017. /**
  7018. * Scale the current bounding box by applying a scale factor
  7019. * @param factor defines the scale factor to apply
  7020. * @returns the current bounding box
  7021. */
  7022. scale(factor: number): BoundingBox;
  7023. /**
  7024. * Gets the world matrix of the bounding box
  7025. * @returns a matrix
  7026. */
  7027. getWorldMatrix(): DeepImmutable<Matrix>;
  7028. /** @hidden */
  7029. _update(world: DeepImmutable<Matrix>): void;
  7030. /**
  7031. * Tests if the bounding box is intersecting the frustum planes
  7032. * @param frustumPlanes defines the frustum planes to test
  7033. * @returns true if there is an intersection
  7034. */
  7035. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7036. /**
  7037. * Tests if the bounding box is entirely inside the frustum planes
  7038. * @param frustumPlanes defines the frustum planes to test
  7039. * @returns true if there is an inclusion
  7040. */
  7041. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7042. /**
  7043. * Tests if a point is inside the bounding box
  7044. * @param point defines the point to test
  7045. * @returns true if the point is inside the bounding box
  7046. */
  7047. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7048. /**
  7049. * Tests if the bounding box intersects with a bounding sphere
  7050. * @param sphere defines the sphere to test
  7051. * @returns true if there is an intersection
  7052. */
  7053. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7054. /**
  7055. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7056. * @param min defines the min vector to use
  7057. * @param max defines the max vector to use
  7058. * @returns true if there is an intersection
  7059. */
  7060. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7061. /**
  7062. * Tests if two bounding boxes are intersections
  7063. * @param box0 defines the first box to test
  7064. * @param box1 defines the second box to test
  7065. * @returns true if there is an intersection
  7066. */
  7067. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7068. /**
  7069. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7070. * @param minPoint defines the minimum vector of the bounding box
  7071. * @param maxPoint defines the maximum vector of the bounding box
  7072. * @param sphereCenter defines the sphere center
  7073. * @param sphereRadius defines the sphere radius
  7074. * @returns true if there is an intersection
  7075. */
  7076. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7077. /**
  7078. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7079. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7080. * @param frustumPlanes defines the frustum planes to test
  7081. * @return true if there is an inclusion
  7082. */
  7083. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7084. /**
  7085. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7086. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7087. * @param frustumPlanes defines the frustum planes to test
  7088. * @return true if there is an intersection
  7089. */
  7090. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7091. }
  7092. }
  7093. declare module "babylonjs/Collisions/collider" {
  7094. import { Nullable, IndicesArray } from "babylonjs/types";
  7095. import { Vector3, Plane } from "babylonjs/Maths/math";
  7096. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7097. /** @hidden */
  7098. export class Collider {
  7099. /** Define if a collision was found */
  7100. collisionFound: boolean;
  7101. /**
  7102. * Define last intersection point in local space
  7103. */
  7104. intersectionPoint: Vector3;
  7105. /**
  7106. * Define last collided mesh
  7107. */
  7108. collidedMesh: Nullable<AbstractMesh>;
  7109. private _collisionPoint;
  7110. private _planeIntersectionPoint;
  7111. private _tempVector;
  7112. private _tempVector2;
  7113. private _tempVector3;
  7114. private _tempVector4;
  7115. private _edge;
  7116. private _baseToVertex;
  7117. private _destinationPoint;
  7118. private _slidePlaneNormal;
  7119. private _displacementVector;
  7120. /** @hidden */
  7121. _radius: Vector3;
  7122. /** @hidden */
  7123. _retry: number;
  7124. private _velocity;
  7125. private _basePoint;
  7126. private _epsilon;
  7127. /** @hidden */
  7128. _velocityWorldLength: number;
  7129. /** @hidden */
  7130. _basePointWorld: Vector3;
  7131. private _velocityWorld;
  7132. private _normalizedVelocity;
  7133. /** @hidden */
  7134. _initialVelocity: Vector3;
  7135. /** @hidden */
  7136. _initialPosition: Vector3;
  7137. private _nearestDistance;
  7138. private _collisionMask;
  7139. collisionMask: number;
  7140. /**
  7141. * Gets the plane normal used to compute the sliding response (in local space)
  7142. */
  7143. readonly slidePlaneNormal: Vector3;
  7144. /** @hidden */
  7145. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7146. /** @hidden */
  7147. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7148. /** @hidden */
  7149. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7150. /** @hidden */
  7151. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  7152. /** @hidden */
  7153. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  7154. /** @hidden */
  7155. _getResponse(pos: Vector3, vel: Vector3): void;
  7156. }
  7157. }
  7158. declare module "babylonjs/Culling/boundingInfo" {
  7159. import { DeepImmutable } from "babylonjs/types";
  7160. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  7161. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7162. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7163. import { Collider } from "babylonjs/Collisions/collider";
  7164. /**
  7165. * Interface for cullable objects
  7166. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7167. */
  7168. export interface ICullable {
  7169. /**
  7170. * Checks if the object or part of the object is in the frustum
  7171. * @param frustumPlanes Camera near/planes
  7172. * @returns true if the object is in frustum otherwise false
  7173. */
  7174. isInFrustum(frustumPlanes: Plane[]): boolean;
  7175. /**
  7176. * Checks if a cullable object (mesh...) is in the camera frustum
  7177. * Unlike isInFrustum this cheks the full bounding box
  7178. * @param frustumPlanes Camera near/planes
  7179. * @returns true if the object is in frustum otherwise false
  7180. */
  7181. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7182. }
  7183. /**
  7184. * Info for a bounding data of a mesh
  7185. */
  7186. export class BoundingInfo implements ICullable {
  7187. /**
  7188. * Bounding box for the mesh
  7189. */
  7190. readonly boundingBox: BoundingBox;
  7191. /**
  7192. * Bounding sphere for the mesh
  7193. */
  7194. readonly boundingSphere: BoundingSphere;
  7195. private _isLocked;
  7196. private static readonly TmpVector3;
  7197. /**
  7198. * Constructs bounding info
  7199. * @param minimum min vector of the bounding box/sphere
  7200. * @param maximum max vector of the bounding box/sphere
  7201. * @param worldMatrix defines the new world matrix
  7202. */
  7203. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7204. /**
  7205. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7206. * @param min defines the new minimum vector (in local space)
  7207. * @param max defines the new maximum vector (in local space)
  7208. * @param worldMatrix defines the new world matrix
  7209. */
  7210. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7211. /**
  7212. * min vector of the bounding box/sphere
  7213. */
  7214. readonly minimum: Vector3;
  7215. /**
  7216. * max vector of the bounding box/sphere
  7217. */
  7218. readonly maximum: Vector3;
  7219. /**
  7220. * If the info is locked and won't be updated to avoid perf overhead
  7221. */
  7222. isLocked: boolean;
  7223. /**
  7224. * Updates the bounding sphere and box
  7225. * @param world world matrix to be used to update
  7226. */
  7227. update(world: DeepImmutable<Matrix>): void;
  7228. /**
  7229. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7230. * @param center New center of the bounding info
  7231. * @param extend New extend of the bounding info
  7232. * @returns the current bounding info
  7233. */
  7234. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7235. /**
  7236. * Scale the current bounding info by applying a scale factor
  7237. * @param factor defines the scale factor to apply
  7238. * @returns the current bounding info
  7239. */
  7240. scale(factor: number): BoundingInfo;
  7241. /**
  7242. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7243. * @param frustumPlanes defines the frustum to test
  7244. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7245. * @returns true if the bounding info is in the frustum planes
  7246. */
  7247. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7248. /**
  7249. * Gets the world distance between the min and max points of the bounding box
  7250. */
  7251. readonly diagonalLength: number;
  7252. /**
  7253. * Checks if a cullable object (mesh...) is in the camera frustum
  7254. * Unlike isInFrustum this cheks the full bounding box
  7255. * @param frustumPlanes Camera near/planes
  7256. * @returns true if the object is in frustum otherwise false
  7257. */
  7258. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7259. /** @hidden */
  7260. _checkCollision(collider: Collider): boolean;
  7261. /**
  7262. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7263. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7264. * @param point the point to check intersection with
  7265. * @returns if the point intersects
  7266. */
  7267. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7268. /**
  7269. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7270. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7271. * @param boundingInfo the bounding info to check intersection with
  7272. * @param precise if the intersection should be done using OBB
  7273. * @returns if the bounding info intersects
  7274. */
  7275. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7276. }
  7277. }
  7278. declare module "babylonjs/Misc/smartArray" {
  7279. /**
  7280. * Defines an array and its length.
  7281. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  7282. */
  7283. export interface ISmartArrayLike<T> {
  7284. /**
  7285. * The data of the array.
  7286. */
  7287. data: Array<T>;
  7288. /**
  7289. * The active length of the array.
  7290. */
  7291. length: number;
  7292. }
  7293. /**
  7294. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7295. */
  7296. export class SmartArray<T> implements ISmartArrayLike<T> {
  7297. /**
  7298. * The full set of data from the array.
  7299. */
  7300. data: Array<T>;
  7301. /**
  7302. * The active length of the array.
  7303. */
  7304. length: number;
  7305. protected _id: number;
  7306. /**
  7307. * Instantiates a Smart Array.
  7308. * @param capacity defines the default capacity of the array.
  7309. */
  7310. constructor(capacity: number);
  7311. /**
  7312. * Pushes a value at the end of the active data.
  7313. * @param value defines the object to push in the array.
  7314. */
  7315. push(value: T): void;
  7316. /**
  7317. * Iterates over the active data and apply the lambda to them.
  7318. * @param func defines the action to apply on each value.
  7319. */
  7320. forEach(func: (content: T) => void): void;
  7321. /**
  7322. * Sorts the full sets of data.
  7323. * @param compareFn defines the comparison function to apply.
  7324. */
  7325. sort(compareFn: (a: T, b: T) => number): void;
  7326. /**
  7327. * Resets the active data to an empty array.
  7328. */
  7329. reset(): void;
  7330. /**
  7331. * Releases all the data from the array as well as the array.
  7332. */
  7333. dispose(): void;
  7334. /**
  7335. * Concats the active data with a given array.
  7336. * @param array defines the data to concatenate with.
  7337. */
  7338. concat(array: any): void;
  7339. /**
  7340. * Returns the position of a value in the active data.
  7341. * @param value defines the value to find the index for
  7342. * @returns the index if found in the active data otherwise -1
  7343. */
  7344. indexOf(value: T): number;
  7345. /**
  7346. * Returns whether an element is part of the active data.
  7347. * @param value defines the value to look for
  7348. * @returns true if found in the active data otherwise false
  7349. */
  7350. contains(value: T): boolean;
  7351. private static _GlobalId;
  7352. }
  7353. /**
  7354. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  7355. * The data in this array can only be present once
  7356. */
  7357. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  7358. private _duplicateId;
  7359. /**
  7360. * Pushes a value at the end of the active data.
  7361. * THIS DOES NOT PREVENT DUPPLICATE DATA
  7362. * @param value defines the object to push in the array.
  7363. */
  7364. push(value: T): void;
  7365. /**
  7366. * Pushes a value at the end of the active data.
  7367. * If the data is already present, it won t be added again
  7368. * @param value defines the object to push in the array.
  7369. * @returns true if added false if it was already present
  7370. */
  7371. pushNoDuplicate(value: T): boolean;
  7372. /**
  7373. * Resets the active data to an empty array.
  7374. */
  7375. reset(): void;
  7376. /**
  7377. * Concats the active data with a given array.
  7378. * This ensures no dupplicate will be present in the result.
  7379. * @param array defines the data to concatenate with.
  7380. */
  7381. concatWithNoDuplicate(array: any): void;
  7382. }
  7383. }
  7384. declare module "babylonjs/Materials/multiMaterial" {
  7385. import { Nullable } from "babylonjs/types";
  7386. import { Scene } from "babylonjs/scene";
  7387. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7388. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  7389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7390. import { Material } from "babylonjs/Materials/material";
  7391. /**
  7392. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7393. * separate meshes. This can be use to improve performances.
  7394. * @see http://doc.babylonjs.com/how_to/multi_materials
  7395. */
  7396. export class MultiMaterial extends Material {
  7397. private _subMaterials;
  7398. /**
  7399. * Gets or Sets the list of Materials used within the multi material.
  7400. * They need to be ordered according to the submeshes order in the associated mesh
  7401. */
  7402. subMaterials: Nullable<Material>[];
  7403. /**
  7404. * Function used to align with Node.getChildren()
  7405. * @returns the list of Materials used within the multi material
  7406. */
  7407. getChildren(): Nullable<Material>[];
  7408. /**
  7409. * Instantiates a new Multi Material
  7410. * A multi-material is used to apply different materials to different parts of the same object without the need of
  7411. * separate meshes. This can be use to improve performances.
  7412. * @see http://doc.babylonjs.com/how_to/multi_materials
  7413. * @param name Define the name in the scene
  7414. * @param scene Define the scene the material belongs to
  7415. */
  7416. constructor(name: string, scene: Scene);
  7417. private _hookArray;
  7418. /**
  7419. * Get one of the submaterial by its index in the submaterials array
  7420. * @param index The index to look the sub material at
  7421. * @returns The Material if the index has been defined
  7422. */
  7423. getSubMaterial(index: number): Nullable<Material>;
  7424. /**
  7425. * Get the list of active textures for the whole sub materials list.
  7426. * @returns All the textures that will be used during the rendering
  7427. */
  7428. getActiveTextures(): BaseTexture[];
  7429. /**
  7430. * Gets the current class name of the material e.g. "MultiMaterial"
  7431. * Mainly use in serialization.
  7432. * @returns the class name
  7433. */
  7434. getClassName(): string;
  7435. /**
  7436. * Checks if the material is ready to render the requested sub mesh
  7437. * @param mesh Define the mesh the submesh belongs to
  7438. * @param subMesh Define the sub mesh to look readyness for
  7439. * @param useInstances Define whether or not the material is used with instances
  7440. * @returns true if ready, otherwise false
  7441. */
  7442. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  7443. /**
  7444. * Clones the current material and its related sub materials
  7445. * @param name Define the name of the newly cloned material
  7446. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  7447. * @returns the cloned material
  7448. */
  7449. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  7450. /**
  7451. * Serializes the materials into a JSON representation.
  7452. * @returns the JSON representation
  7453. */
  7454. serialize(): any;
  7455. /**
  7456. * Dispose the material and release its associated resources
  7457. * @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)
  7458. * @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)
  7459. * @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)
  7460. */
  7461. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  7462. /**
  7463. * Creates a MultiMaterial from parsed MultiMaterial data.
  7464. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  7465. * @param scene defines the hosting scene
  7466. * @returns a new MultiMaterial
  7467. */
  7468. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  7469. }
  7470. }
  7471. declare module "babylonjs/Loading/sceneLoaderFlags" {
  7472. /**
  7473. * Class used to represent data loading progression
  7474. */
  7475. export class SceneLoaderFlags {
  7476. private static _ForceFullSceneLoadingForIncremental;
  7477. private static _ShowLoadingScreen;
  7478. private static _CleanBoneMatrixWeights;
  7479. private static _loggingLevel;
  7480. /**
  7481. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  7482. */
  7483. static ForceFullSceneLoadingForIncremental: boolean;
  7484. /**
  7485. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  7486. */
  7487. static ShowLoadingScreen: boolean;
  7488. /**
  7489. * Defines the current logging level (while loading the scene)
  7490. * @ignorenaming
  7491. */
  7492. static loggingLevel: number;
  7493. /**
  7494. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  7495. */
  7496. static CleanBoneMatrixWeights: boolean;
  7497. }
  7498. }
  7499. declare module "babylonjs/Meshes/transformNode" {
  7500. import { DeepImmutable } from "babylonjs/types";
  7501. import { Observable } from "babylonjs/Misc/observable";
  7502. import { Nullable } from "babylonjs/types";
  7503. import { Camera } from "babylonjs/Cameras/camera";
  7504. import { Scene } from "babylonjs/scene";
  7505. import { Quaternion, Matrix, Vector3, Space } from "babylonjs/Maths/math";
  7506. import { Node } from "babylonjs/node";
  7507. import { Bone } from "babylonjs/Bones/bone";
  7508. /**
  7509. * 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.
  7510. * @see https://doc.babylonjs.com/how_to/transformnode
  7511. */
  7512. export class TransformNode extends Node {
  7513. /**
  7514. * Object will not rotate to face the camera
  7515. */
  7516. static BILLBOARDMODE_NONE: number;
  7517. /**
  7518. * Object will rotate to face the camera but only on the x axis
  7519. */
  7520. static BILLBOARDMODE_X: number;
  7521. /**
  7522. * Object will rotate to face the camera but only on the y axis
  7523. */
  7524. static BILLBOARDMODE_Y: number;
  7525. /**
  7526. * Object will rotate to face the camera but only on the z axis
  7527. */
  7528. static BILLBOARDMODE_Z: number;
  7529. /**
  7530. * Object will rotate to face the camera
  7531. */
  7532. static BILLBOARDMODE_ALL: number;
  7533. private _forward;
  7534. private _forwardInverted;
  7535. private _up;
  7536. private _right;
  7537. private _rightInverted;
  7538. private _position;
  7539. private _rotation;
  7540. private _rotationQuaternion;
  7541. protected _scaling: Vector3;
  7542. protected _isDirty: boolean;
  7543. private _transformToBoneReferal;
  7544. private _billboardMode;
  7545. /**
  7546. * Gets or sets the billboard mode. Default is 0.
  7547. *
  7548. * | Value | Type | Description |
  7549. * | --- | --- | --- |
  7550. * | 0 | BILLBOARDMODE_NONE | |
  7551. * | 1 | BILLBOARDMODE_X | |
  7552. * | 2 | BILLBOARDMODE_Y | |
  7553. * | 4 | BILLBOARDMODE_Z | |
  7554. * | 7 | BILLBOARDMODE_ALL | |
  7555. *
  7556. */
  7557. billboardMode: number;
  7558. private _preserveParentRotationForBillboard;
  7559. /**
  7560. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  7561. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  7562. */
  7563. preserveParentRotationForBillboard: boolean;
  7564. /**
  7565. * 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
  7566. */
  7567. scalingDeterminant: number;
  7568. private _infiniteDistance;
  7569. /**
  7570. * Gets or sets the distance of the object to max, often used by skybox
  7571. */
  7572. infiniteDistance: boolean;
  7573. /**
  7574. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  7575. * By default the system will update normals to compensate
  7576. */
  7577. ignoreNonUniformScaling: boolean;
  7578. /**
  7579. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  7580. */
  7581. reIntegrateRotationIntoRotationQuaternion: boolean;
  7582. /** @hidden */
  7583. _poseMatrix: Nullable<Matrix>;
  7584. /** @hidden */
  7585. _localMatrix: Matrix;
  7586. private _usePivotMatrix;
  7587. private _absolutePosition;
  7588. private _pivotMatrix;
  7589. private _pivotMatrixInverse;
  7590. protected _postMultiplyPivotMatrix: boolean;
  7591. protected _isWorldMatrixFrozen: boolean;
  7592. /** @hidden */
  7593. _indexInSceneTransformNodesArray: number;
  7594. /**
  7595. * An event triggered after the world matrix is updated
  7596. */
  7597. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  7598. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  7599. /**
  7600. * Gets a string identifying the name of the class
  7601. * @returns "TransformNode" string
  7602. */
  7603. getClassName(): string;
  7604. /**
  7605. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  7606. */
  7607. position: Vector3;
  7608. /**
  7609. * 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)).
  7610. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  7611. */
  7612. rotation: Vector3;
  7613. /**
  7614. * 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)).
  7615. */
  7616. scaling: Vector3;
  7617. /**
  7618. * 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).
  7619. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  7620. */
  7621. rotationQuaternion: Nullable<Quaternion>;
  7622. /**
  7623. * The forward direction of that transform in world space.
  7624. */
  7625. readonly forward: Vector3;
  7626. /**
  7627. * The up direction of that transform in world space.
  7628. */
  7629. readonly up: Vector3;
  7630. /**
  7631. * The right direction of that transform in world space.
  7632. */
  7633. readonly right: Vector3;
  7634. /**
  7635. * Copies the parameter passed Matrix into the mesh Pose matrix.
  7636. * @param matrix the matrix to copy the pose from
  7637. * @returns this TransformNode.
  7638. */
  7639. updatePoseMatrix(matrix: Matrix): TransformNode;
  7640. /**
  7641. * Returns the mesh Pose matrix.
  7642. * @returns the pose matrix
  7643. */
  7644. getPoseMatrix(): Matrix;
  7645. /** @hidden */
  7646. _isSynchronized(): boolean;
  7647. /** @hidden */
  7648. _initCache(): void;
  7649. /**
  7650. * Flag the transform node as dirty (Forcing it to update everything)
  7651. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  7652. * @returns this transform node
  7653. */
  7654. markAsDirty(property: string): TransformNode;
  7655. /**
  7656. * Returns the current mesh absolute position.
  7657. * Returns a Vector3.
  7658. */
  7659. readonly absolutePosition: Vector3;
  7660. /**
  7661. * Sets a new matrix to apply before all other transformation
  7662. * @param matrix defines the transform matrix
  7663. * @returns the current TransformNode
  7664. */
  7665. setPreTransformMatrix(matrix: Matrix): TransformNode;
  7666. /**
  7667. * Sets a new pivot matrix to the current node
  7668. * @param matrix defines the new pivot matrix to use
  7669. * @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
  7670. * @returns the current TransformNode
  7671. */
  7672. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  7673. /**
  7674. * Returns the mesh pivot matrix.
  7675. * Default : Identity.
  7676. * @returns the matrix
  7677. */
  7678. getPivotMatrix(): Matrix;
  7679. /**
  7680. * Prevents the World matrix to be computed any longer.
  7681. * @returns the TransformNode.
  7682. */
  7683. freezeWorldMatrix(): TransformNode;
  7684. /**
  7685. * Allows back the World matrix computation.
  7686. * @returns the TransformNode.
  7687. */
  7688. unfreezeWorldMatrix(): this;
  7689. /**
  7690. * True if the World matrix has been frozen.
  7691. */
  7692. readonly isWorldMatrixFrozen: boolean;
  7693. /**
  7694. * Retuns the mesh absolute position in the World.
  7695. * @returns a Vector3.
  7696. */
  7697. getAbsolutePosition(): Vector3;
  7698. /**
  7699. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  7700. * @param absolutePosition the absolute position to set
  7701. * @returns the TransformNode.
  7702. */
  7703. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  7704. /**
  7705. * Sets the mesh position in its local space.
  7706. * @param vector3 the position to set in localspace
  7707. * @returns the TransformNode.
  7708. */
  7709. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  7710. /**
  7711. * Returns the mesh position in the local space from the current World matrix values.
  7712. * @returns a new Vector3.
  7713. */
  7714. getPositionExpressedInLocalSpace(): Vector3;
  7715. /**
  7716. * Translates the mesh along the passed Vector3 in its local space.
  7717. * @param vector3 the distance to translate in localspace
  7718. * @returns the TransformNode.
  7719. */
  7720. locallyTranslate(vector3: Vector3): TransformNode;
  7721. private static _lookAtVectorCache;
  7722. /**
  7723. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  7724. * @param targetPoint the position (must be in same space as current mesh) to look at
  7725. * @param yawCor optional yaw (y-axis) correction in radians
  7726. * @param pitchCor optional pitch (x-axis) correction in radians
  7727. * @param rollCor optional roll (z-axis) correction in radians
  7728. * @param space the choosen space of the target
  7729. * @returns the TransformNode.
  7730. */
  7731. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  7732. /**
  7733. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7734. * This Vector3 is expressed in the World space.
  7735. * @param localAxis axis to rotate
  7736. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  7737. */
  7738. getDirection(localAxis: Vector3): Vector3;
  7739. /**
  7740. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  7741. * localAxis is expressed in the mesh local space.
  7742. * result is computed in the Wordl space from the mesh World matrix.
  7743. * @param localAxis axis to rotate
  7744. * @param result the resulting transformnode
  7745. * @returns this TransformNode.
  7746. */
  7747. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  7748. /**
  7749. * Sets this transform node rotation to the given local axis.
  7750. * @param localAxis the axis in local space
  7751. * @param yawCor optional yaw (y-axis) correction in radians
  7752. * @param pitchCor optional pitch (x-axis) correction in radians
  7753. * @param rollCor optional roll (z-axis) correction in radians
  7754. * @returns this TransformNode
  7755. */
  7756. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  7757. /**
  7758. * Sets a new pivot point to the current node
  7759. * @param point defines the new pivot point to use
  7760. * @param space defines if the point is in world or local space (local by default)
  7761. * @returns the current TransformNode
  7762. */
  7763. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  7764. /**
  7765. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  7766. * @returns the pivot point
  7767. */
  7768. getPivotPoint(): Vector3;
  7769. /**
  7770. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  7771. * @param result the vector3 to store the result
  7772. * @returns this TransformNode.
  7773. */
  7774. getPivotPointToRef(result: Vector3): TransformNode;
  7775. /**
  7776. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  7777. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  7778. */
  7779. getAbsolutePivotPoint(): Vector3;
  7780. /**
  7781. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  7782. * @param result vector3 to store the result
  7783. * @returns this TransformNode.
  7784. */
  7785. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  7786. /**
  7787. * Defines the passed node as the parent of the current node.
  7788. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  7789. * @see https://doc.babylonjs.com/how_to/parenting
  7790. * @param node the node ot set as the parent
  7791. * @returns this TransformNode.
  7792. */
  7793. setParent(node: Nullable<Node>): TransformNode;
  7794. private _nonUniformScaling;
  7795. /**
  7796. * True if the scaling property of this object is non uniform eg. (1,2,1)
  7797. */
  7798. readonly nonUniformScaling: boolean;
  7799. /** @hidden */
  7800. _updateNonUniformScalingState(value: boolean): boolean;
  7801. /**
  7802. * Attach the current TransformNode to another TransformNode associated with a bone
  7803. * @param bone Bone affecting the TransformNode
  7804. * @param affectedTransformNode TransformNode associated with the bone
  7805. * @returns this object
  7806. */
  7807. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  7808. /**
  7809. * Detach the transform node if its associated with a bone
  7810. * @returns this object
  7811. */
  7812. detachFromBone(): TransformNode;
  7813. private static _rotationAxisCache;
  7814. /**
  7815. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  7816. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7817. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7818. * The passed axis is also normalized.
  7819. * @param axis the axis to rotate around
  7820. * @param amount the amount to rotate in radians
  7821. * @param space Space to rotate in (Default: local)
  7822. * @returns the TransformNode.
  7823. */
  7824. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  7825. /**
  7826. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  7827. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  7828. * The passed axis is also normalized. .
  7829. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  7830. * @param point the point to rotate around
  7831. * @param axis the axis to rotate around
  7832. * @param amount the amount to rotate in radians
  7833. * @returns the TransformNode
  7834. */
  7835. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  7836. /**
  7837. * Translates the mesh along the axis vector for the passed distance in the given space.
  7838. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  7839. * @param axis the axis to translate in
  7840. * @param distance the distance to translate
  7841. * @param space Space to rotate in (Default: local)
  7842. * @returns the TransformNode.
  7843. */
  7844. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  7845. /**
  7846. * Adds a rotation step to the mesh current rotation.
  7847. * x, y, z are Euler angles expressed in radians.
  7848. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  7849. * This means this rotation is made in the mesh local space only.
  7850. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  7851. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  7852. * ```javascript
  7853. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  7854. * ```
  7855. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  7856. * 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.
  7857. * @param x Rotation to add
  7858. * @param y Rotation to add
  7859. * @param z Rotation to add
  7860. * @returns the TransformNode.
  7861. */
  7862. addRotation(x: number, y: number, z: number): TransformNode;
  7863. /**
  7864. * @hidden
  7865. */
  7866. protected _getEffectiveParent(): Nullable<Node>;
  7867. /**
  7868. * Computes the world matrix of the node
  7869. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  7870. * @returns the world matrix
  7871. */
  7872. computeWorldMatrix(force?: boolean): Matrix;
  7873. protected _afterComputeWorldMatrix(): void;
  7874. /**
  7875. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  7876. * @param func callback function to add
  7877. *
  7878. * @returns the TransformNode.
  7879. */
  7880. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7881. /**
  7882. * Removes a registered callback function.
  7883. * @param func callback function to remove
  7884. * @returns the TransformNode.
  7885. */
  7886. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  7887. /**
  7888. * Gets the position of the current mesh in camera space
  7889. * @param camera defines the camera to use
  7890. * @returns a position
  7891. */
  7892. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  7893. /**
  7894. * Returns the distance from the mesh to the active camera
  7895. * @param camera defines the camera to use
  7896. * @returns the distance
  7897. */
  7898. getDistanceToCamera(camera?: Nullable<Camera>): number;
  7899. /**
  7900. * Clone the current transform node
  7901. * @param name Name of the new clone
  7902. * @param newParent New parent for the clone
  7903. * @param doNotCloneChildren Do not clone children hierarchy
  7904. * @returns the new transform node
  7905. */
  7906. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  7907. /**
  7908. * Serializes the objects information.
  7909. * @param currentSerializationObject defines the object to serialize in
  7910. * @returns the serialized object
  7911. */
  7912. serialize(currentSerializationObject?: any): any;
  7913. /**
  7914. * Returns a new TransformNode object parsed from the source provided.
  7915. * @param parsedTransformNode is the source.
  7916. * @param scene the scne the object belongs to
  7917. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  7918. * @returns a new TransformNode object parsed from the source provided.
  7919. */
  7920. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  7921. /**
  7922. * Get all child-transformNodes of this node
  7923. * @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
  7924. * @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
  7925. * @returns an array of TransformNode
  7926. */
  7927. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  7928. /**
  7929. * Releases resources associated with this transform node.
  7930. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  7931. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  7932. */
  7933. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  7934. }
  7935. }
  7936. declare module "babylonjs/Animations/animationPropertiesOverride" {
  7937. /**
  7938. * Class used to override all child animations of a given target
  7939. */
  7940. export class AnimationPropertiesOverride {
  7941. /**
  7942. * Gets or sets a value indicating if animation blending must be used
  7943. */
  7944. enableBlending: boolean;
  7945. /**
  7946. * Gets or sets the blending speed to use when enableBlending is true
  7947. */
  7948. blendingSpeed: number;
  7949. /**
  7950. * Gets or sets the default loop mode to use
  7951. */
  7952. loopMode: number;
  7953. }
  7954. }
  7955. declare module "babylonjs/Bones/bone" {
  7956. import { Skeleton } from "babylonjs/Bones/skeleton";
  7957. import { Vector3, Quaternion, Matrix, Space } from "babylonjs/Maths/math";
  7958. import { Nullable } from "babylonjs/types";
  7959. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7960. import { TransformNode } from "babylonjs/Meshes/transformNode";
  7961. import { Node } from "babylonjs/node";
  7962. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  7963. /**
  7964. * Class used to store bone information
  7965. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  7966. */
  7967. export class Bone extends Node {
  7968. /**
  7969. * defines the bone name
  7970. */
  7971. name: string;
  7972. private static _tmpVecs;
  7973. private static _tmpQuat;
  7974. private static _tmpMats;
  7975. /**
  7976. * Gets the list of child bones
  7977. */
  7978. children: Bone[];
  7979. /** Gets the animations associated with this bone */
  7980. animations: import("babylonjs/Animations/animation").Animation[];
  7981. /**
  7982. * Gets or sets bone length
  7983. */
  7984. length: number;
  7985. /**
  7986. * @hidden Internal only
  7987. * Set this value to map this bone to a different index in the transform matrices
  7988. * Set this value to -1 to exclude the bone from the transform matrices
  7989. */
  7990. _index: Nullable<number>;
  7991. private _skeleton;
  7992. private _localMatrix;
  7993. private _restPose;
  7994. private _baseMatrix;
  7995. private _absoluteTransform;
  7996. private _invertedAbsoluteTransform;
  7997. private _parent;
  7998. private _scalingDeterminant;
  7999. private _worldTransform;
  8000. private _localScaling;
  8001. private _localRotation;
  8002. private _localPosition;
  8003. private _needToDecompose;
  8004. private _needToCompose;
  8005. /** @hidden */
  8006. _linkedTransformNode: Nullable<TransformNode>;
  8007. /** @hidden */
  8008. /** @hidden */
  8009. _matrix: Matrix;
  8010. /**
  8011. * Create a new bone
  8012. * @param name defines the bone name
  8013. * @param skeleton defines the parent skeleton
  8014. * @param parentBone defines the parent (can be null if the bone is the root)
  8015. * @param localMatrix defines the local matrix
  8016. * @param restPose defines the rest pose matrix
  8017. * @param baseMatrix defines the base matrix
  8018. * @param index defines index of the bone in the hiearchy
  8019. */
  8020. constructor(
  8021. /**
  8022. * defines the bone name
  8023. */
  8024. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  8025. /**
  8026. * Gets the current object class name.
  8027. * @return the class name
  8028. */
  8029. getClassName(): string;
  8030. /**
  8031. * Gets the parent skeleton
  8032. * @returns a skeleton
  8033. */
  8034. getSkeleton(): Skeleton;
  8035. /**
  8036. * Gets parent bone
  8037. * @returns a bone or null if the bone is the root of the bone hierarchy
  8038. */
  8039. getParent(): Nullable<Bone>;
  8040. /**
  8041. * Returns an array containing the root bones
  8042. * @returns an array containing the root bones
  8043. */
  8044. getChildren(): Array<Bone>;
  8045. /**
  8046. * Sets the parent bone
  8047. * @param parent defines the parent (can be null if the bone is the root)
  8048. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8049. */
  8050. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  8051. /**
  8052. * Gets the local matrix
  8053. * @returns a matrix
  8054. */
  8055. getLocalMatrix(): Matrix;
  8056. /**
  8057. * Gets the base matrix (initial matrix which remains unchanged)
  8058. * @returns a matrix
  8059. */
  8060. getBaseMatrix(): Matrix;
  8061. /**
  8062. * Gets the rest pose matrix
  8063. * @returns a matrix
  8064. */
  8065. getRestPose(): Matrix;
  8066. /**
  8067. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  8068. */
  8069. getWorldMatrix(): Matrix;
  8070. /**
  8071. * Sets the local matrix to rest pose matrix
  8072. */
  8073. returnToRest(): void;
  8074. /**
  8075. * Gets the inverse of the absolute transform matrix.
  8076. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  8077. * @returns a matrix
  8078. */
  8079. getInvertedAbsoluteTransform(): Matrix;
  8080. /**
  8081. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  8082. * @returns a matrix
  8083. */
  8084. getAbsoluteTransform(): Matrix;
  8085. /**
  8086. * Links with the given transform node.
  8087. * The local matrix of this bone is copied from the transform node every frame.
  8088. * @param transformNode defines the transform node to link to
  8089. */
  8090. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  8091. /** Gets or sets current position (in local space) */
  8092. position: Vector3;
  8093. /** Gets or sets current rotation (in local space) */
  8094. rotation: Vector3;
  8095. /** Gets or sets current rotation quaternion (in local space) */
  8096. rotationQuaternion: Quaternion;
  8097. /** Gets or sets current scaling (in local space) */
  8098. scaling: Vector3;
  8099. /**
  8100. * Gets the animation properties override
  8101. */
  8102. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  8103. private _decompose;
  8104. private _compose;
  8105. /**
  8106. * Update the base and local matrices
  8107. * @param matrix defines the new base or local matrix
  8108. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  8109. * @param updateLocalMatrix defines if the local matrix should be updated
  8110. */
  8111. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  8112. /** @hidden */
  8113. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  8114. /**
  8115. * Flag the bone as dirty (Forcing it to update everything)
  8116. */
  8117. markAsDirty(): void;
  8118. private _markAsDirtyAndCompose;
  8119. private _markAsDirtyAndDecompose;
  8120. /**
  8121. * Translate the bone in local or world space
  8122. * @param vec The amount to translate the bone
  8123. * @param space The space that the translation is in
  8124. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8125. */
  8126. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8127. /**
  8128. * Set the postion of the bone in local or world space
  8129. * @param position The position to set the bone
  8130. * @param space The space that the position is in
  8131. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8132. */
  8133. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8134. /**
  8135. * Set the absolute position of the bone (world space)
  8136. * @param position The position to set the bone
  8137. * @param mesh The mesh that this bone is attached to
  8138. */
  8139. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  8140. /**
  8141. * Scale the bone on the x, y and z axes (in local space)
  8142. * @param x The amount to scale the bone on the x axis
  8143. * @param y The amount to scale the bone on the y axis
  8144. * @param z The amount to scale the bone on the z axis
  8145. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  8146. */
  8147. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  8148. /**
  8149. * Set the bone scaling in local space
  8150. * @param scale defines the scaling vector
  8151. */
  8152. setScale(scale: Vector3): void;
  8153. /**
  8154. * Gets the current scaling in local space
  8155. * @returns the current scaling vector
  8156. */
  8157. getScale(): Vector3;
  8158. /**
  8159. * Gets the current scaling in local space and stores it in a target vector
  8160. * @param result defines the target vector
  8161. */
  8162. getScaleToRef(result: Vector3): void;
  8163. /**
  8164. * Set the yaw, pitch, and roll of the bone in local or world space
  8165. * @param yaw The rotation of the bone on the y axis
  8166. * @param pitch The rotation of the bone on the x axis
  8167. * @param roll The rotation of the bone on the z axis
  8168. * @param space The space that the axes of rotation are in
  8169. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8170. */
  8171. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  8172. /**
  8173. * Add a rotation to the bone on an axis in local or world space
  8174. * @param axis The axis to rotate the bone on
  8175. * @param amount The amount to rotate the bone
  8176. * @param space The space that the axis is in
  8177. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8178. */
  8179. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  8180. /**
  8181. * Set the rotation of the bone to a particular axis angle in local or world space
  8182. * @param axis The axis to rotate the bone on
  8183. * @param angle The angle that the bone should be rotated to
  8184. * @param space The space that the axis is in
  8185. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8186. */
  8187. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  8188. /**
  8189. * Set the euler rotation of the bone in local of world space
  8190. * @param rotation The euler rotation that the bone should be set to
  8191. * @param space The space that the rotation is in
  8192. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8193. */
  8194. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  8195. /**
  8196. * Set the quaternion rotation of the bone in local of world space
  8197. * @param quat The quaternion rotation that the bone should be set to
  8198. * @param space The space that the rotation is in
  8199. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8200. */
  8201. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  8202. /**
  8203. * Set the rotation matrix of the bone in local of world space
  8204. * @param rotMat The rotation matrix that the bone should be set to
  8205. * @param space The space that the rotation is in
  8206. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8207. */
  8208. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  8209. private _rotateWithMatrix;
  8210. private _getNegativeRotationToRef;
  8211. /**
  8212. * Get the position of the bone in local or world space
  8213. * @param space The space that the returned position is in
  8214. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8215. * @returns The position of the bone
  8216. */
  8217. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8218. /**
  8219. * Copy the position of the bone to a vector3 in local or world space
  8220. * @param space The space that the returned position is in
  8221. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8222. * @param result The vector3 to copy the position to
  8223. */
  8224. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  8225. /**
  8226. * Get the absolute position of the bone (world space)
  8227. * @param mesh The mesh that this bone is attached to
  8228. * @returns The absolute position of the bone
  8229. */
  8230. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  8231. /**
  8232. * Copy the absolute position of the bone (world space) to the result param
  8233. * @param mesh The mesh that this bone is attached to
  8234. * @param result The vector3 to copy the absolute position to
  8235. */
  8236. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  8237. /**
  8238. * Compute the absolute transforms of this bone and its children
  8239. */
  8240. computeAbsoluteTransforms(): void;
  8241. /**
  8242. * Get the world direction from an axis that is in the local space of the bone
  8243. * @param localAxis The local direction that is used to compute the world direction
  8244. * @param mesh The mesh that this bone is attached to
  8245. * @returns The world direction
  8246. */
  8247. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8248. /**
  8249. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  8250. * @param localAxis The local direction that is used to compute the world direction
  8251. * @param mesh The mesh that this bone is attached to
  8252. * @param result The vector3 that the world direction will be copied to
  8253. */
  8254. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8255. /**
  8256. * Get the euler rotation of the bone in local or world space
  8257. * @param space The space that the rotation should be in
  8258. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8259. * @returns The euler rotation
  8260. */
  8261. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  8262. /**
  8263. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  8264. * @param space The space that the rotation should be in
  8265. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8266. * @param result The vector3 that the rotation should be copied to
  8267. */
  8268. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8269. /**
  8270. * Get the quaternion rotation of the bone in either local or world space
  8271. * @param space The space that the rotation should be in
  8272. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8273. * @returns The quaternion rotation
  8274. */
  8275. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  8276. /**
  8277. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  8278. * @param space The space that the rotation should be in
  8279. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8280. * @param result The quaternion that the rotation should be copied to
  8281. */
  8282. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  8283. /**
  8284. * Get the rotation matrix of the bone in local or world space
  8285. * @param space The space that the rotation should be in
  8286. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8287. * @returns The rotation matrix
  8288. */
  8289. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  8290. /**
  8291. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  8292. * @param space The space that the rotation should be in
  8293. * @param mesh The mesh that this bone is attached to. This is only used in world space
  8294. * @param result The quaternion that the rotation should be copied to
  8295. */
  8296. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  8297. /**
  8298. * Get the world position of a point that is in the local space of the bone
  8299. * @param position The local position
  8300. * @param mesh The mesh that this bone is attached to
  8301. * @returns The world position
  8302. */
  8303. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8304. /**
  8305. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  8306. * @param position The local position
  8307. * @param mesh The mesh that this bone is attached to
  8308. * @param result The vector3 that the world position should be copied to
  8309. */
  8310. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8311. /**
  8312. * Get the local position of a point that is in world space
  8313. * @param position The world position
  8314. * @param mesh The mesh that this bone is attached to
  8315. * @returns The local position
  8316. */
  8317. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  8318. /**
  8319. * Get the local position of a point that is in world space and copy it to the result param
  8320. * @param position The world position
  8321. * @param mesh The mesh that this bone is attached to
  8322. * @param result The vector3 that the local position should be copied to
  8323. */
  8324. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  8325. }
  8326. }
  8327. declare module "babylonjs/Misc/iInspectable" {
  8328. /**
  8329. * Enum that determines the text-wrapping mode to use.
  8330. */
  8331. export enum InspectableType {
  8332. /**
  8333. * Checkbox for booleans
  8334. */
  8335. Checkbox = 0,
  8336. /**
  8337. * Sliders for numbers
  8338. */
  8339. Slider = 1,
  8340. /**
  8341. * Vector3
  8342. */
  8343. Vector3 = 2,
  8344. /**
  8345. * Quaternions
  8346. */
  8347. Quaternion = 3,
  8348. /**
  8349. * Color3
  8350. */
  8351. Color3 = 4
  8352. }
  8353. /**
  8354. * Interface used to define custom inspectable properties.
  8355. * This interface is used by the inspector to display custom property grids
  8356. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  8357. */
  8358. export interface IInspectable {
  8359. /**
  8360. * Gets the label to display
  8361. */
  8362. label: string;
  8363. /**
  8364. * Gets the name of the property to edit
  8365. */
  8366. propertyName: string;
  8367. /**
  8368. * Gets the type of the editor to use
  8369. */
  8370. type: InspectableType;
  8371. /**
  8372. * Gets the minimum value of the property when using in "slider" mode
  8373. */
  8374. min?: number;
  8375. /**
  8376. * Gets the maximum value of the property when using in "slider" mode
  8377. */
  8378. max?: number;
  8379. /**
  8380. * Gets the setp to use when using in "slider" mode
  8381. */
  8382. step?: number;
  8383. }
  8384. }
  8385. declare module "babylonjs/Materials/Textures/cubeTexture" {
  8386. import { Nullable } from "babylonjs/types";
  8387. import { Scene } from "babylonjs/scene";
  8388. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8389. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8390. /**
  8391. * Class for creating a cube texture
  8392. */
  8393. export class CubeTexture extends BaseTexture {
  8394. private _delayedOnLoad;
  8395. /**
  8396. * The url of the texture
  8397. */
  8398. url: string;
  8399. /**
  8400. * Gets or sets the center of the bounding box associated with the cube texture.
  8401. * It must define where the camera used to render the texture was set
  8402. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8403. */
  8404. boundingBoxPosition: Vector3;
  8405. private _boundingBoxSize;
  8406. /**
  8407. * Gets or sets the size of the bounding box associated with the cube texture
  8408. * When defined, the cubemap will switch to local mode
  8409. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  8410. * @example https://www.babylonjs-playground.com/#RNASML
  8411. */
  8412. /**
  8413. * Returns the bounding box size
  8414. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  8415. */
  8416. boundingBoxSize: Vector3;
  8417. protected _rotationY: number;
  8418. /**
  8419. * Sets texture matrix rotation angle around Y axis in radians.
  8420. */
  8421. /**
  8422. * Gets texture matrix rotation angle around Y axis radians.
  8423. */
  8424. rotationY: number;
  8425. /**
  8426. * Are mip maps generated for this texture or not.
  8427. */
  8428. readonly noMipmap: boolean;
  8429. private _noMipmap;
  8430. private _files;
  8431. private _extensions;
  8432. private _textureMatrix;
  8433. private _format;
  8434. private _createPolynomials;
  8435. /** @hidden */
  8436. _prefiltered: boolean;
  8437. /**
  8438. * Creates a cube texture from an array of image urls
  8439. * @param files defines an array of image urls
  8440. * @param scene defines the hosting scene
  8441. * @param noMipmap specifies if mip maps are not used
  8442. * @returns a cube texture
  8443. */
  8444. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8445. /**
  8446. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8447. * @param url defines the url of the prefiltered texture
  8448. * @param scene defines the scene the texture is attached to
  8449. * @param forcedExtension defines the extension of the file if different from the url
  8450. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8451. * @return the prefiltered texture
  8452. */
  8453. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8454. /**
  8455. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8456. * as prefiltered data.
  8457. * @param rootUrl defines the url of the texture or the root name of the six images
  8458. * @param scene defines the scene the texture is attached to
  8459. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8460. * @param noMipmap defines if mipmaps should be created or not
  8461. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8462. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8463. * @param onError defines a callback triggered in case of error during load
  8464. * @param format defines the internal format to use for the texture once loaded
  8465. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8466. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8467. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8468. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8469. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8470. * @return the cube texture
  8471. */
  8472. 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);
  8473. /**
  8474. * Get the current class name of the texture useful for serialization or dynamic coding.
  8475. * @returns "CubeTexture"
  8476. */
  8477. getClassName(): string;
  8478. /**
  8479. * Update the url (and optional buffer) of this texture if url was null during construction.
  8480. * @param url the url of the texture
  8481. * @param forcedExtension defines the extension to use
  8482. * @param onLoad callback called when the texture is loaded (defaults to null)
  8483. */
  8484. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  8485. /**
  8486. * Delays loading of the cube texture
  8487. * @param forcedExtension defines the extension to use
  8488. */
  8489. delayLoad(forcedExtension?: string): void;
  8490. /**
  8491. * Returns the reflection texture matrix
  8492. * @returns the reflection texture matrix
  8493. */
  8494. getReflectionTextureMatrix(): Matrix;
  8495. /**
  8496. * Sets the reflection texture matrix
  8497. * @param value Reflection texture matrix
  8498. */
  8499. setReflectionTextureMatrix(value: Matrix): void;
  8500. /**
  8501. * Parses text to create a cube texture
  8502. * @param parsedTexture define the serialized text to read from
  8503. * @param scene defines the hosting scene
  8504. * @param rootUrl defines the root url of the cube texture
  8505. * @returns a cube texture
  8506. */
  8507. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8508. /**
  8509. * Makes a clone, or deep copy, of the cube texture
  8510. * @returns a new cube texture
  8511. */
  8512. clone(): CubeTexture;
  8513. }
  8514. }
  8515. declare module "babylonjs/Shaders/postprocess.vertex" {
  8516. /** @hidden */
  8517. export var postprocessVertexShader: {
  8518. name: string;
  8519. shader: string;
  8520. };
  8521. }
  8522. declare module "babylonjs/Cameras/targetCamera" {
  8523. import { Nullable } from "babylonjs/types";
  8524. import { Camera } from "babylonjs/Cameras/camera";
  8525. import { Scene } from "babylonjs/scene";
  8526. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  8527. /**
  8528. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  8529. * This is the base of the follow, arc rotate cameras and Free camera
  8530. * @see http://doc.babylonjs.com/features/cameras
  8531. */
  8532. export class TargetCamera extends Camera {
  8533. private static _RigCamTransformMatrix;
  8534. private static _TargetTransformMatrix;
  8535. private static _TargetFocalPoint;
  8536. /**
  8537. * Define the current direction the camera is moving to
  8538. */
  8539. cameraDirection: Vector3;
  8540. /**
  8541. * Define the current rotation the camera is rotating to
  8542. */
  8543. cameraRotation: Vector2;
  8544. /**
  8545. * When set, the up vector of the camera will be updated by the rotation of the camera
  8546. */
  8547. updateUpVectorFromRotation: boolean;
  8548. private _tmpQuaternion;
  8549. /**
  8550. * Define the current rotation of the camera
  8551. */
  8552. rotation: Vector3;
  8553. /**
  8554. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  8555. */
  8556. rotationQuaternion: Quaternion;
  8557. /**
  8558. * Define the current speed of the camera
  8559. */
  8560. speed: number;
  8561. /**
  8562. * Add cconstraint to the camera to prevent it to move freely in all directions and
  8563. * around all axis.
  8564. */
  8565. noRotationConstraint: boolean;
  8566. /**
  8567. * Define the current target of the camera as an object or a position.
  8568. */
  8569. lockedTarget: any;
  8570. /** @hidden */
  8571. _currentTarget: Vector3;
  8572. /** @hidden */
  8573. _initialFocalDistance: number;
  8574. /** @hidden */
  8575. _viewMatrix: Matrix;
  8576. /** @hidden */
  8577. _camMatrix: Matrix;
  8578. /** @hidden */
  8579. _cameraTransformMatrix: Matrix;
  8580. /** @hidden */
  8581. _cameraRotationMatrix: Matrix;
  8582. /** @hidden */
  8583. _referencePoint: Vector3;
  8584. /** @hidden */
  8585. _transformedReferencePoint: Vector3;
  8586. protected _globalCurrentTarget: Vector3;
  8587. protected _globalCurrentUpVector: Vector3;
  8588. /** @hidden */
  8589. _reset: () => void;
  8590. private _defaultUp;
  8591. /**
  8592. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  8593. * This is the base of the follow, arc rotate cameras and Free camera
  8594. * @see http://doc.babylonjs.com/features/cameras
  8595. * @param name Defines the name of the camera in the scene
  8596. * @param position Defines the start position of the camera in the scene
  8597. * @param scene Defines the scene the camera belongs to
  8598. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  8599. */
  8600. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  8601. /**
  8602. * Gets the position in front of the camera at a given distance.
  8603. * @param distance The distance from the camera we want the position to be
  8604. * @returns the position
  8605. */
  8606. getFrontPosition(distance: number): Vector3;
  8607. /** @hidden */
  8608. _getLockedTargetPosition(): Nullable<Vector3>;
  8609. private _storedPosition;
  8610. private _storedRotation;
  8611. private _storedRotationQuaternion;
  8612. /**
  8613. * Store current camera state of the camera (fov, position, rotation, etc..)
  8614. * @returns the camera
  8615. */
  8616. storeState(): Camera;
  8617. /**
  8618. * Restored camera state. You must call storeState() first
  8619. * @returns whether it was successful or not
  8620. * @hidden
  8621. */
  8622. _restoreStateValues(): boolean;
  8623. /** @hidden */
  8624. _initCache(): void;
  8625. /** @hidden */
  8626. _updateCache(ignoreParentClass?: boolean): void;
  8627. /** @hidden */
  8628. _isSynchronizedViewMatrix(): boolean;
  8629. /** @hidden */
  8630. _computeLocalCameraSpeed(): number;
  8631. /**
  8632. * Defines the target the camera should look at.
  8633. * This will automatically adapt alpha beta and radius to fit within the new target.
  8634. * @param target Defines the new target as a Vector or a mesh
  8635. */
  8636. setTarget(target: Vector3): void;
  8637. /**
  8638. * Return the current target position of the camera. This value is expressed in local space.
  8639. * @returns the target position
  8640. */
  8641. getTarget(): Vector3;
  8642. /** @hidden */
  8643. _decideIfNeedsToMove(): boolean;
  8644. /** @hidden */
  8645. _updatePosition(): void;
  8646. /** @hidden */
  8647. _checkInputs(): void;
  8648. protected _updateCameraRotationMatrix(): void;
  8649. /**
  8650. * 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)
  8651. * @returns the current camera
  8652. */
  8653. private _rotateUpVectorWithCameraRotationMatrix;
  8654. private _cachedRotationZ;
  8655. private _cachedQuaternionRotationZ;
  8656. /** @hidden */
  8657. _getViewMatrix(): Matrix;
  8658. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  8659. /**
  8660. * @hidden
  8661. */
  8662. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  8663. /**
  8664. * @hidden
  8665. */
  8666. _updateRigCameras(): void;
  8667. private _getRigCamPositionAndTarget;
  8668. /**
  8669. * Gets the current object class name.
  8670. * @return the class name
  8671. */
  8672. getClassName(): string;
  8673. }
  8674. }
  8675. declare module "babylonjs/Cameras/cameraInputsManager" {
  8676. import { Nullable } from "babylonjs/types";
  8677. import { Camera } from "babylonjs/Cameras/camera";
  8678. /**
  8679. * @ignore
  8680. * This is a list of all the different input types that are available in the application.
  8681. * Fo instance: ArcRotateCameraGamepadInput...
  8682. */
  8683. export var CameraInputTypes: {};
  8684. /**
  8685. * This is the contract to implement in order to create a new input class.
  8686. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  8687. */
  8688. export interface ICameraInput<TCamera extends Camera> {
  8689. /**
  8690. * Defines the camera the input is attached to.
  8691. */
  8692. camera: Nullable<TCamera>;
  8693. /**
  8694. * Gets the class name of the current intput.
  8695. * @returns the class name
  8696. */
  8697. getClassName(): string;
  8698. /**
  8699. * Get the friendly name associated with the input class.
  8700. * @returns the input friendly name
  8701. */
  8702. getSimpleName(): string;
  8703. /**
  8704. * Attach the input controls to a specific dom element to get the input from.
  8705. * @param element Defines the element the controls should be listened from
  8706. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8707. */
  8708. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8709. /**
  8710. * Detach the current controls from the specified dom element.
  8711. * @param element Defines the element to stop listening the inputs from
  8712. */
  8713. detachControl(element: Nullable<HTMLElement>): void;
  8714. /**
  8715. * Update the current camera state depending on the inputs that have been used this frame.
  8716. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8717. */
  8718. checkInputs?: () => void;
  8719. }
  8720. /**
  8721. * Represents a map of input types to input instance or input index to input instance.
  8722. */
  8723. export interface CameraInputsMap<TCamera extends Camera> {
  8724. /**
  8725. * Accessor to the input by input type.
  8726. */
  8727. [name: string]: ICameraInput<TCamera>;
  8728. /**
  8729. * Accessor to the input by input index.
  8730. */
  8731. [idx: number]: ICameraInput<TCamera>;
  8732. }
  8733. /**
  8734. * This represents the input manager used within a camera.
  8735. * It helps dealing with all the different kind of input attached to a camera.
  8736. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8737. */
  8738. export class CameraInputsManager<TCamera extends Camera> {
  8739. /**
  8740. * Defines the list of inputs attahed to the camera.
  8741. */
  8742. attached: CameraInputsMap<TCamera>;
  8743. /**
  8744. * Defines the dom element the camera is collecting inputs from.
  8745. * This is null if the controls have not been attached.
  8746. */
  8747. attachedElement: Nullable<HTMLElement>;
  8748. /**
  8749. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8750. */
  8751. noPreventDefault: boolean;
  8752. /**
  8753. * Defined the camera the input manager belongs to.
  8754. */
  8755. camera: TCamera;
  8756. /**
  8757. * Update the current camera state depending on the inputs that have been used this frame.
  8758. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8759. */
  8760. checkInputs: () => void;
  8761. /**
  8762. * Instantiate a new Camera Input Manager.
  8763. * @param camera Defines the camera the input manager blongs to
  8764. */
  8765. constructor(camera: TCamera);
  8766. /**
  8767. * Add an input method to a camera
  8768. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8769. * @param input camera input method
  8770. */
  8771. add(input: ICameraInput<TCamera>): void;
  8772. /**
  8773. * Remove a specific input method from a camera
  8774. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  8775. * @param inputToRemove camera input method
  8776. */
  8777. remove(inputToRemove: ICameraInput<TCamera>): void;
  8778. /**
  8779. * Remove a specific input type from a camera
  8780. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  8781. * @param inputType the type of the input to remove
  8782. */
  8783. removeByType(inputType: string): void;
  8784. private _addCheckInputs;
  8785. /**
  8786. * Attach the input controls to the currently attached dom element to listen the events from.
  8787. * @param input Defines the input to attach
  8788. */
  8789. attachInput(input: ICameraInput<TCamera>): void;
  8790. /**
  8791. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  8792. * @param element Defines the dom element to collect the events from
  8793. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8794. */
  8795. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  8796. /**
  8797. * Detach the current manager inputs controls from a specific dom element.
  8798. * @param element Defines the dom element to collect the events from
  8799. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  8800. */
  8801. detachElement(element: HTMLElement, disconnect?: boolean): void;
  8802. /**
  8803. * Rebuild the dynamic inputCheck function from the current list of
  8804. * defined inputs in the manager.
  8805. */
  8806. rebuildInputCheck(): void;
  8807. /**
  8808. * Remove all attached input methods from a camera
  8809. */
  8810. clear(): void;
  8811. /**
  8812. * Serialize the current input manager attached to a camera.
  8813. * This ensures than once parsed,
  8814. * the input associated to the camera will be identical to the current ones
  8815. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  8816. */
  8817. serialize(serializedCamera: any): void;
  8818. /**
  8819. * Parses an input manager serialized JSON to restore the previous list of inputs
  8820. * and states associated to a camera.
  8821. * @param parsedCamera Defines the JSON to parse
  8822. */
  8823. parse(parsedCamera: any): void;
  8824. }
  8825. }
  8826. declare module "babylonjs/Events/keyboardEvents" {
  8827. /**
  8828. * Gather the list of keyboard event types as constants.
  8829. */
  8830. export class KeyboardEventTypes {
  8831. /**
  8832. * The keydown event is fired when a key becomes active (pressed).
  8833. */
  8834. static readonly KEYDOWN: number;
  8835. /**
  8836. * The keyup event is fired when a key has been released.
  8837. */
  8838. static readonly KEYUP: number;
  8839. }
  8840. /**
  8841. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8842. */
  8843. export class KeyboardInfo {
  8844. /**
  8845. * Defines the type of event (KeyboardEventTypes)
  8846. */
  8847. type: number;
  8848. /**
  8849. * Defines the related dom event
  8850. */
  8851. event: KeyboardEvent;
  8852. /**
  8853. * Instantiates a new keyboard info.
  8854. * This class is used to store keyboard related info for the onKeyboardObservable event.
  8855. * @param type Defines the type of event (KeyboardEventTypes)
  8856. * @param event Defines the related dom event
  8857. */
  8858. constructor(
  8859. /**
  8860. * Defines the type of event (KeyboardEventTypes)
  8861. */
  8862. type: number,
  8863. /**
  8864. * Defines the related dom event
  8865. */
  8866. event: KeyboardEvent);
  8867. }
  8868. /**
  8869. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8870. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  8871. */
  8872. export class KeyboardInfoPre extends KeyboardInfo {
  8873. /**
  8874. * Defines the type of event (KeyboardEventTypes)
  8875. */
  8876. type: number;
  8877. /**
  8878. * Defines the related dom event
  8879. */
  8880. event: KeyboardEvent;
  8881. /**
  8882. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  8883. */
  8884. skipOnPointerObservable: boolean;
  8885. /**
  8886. * Instantiates a new keyboard pre info.
  8887. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  8888. * @param type Defines the type of event (KeyboardEventTypes)
  8889. * @param event Defines the related dom event
  8890. */
  8891. constructor(
  8892. /**
  8893. * Defines the type of event (KeyboardEventTypes)
  8894. */
  8895. type: number,
  8896. /**
  8897. * Defines the related dom event
  8898. */
  8899. event: KeyboardEvent);
  8900. }
  8901. }
  8902. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  8903. import { Nullable } from "babylonjs/types";
  8904. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  8905. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  8906. /**
  8907. * Manage the keyboard inputs to control the movement of a free camera.
  8908. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  8909. */
  8910. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  8911. /**
  8912. * Defines the camera the input is attached to.
  8913. */
  8914. camera: FreeCamera;
  8915. /**
  8916. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  8917. */
  8918. keysUp: number[];
  8919. /**
  8920. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  8921. */
  8922. keysDown: number[];
  8923. /**
  8924. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  8925. */
  8926. keysLeft: number[];
  8927. /**
  8928. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  8929. */
  8930. keysRight: number[];
  8931. private _keys;
  8932. private _onCanvasBlurObserver;
  8933. private _onKeyboardObserver;
  8934. private _engine;
  8935. private _scene;
  8936. /**
  8937. * Attach the input controls to a specific dom element to get the input from.
  8938. * @param element Defines the element the controls should be listened from
  8939. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  8940. */
  8941. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  8942. /**
  8943. * Detach the current controls from the specified dom element.
  8944. * @param element Defines the element to stop listening the inputs from
  8945. */
  8946. detachControl(element: Nullable<HTMLElement>): void;
  8947. /**
  8948. * Update the current camera state depending on the inputs that have been used this frame.
  8949. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  8950. */
  8951. checkInputs(): void;
  8952. /**
  8953. * Gets the class name of the current intput.
  8954. * @returns the class name
  8955. */
  8956. getClassName(): string;
  8957. /** @hidden */
  8958. _onLostFocus(): void;
  8959. /**
  8960. * Get the friendly name associated with the input class.
  8961. * @returns the input friendly name
  8962. */
  8963. getSimpleName(): string;
  8964. }
  8965. }
  8966. declare module "babylonjs/Lights/shadowLight" {
  8967. import { Camera } from "babylonjs/Cameras/camera";
  8968. import { Scene } from "babylonjs/scene";
  8969. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  8970. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  8971. import { Light } from "babylonjs/Lights/light";
  8972. /**
  8973. * Interface describing all the common properties and methods a shadow light needs to implement.
  8974. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  8975. * as well as binding the different shadow properties to the effects.
  8976. */
  8977. export interface IShadowLight extends Light {
  8978. /**
  8979. * The light id in the scene (used in scene.findLighById for instance)
  8980. */
  8981. id: string;
  8982. /**
  8983. * The position the shdow will be casted from.
  8984. */
  8985. position: Vector3;
  8986. /**
  8987. * In 2d mode (needCube being false), the direction used to cast the shadow.
  8988. */
  8989. direction: Vector3;
  8990. /**
  8991. * The transformed position. Position of the light in world space taking parenting in account.
  8992. */
  8993. transformedPosition: Vector3;
  8994. /**
  8995. * The transformed direction. Direction of the light in world space taking parenting in account.
  8996. */
  8997. transformedDirection: Vector3;
  8998. /**
  8999. * The friendly name of the light in the scene.
  9000. */
  9001. name: string;
  9002. /**
  9003. * Defines the shadow projection clipping minimum z value.
  9004. */
  9005. shadowMinZ: number;
  9006. /**
  9007. * Defines the shadow projection clipping maximum z value.
  9008. */
  9009. shadowMaxZ: number;
  9010. /**
  9011. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9012. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9013. */
  9014. computeTransformedInformation(): boolean;
  9015. /**
  9016. * Gets the scene the light belongs to.
  9017. * @returns The scene
  9018. */
  9019. getScene(): Scene;
  9020. /**
  9021. * Callback defining a custom Projection Matrix Builder.
  9022. * This can be used to override the default projection matrix computation.
  9023. */
  9024. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9025. /**
  9026. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9027. * @param matrix The materix to updated with the projection information
  9028. * @param viewMatrix The transform matrix of the light
  9029. * @param renderList The list of mesh to render in the map
  9030. * @returns The current light
  9031. */
  9032. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9033. /**
  9034. * Gets the current depth scale used in ESM.
  9035. * @returns The scale
  9036. */
  9037. getDepthScale(): number;
  9038. /**
  9039. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9040. * @returns true if a cube texture needs to be use
  9041. */
  9042. needCube(): boolean;
  9043. /**
  9044. * Detects if the projection matrix requires to be recomputed this frame.
  9045. * @returns true if it requires to be recomputed otherwise, false.
  9046. */
  9047. needProjectionMatrixCompute(): boolean;
  9048. /**
  9049. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9050. */
  9051. forceProjectionMatrixCompute(): void;
  9052. /**
  9053. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9054. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9055. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9056. */
  9057. getShadowDirection(faceIndex?: number): Vector3;
  9058. /**
  9059. * Gets the minZ used for shadow according to both the scene and the light.
  9060. * @param activeCamera The camera we are returning the min for
  9061. * @returns the depth min z
  9062. */
  9063. getDepthMinZ(activeCamera: Camera): number;
  9064. /**
  9065. * Gets the maxZ used for shadow according to both the scene and the light.
  9066. * @param activeCamera The camera we are returning the max for
  9067. * @returns the depth max z
  9068. */
  9069. getDepthMaxZ(activeCamera: Camera): number;
  9070. }
  9071. /**
  9072. * Base implementation IShadowLight
  9073. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9074. */
  9075. export abstract class ShadowLight extends Light implements IShadowLight {
  9076. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9077. protected _position: Vector3;
  9078. protected _setPosition(value: Vector3): void;
  9079. /**
  9080. * Sets the position the shadow will be casted from. Also use as the light position for both
  9081. * point and spot lights.
  9082. */
  9083. /**
  9084. * Sets the position the shadow will be casted from. Also use as the light position for both
  9085. * point and spot lights.
  9086. */
  9087. position: Vector3;
  9088. protected _direction: Vector3;
  9089. protected _setDirection(value: Vector3): void;
  9090. /**
  9091. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9092. * Also use as the light direction on spot and directional lights.
  9093. */
  9094. /**
  9095. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9096. * Also use as the light direction on spot and directional lights.
  9097. */
  9098. direction: Vector3;
  9099. private _shadowMinZ;
  9100. /**
  9101. * Gets the shadow projection clipping minimum z value.
  9102. */
  9103. /**
  9104. * Sets the shadow projection clipping minimum z value.
  9105. */
  9106. shadowMinZ: number;
  9107. private _shadowMaxZ;
  9108. /**
  9109. * Sets the shadow projection clipping maximum z value.
  9110. */
  9111. /**
  9112. * Gets the shadow projection clipping maximum z value.
  9113. */
  9114. shadowMaxZ: number;
  9115. /**
  9116. * Callback defining a custom Projection Matrix Builder.
  9117. * This can be used to override the default projection matrix computation.
  9118. */
  9119. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9120. /**
  9121. * The transformed position. Position of the light in world space taking parenting in account.
  9122. */
  9123. transformedPosition: Vector3;
  9124. /**
  9125. * The transformed direction. Direction of the light in world space taking parenting in account.
  9126. */
  9127. transformedDirection: Vector3;
  9128. private _needProjectionMatrixCompute;
  9129. /**
  9130. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9131. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9132. */
  9133. computeTransformedInformation(): boolean;
  9134. /**
  9135. * Return the depth scale used for the shadow map.
  9136. * @returns the depth scale.
  9137. */
  9138. getDepthScale(): number;
  9139. /**
  9140. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9141. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9142. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9143. */
  9144. getShadowDirection(faceIndex?: number): Vector3;
  9145. /**
  9146. * Returns the ShadowLight absolute position in the World.
  9147. * @returns the position vector in world space
  9148. */
  9149. getAbsolutePosition(): Vector3;
  9150. /**
  9151. * Sets the ShadowLight direction toward the passed target.
  9152. * @param target The point to target in local space
  9153. * @returns the updated ShadowLight direction
  9154. */
  9155. setDirectionToTarget(target: Vector3): Vector3;
  9156. /**
  9157. * Returns the light rotation in euler definition.
  9158. * @returns the x y z rotation in local space.
  9159. */
  9160. getRotation(): Vector3;
  9161. /**
  9162. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9163. * @returns true if a cube texture needs to be use
  9164. */
  9165. needCube(): boolean;
  9166. /**
  9167. * Detects if the projection matrix requires to be recomputed this frame.
  9168. * @returns true if it requires to be recomputed otherwise, false.
  9169. */
  9170. needProjectionMatrixCompute(): boolean;
  9171. /**
  9172. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9173. */
  9174. forceProjectionMatrixCompute(): void;
  9175. /** @hidden */
  9176. _initCache(): void;
  9177. /** @hidden */
  9178. _isSynchronized(): boolean;
  9179. /**
  9180. * Computes the world matrix of the node
  9181. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9182. * @returns the world matrix
  9183. */
  9184. computeWorldMatrix(force?: boolean): Matrix;
  9185. /**
  9186. * Gets the minZ used for shadow according to both the scene and the light.
  9187. * @param activeCamera The camera we are returning the min for
  9188. * @returns the depth min z
  9189. */
  9190. getDepthMinZ(activeCamera: Camera): number;
  9191. /**
  9192. * Gets the maxZ used for shadow according to both the scene and the light.
  9193. * @param activeCamera The camera we are returning the max for
  9194. * @returns the depth max z
  9195. */
  9196. getDepthMaxZ(activeCamera: Camera): number;
  9197. /**
  9198. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9199. * @param matrix The materix to updated with the projection information
  9200. * @param viewMatrix The transform matrix of the light
  9201. * @param renderList The list of mesh to render in the map
  9202. * @returns The current light
  9203. */
  9204. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9205. }
  9206. }
  9207. declare module "babylonjs/Materials/materialHelper" {
  9208. import { Nullable } from "babylonjs/types";
  9209. import { Scene } from "babylonjs/scene";
  9210. import { Engine } from "babylonjs/Engines/engine";
  9211. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9212. import { Light } from "babylonjs/Lights/light";
  9213. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  9214. import { Effect, EffectFallbacks, EffectCreationOptions } from "babylonjs/Materials/effect";
  9215. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  9216. /**
  9217. * "Static Class" containing the most commonly used helper while dealing with material for
  9218. * rendering purpose.
  9219. *
  9220. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  9221. *
  9222. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  9223. */
  9224. export class MaterialHelper {
  9225. /**
  9226. * Bind the current view position to an effect.
  9227. * @param effect The effect to be bound
  9228. * @param scene The scene the eyes position is used from
  9229. */
  9230. static BindEyePosition(effect: Effect, scene: Scene): void;
  9231. /**
  9232. * Helps preparing the defines values about the UVs in used in the effect.
  9233. * UVs are shared as much as we can accross channels in the shaders.
  9234. * @param texture The texture we are preparing the UVs for
  9235. * @param defines The defines to update
  9236. * @param key The channel key "diffuse", "specular"... used in the shader
  9237. */
  9238. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  9239. /**
  9240. * Binds a texture matrix value to its corrsponding uniform
  9241. * @param texture The texture to bind the matrix for
  9242. * @param uniformBuffer The uniform buffer receivin the data
  9243. * @param key The channel key "diffuse", "specular"... used in the shader
  9244. */
  9245. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  9246. /**
  9247. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  9248. * @param mesh defines the current mesh
  9249. * @param scene defines the current scene
  9250. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  9251. * @param pointsCloud defines if point cloud rendering has to be turned on
  9252. * @param fogEnabled defines if fog has to be turned on
  9253. * @param alphaTest defines if alpha testing has to be turned on
  9254. * @param defines defines the current list of defines
  9255. */
  9256. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  9257. /**
  9258. * Helper used to prepare the list of defines associated with frame values for shader compilation
  9259. * @param scene defines the current scene
  9260. * @param engine defines the current engine
  9261. * @param defines specifies the list of active defines
  9262. * @param useInstances defines if instances have to be turned on
  9263. * @param useClipPlane defines if clip plane have to be turned on
  9264. */
  9265. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  9266. /**
  9267. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  9268. * @param mesh The mesh containing the geometry data we will draw
  9269. * @param defines The defines to update
  9270. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  9271. * @param useBones Precise whether bones should be used or not (override mesh info)
  9272. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  9273. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  9274. * @returns false if defines are considered not dirty and have not been checked
  9275. */
  9276. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  9277. /**
  9278. * Prepares the defines related to multiview
  9279. * @param scene The scene we are intending to draw
  9280. * @param defines The defines to update
  9281. */
  9282. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  9283. /**
  9284. * Prepares the defines related to the light information passed in parameter
  9285. * @param scene The scene we are intending to draw
  9286. * @param mesh The mesh the effect is compiling for
  9287. * @param defines The defines to update
  9288. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  9289. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  9290. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  9291. * @returns true if normals will be required for the rest of the effect
  9292. */
  9293. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  9294. /**
  9295. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  9296. * that won t be acctive due to defines being turned off.
  9297. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  9298. * @param samplersList The samplers list
  9299. * @param defines The defines helping in the list generation
  9300. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  9301. */
  9302. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  9303. /**
  9304. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  9305. * @param defines The defines to update while falling back
  9306. * @param fallbacks The authorized effect fallbacks
  9307. * @param maxSimultaneousLights The maximum number of lights allowed
  9308. * @param rank the current rank of the Effect
  9309. * @returns The newly affected rank
  9310. */
  9311. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  9312. /**
  9313. * Prepares the list of attributes required for morph targets according to the effect defines.
  9314. * @param attribs The current list of supported attribs
  9315. * @param mesh The mesh to prepare the morph targets attributes for
  9316. * @param defines The current Defines of the effect
  9317. */
  9318. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  9319. /**
  9320. * Prepares the list of attributes required for bones according to the effect defines.
  9321. * @param attribs The current list of supported attribs
  9322. * @param mesh The mesh to prepare the bones attributes for
  9323. * @param defines The current Defines of the effect
  9324. * @param fallbacks The current efffect fallback strategy
  9325. */
  9326. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  9327. /**
  9328. * Prepares the list of attributes required for instances according to the effect defines.
  9329. * @param attribs The current list of supported attribs
  9330. * @param defines The current Defines of the effect
  9331. */
  9332. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  9333. /**
  9334. * Binds the light shadow information to the effect for the given mesh.
  9335. * @param light The light containing the generator
  9336. * @param scene The scene the lights belongs to
  9337. * @param mesh The mesh we are binding the information to render
  9338. * @param lightIndex The light index in the effect used to render the mesh
  9339. * @param effect The effect we are binding the data to
  9340. */
  9341. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  9342. /**
  9343. * Binds the light information to the effect.
  9344. * @param light The light containing the generator
  9345. * @param effect The effect we are binding the data to
  9346. * @param lightIndex The light index in the effect used to render
  9347. */
  9348. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  9349. /**
  9350. * Binds the lights information from the scene to the effect for the given mesh.
  9351. * @param scene The scene the lights belongs to
  9352. * @param mesh The mesh we are binding the information to render
  9353. * @param effect The effect we are binding the data to
  9354. * @param defines The generated defines for the effect
  9355. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  9356. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  9357. */
  9358. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  9359. private static _tempFogColor;
  9360. /**
  9361. * Binds the fog information from the scene to the effect for the given mesh.
  9362. * @param scene The scene the lights belongs to
  9363. * @param mesh The mesh we are binding the information to render
  9364. * @param effect The effect we are binding the data to
  9365. * @param linearSpace Defines if the fog effect is applied in linear space
  9366. */
  9367. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  9368. /**
  9369. * Binds the bones information from the mesh to the effect.
  9370. * @param mesh The mesh we are binding the information to render
  9371. * @param effect The effect we are binding the data to
  9372. */
  9373. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  9374. /**
  9375. * Binds the morph targets information from the mesh to the effect.
  9376. * @param abstractMesh The mesh we are binding the information to render
  9377. * @param effect The effect we are binding the data to
  9378. */
  9379. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  9380. /**
  9381. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  9382. * @param defines The generated defines used in the effect
  9383. * @param effect The effect we are binding the data to
  9384. * @param scene The scene we are willing to render with logarithmic scale for
  9385. */
  9386. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  9387. /**
  9388. * Binds the clip plane information from the scene to the effect.
  9389. * @param scene The scene the clip plane information are extracted from
  9390. * @param effect The effect we are binding the data to
  9391. */
  9392. static BindClipPlane(effect: Effect, scene: Scene): void;
  9393. }
  9394. }
  9395. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  9396. /** @hidden */
  9397. export var kernelBlurVaryingDeclaration: {
  9398. name: string;
  9399. shader: string;
  9400. };
  9401. }
  9402. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  9403. /** @hidden */
  9404. export var kernelBlurFragment: {
  9405. name: string;
  9406. shader: string;
  9407. };
  9408. }
  9409. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  9410. /** @hidden */
  9411. export var kernelBlurFragment2: {
  9412. name: string;
  9413. shader: string;
  9414. };
  9415. }
  9416. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  9417. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9418. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  9419. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  9420. /** @hidden */
  9421. export var kernelBlurPixelShader: {
  9422. name: string;
  9423. shader: string;
  9424. };
  9425. }
  9426. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  9427. /** @hidden */
  9428. export var kernelBlurVertex: {
  9429. name: string;
  9430. shader: string;
  9431. };
  9432. }
  9433. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  9434. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  9435. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  9436. /** @hidden */
  9437. export var kernelBlurVertexShader: {
  9438. name: string;
  9439. shader: string;
  9440. };
  9441. }
  9442. declare module "babylonjs/PostProcesses/blurPostProcess" {
  9443. import { Vector2 } from "babylonjs/Maths/math";
  9444. import { Nullable } from "babylonjs/types";
  9445. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  9446. import { Camera } from "babylonjs/Cameras/camera";
  9447. import { Effect } from "babylonjs/Materials/effect";
  9448. import { Engine } from "babylonjs/Engines/engine";
  9449. import "babylonjs/Shaders/kernelBlur.fragment";
  9450. import "babylonjs/Shaders/kernelBlur.vertex";
  9451. /**
  9452. * The Blur Post Process which blurs an image based on a kernel and direction.
  9453. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  9454. */
  9455. export class BlurPostProcess extends PostProcess {
  9456. /** The direction in which to blur the image. */
  9457. direction: Vector2;
  9458. private blockCompilation;
  9459. protected _kernel: number;
  9460. protected _idealKernel: number;
  9461. protected _packedFloat: boolean;
  9462. private _staticDefines;
  9463. /**
  9464. * Sets the length in pixels of the blur sample region
  9465. */
  9466. /**
  9467. * Gets the length in pixels of the blur sample region
  9468. */
  9469. kernel: number;
  9470. /**
  9471. * Sets wether or not the blur needs to unpack/repack floats
  9472. */
  9473. /**
  9474. * Gets wether or not the blur is unpacking/repacking floats
  9475. */
  9476. packedFloat: boolean;
  9477. /**
  9478. * Creates a new instance BlurPostProcess
  9479. * @param name The name of the effect.
  9480. * @param direction The direction in which to blur the image.
  9481. * @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.
  9482. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  9483. * @param camera The camera to apply the render pass to.
  9484. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  9485. * @param engine The engine which the post process will be applied. (default: current engine)
  9486. * @param reusable If the post process can be reused on the same frame. (default: false)
  9487. * @param textureType Type of textures used when performing the post process. (default: 0)
  9488. * @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)
  9489. */
  9490. constructor(name: string,
  9491. /** The direction in which to blur the image. */
  9492. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  9493. /**
  9494. * Updates the effect with the current post process compile time values and recompiles the shader.
  9495. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  9496. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  9497. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  9498. * @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
  9499. * @param onCompiled Called when the shader has been compiled.
  9500. * @param onError Called if there is an error when compiling a shader.
  9501. */
  9502. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9503. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  9504. /**
  9505. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  9506. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  9507. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  9508. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  9509. * The gaps between physical kernels are compensated for in the weighting of the samples
  9510. * @param idealKernel Ideal blur kernel.
  9511. * @return Nearest best kernel.
  9512. */
  9513. protected _nearestBestKernel(idealKernel: number): number;
  9514. /**
  9515. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  9516. * @param x The point on the Gaussian distribution to sample.
  9517. * @return the value of the Gaussian function at x.
  9518. */
  9519. protected _gaussianWeight(x: number): number;
  9520. /**
  9521. * Generates a string that can be used as a floating point number in GLSL.
  9522. * @param x Value to print.
  9523. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  9524. * @return GLSL float string.
  9525. */
  9526. protected _glslFloat(x: number, decimalFigures?: number): string;
  9527. }
  9528. }
  9529. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9530. /** @hidden */
  9531. export var shadowMapPixelShader: {
  9532. name: string;
  9533. shader: string;
  9534. };
  9535. }
  9536. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9537. /** @hidden */
  9538. export var bonesDeclaration: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9544. /** @hidden */
  9545. export var morphTargetsVertexGlobalDeclaration: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9551. /** @hidden */
  9552. export var morphTargetsVertexDeclaration: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9558. /** @hidden */
  9559. export var instancesDeclaration: {
  9560. name: string;
  9561. shader: string;
  9562. };
  9563. }
  9564. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9565. /** @hidden */
  9566. export var helperFunctions: {
  9567. name: string;
  9568. shader: string;
  9569. };
  9570. }
  9571. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9572. /** @hidden */
  9573. export var morphTargetsVertex: {
  9574. name: string;
  9575. shader: string;
  9576. };
  9577. }
  9578. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9579. /** @hidden */
  9580. export var instancesVertex: {
  9581. name: string;
  9582. shader: string;
  9583. };
  9584. }
  9585. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9586. /** @hidden */
  9587. export var bonesVertex: {
  9588. name: string;
  9589. shader: string;
  9590. };
  9591. }
  9592. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9593. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9594. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9595. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9596. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9597. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9598. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9599. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9600. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9601. /** @hidden */
  9602. export var shadowMapVertexShader: {
  9603. name: string;
  9604. shader: string;
  9605. };
  9606. }
  9607. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9608. /** @hidden */
  9609. export var depthBoxBlurPixelShader: {
  9610. name: string;
  9611. shader: string;
  9612. };
  9613. }
  9614. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  9615. import { Nullable } from "babylonjs/types";
  9616. import { Scene } from "babylonjs/scene";
  9617. import { Matrix } from "babylonjs/Maths/math";
  9618. import { SubMesh } from "babylonjs/Meshes/subMesh";
  9619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9620. import { Mesh } from "babylonjs/Meshes/mesh";
  9621. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  9622. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  9623. import { Effect } from "babylonjs/Materials/effect";
  9624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  9625. import "babylonjs/Shaders/shadowMap.fragment";
  9626. import "babylonjs/Shaders/shadowMap.vertex";
  9627. import "babylonjs/Shaders/depthBoxBlur.fragment";
  9628. import { Observable } from "babylonjs/Misc/observable";
  9629. /**
  9630. * Defines the options associated with the creation of a custom shader for a shadow generator.
  9631. */
  9632. export interface ICustomShaderOptions {
  9633. /**
  9634. * Gets or sets the custom shader name to use
  9635. */
  9636. shaderName: string;
  9637. /**
  9638. * The list of attribute names used in the shader
  9639. */
  9640. attributes?: string[];
  9641. /**
  9642. * The list of unifrom names used in the shader
  9643. */
  9644. uniforms?: string[];
  9645. /**
  9646. * The list of sampler names used in the shader
  9647. */
  9648. samplers?: string[];
  9649. /**
  9650. * The list of defines used in the shader
  9651. */
  9652. defines?: string[];
  9653. }
  9654. /**
  9655. * Interface to implement to create a shadow generator compatible with BJS.
  9656. */
  9657. export interface IShadowGenerator {
  9658. /**
  9659. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9660. * @returns The render target texture if present otherwise, null
  9661. */
  9662. getShadowMap(): Nullable<RenderTargetTexture>;
  9663. /**
  9664. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  9665. * @returns The render target texture if the shadow map is present otherwise, null
  9666. */
  9667. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  9668. /**
  9669. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  9670. * @param subMesh The submesh we want to render in the shadow map
  9671. * @param useInstances Defines wether will draw in the map using instances
  9672. * @returns true if ready otherwise, false
  9673. */
  9674. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  9675. /**
  9676. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  9677. * @param defines Defines of the material we want to update
  9678. * @param lightIndex Index of the light in the enabled light list of the material
  9679. */
  9680. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  9681. /**
  9682. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  9683. * defined in the generator but impacting the effect).
  9684. * It implies the unifroms available on the materials are the standard BJS ones.
  9685. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  9686. * @param effect The effect we are binfing the information for
  9687. */
  9688. bindShadowLight(lightIndex: string, effect: Effect): void;
  9689. /**
  9690. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  9691. * (eq to shadow prjection matrix * light transform matrix)
  9692. * @returns The transform matrix used to create the shadow map
  9693. */
  9694. getTransformMatrix(): Matrix;
  9695. /**
  9696. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  9697. * Cube and 2D textures for instance.
  9698. */
  9699. recreateShadowMap(): void;
  9700. /**
  9701. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9702. * @param onCompiled Callback triggered at the and of the effects compilation
  9703. * @param options Sets of optional options forcing the compilation with different modes
  9704. */
  9705. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  9706. useInstances: boolean;
  9707. }>): void;
  9708. /**
  9709. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  9710. * @param options Sets of optional options forcing the compilation with different modes
  9711. * @returns A promise that resolves when the compilation completes
  9712. */
  9713. forceCompilationAsync(options?: Partial<{
  9714. useInstances: boolean;
  9715. }>): Promise<void>;
  9716. /**
  9717. * Serializes the shadow generator setup to a json object.
  9718. * @returns The serialized JSON object
  9719. */
  9720. serialize(): any;
  9721. /**
  9722. * Disposes the Shadow map and related Textures and effects.
  9723. */
  9724. dispose(): void;
  9725. }
  9726. /**
  9727. * Default implementation IShadowGenerator.
  9728. * This is the main object responsible of generating shadows in the framework.
  9729. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  9730. */
  9731. export class ShadowGenerator implements IShadowGenerator {
  9732. /**
  9733. * Shadow generator mode None: no filtering applied.
  9734. */
  9735. static readonly FILTER_NONE: number;
  9736. /**
  9737. * Shadow generator mode ESM: Exponential Shadow Mapping.
  9738. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9739. */
  9740. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  9741. /**
  9742. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  9743. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  9744. */
  9745. static readonly FILTER_POISSONSAMPLING: number;
  9746. /**
  9747. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  9748. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9749. */
  9750. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  9751. /**
  9752. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  9753. * edge artifacts on steep falloff.
  9754. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9755. */
  9756. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  9757. /**
  9758. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  9759. * edge artifacts on steep falloff.
  9760. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  9761. */
  9762. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  9763. /**
  9764. * Shadow generator mode PCF: Percentage Closer Filtering
  9765. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9766. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  9767. */
  9768. static readonly FILTER_PCF: number;
  9769. /**
  9770. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  9771. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  9772. * Contact Hardening
  9773. */
  9774. static readonly FILTER_PCSS: number;
  9775. /**
  9776. * Reserved for PCF and PCSS
  9777. * Highest Quality.
  9778. *
  9779. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  9780. *
  9781. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  9782. */
  9783. static readonly QUALITY_HIGH: number;
  9784. /**
  9785. * Reserved for PCF and PCSS
  9786. * Good tradeoff for quality/perf cross devices
  9787. *
  9788. * Execute PCF on a 3*3 kernel.
  9789. *
  9790. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  9791. */
  9792. static readonly QUALITY_MEDIUM: number;
  9793. /**
  9794. * Reserved for PCF and PCSS
  9795. * The lowest quality but the fastest.
  9796. *
  9797. * Execute PCF on a 1*1 kernel.
  9798. *
  9799. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  9800. */
  9801. static readonly QUALITY_LOW: number;
  9802. /** Gets or sets the custom shader name to use */
  9803. customShaderOptions: ICustomShaderOptions;
  9804. /**
  9805. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  9806. */
  9807. onBeforeShadowMapRenderObservable: Observable<Effect>;
  9808. /**
  9809. * Observable triggered before a mesh is rendered in the shadow map.
  9810. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  9811. */
  9812. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  9813. private _bias;
  9814. /**
  9815. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  9816. */
  9817. /**
  9818. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  9819. */
  9820. bias: number;
  9821. private _normalBias;
  9822. /**
  9823. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9824. */
  9825. /**
  9826. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  9827. */
  9828. normalBias: number;
  9829. private _blurBoxOffset;
  9830. /**
  9831. * Gets the blur box offset: offset applied during the blur pass.
  9832. * Only useful if useKernelBlur = false
  9833. */
  9834. /**
  9835. * Sets the blur box offset: offset applied during the blur pass.
  9836. * Only useful if useKernelBlur = false
  9837. */
  9838. blurBoxOffset: number;
  9839. private _blurScale;
  9840. /**
  9841. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  9842. * 2 means half of the size.
  9843. */
  9844. /**
  9845. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  9846. * 2 means half of the size.
  9847. */
  9848. blurScale: number;
  9849. private _blurKernel;
  9850. /**
  9851. * Gets the blur kernel: kernel size of the blur pass.
  9852. * Only useful if useKernelBlur = true
  9853. */
  9854. /**
  9855. * Sets the blur kernel: kernel size of the blur pass.
  9856. * Only useful if useKernelBlur = true
  9857. */
  9858. blurKernel: number;
  9859. private _useKernelBlur;
  9860. /**
  9861. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  9862. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9863. */
  9864. /**
  9865. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  9866. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  9867. */
  9868. useKernelBlur: boolean;
  9869. private _depthScale;
  9870. /**
  9871. * Gets the depth scale used in ESM mode.
  9872. */
  9873. /**
  9874. * Sets the depth scale used in ESM mode.
  9875. * This can override the scale stored on the light.
  9876. */
  9877. depthScale: number;
  9878. private _filter;
  9879. /**
  9880. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  9881. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9882. */
  9883. /**
  9884. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  9885. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  9886. */
  9887. filter: number;
  9888. /**
  9889. * Gets if the current filter is set to Poisson Sampling.
  9890. */
  9891. /**
  9892. * Sets the current filter to Poisson Sampling.
  9893. */
  9894. usePoissonSampling: boolean;
  9895. /**
  9896. * Gets if the current filter is set to ESM.
  9897. */
  9898. /**
  9899. * Sets the current filter is to ESM.
  9900. */
  9901. useExponentialShadowMap: boolean;
  9902. /**
  9903. * Gets if the current filter is set to filtered ESM.
  9904. */
  9905. /**
  9906. * Gets if the current filter is set to filtered ESM.
  9907. */
  9908. useBlurExponentialShadowMap: boolean;
  9909. /**
  9910. * Gets if the current filter is set to "close ESM" (using the inverse of the
  9911. * exponential to prevent steep falloff artifacts).
  9912. */
  9913. /**
  9914. * Sets the current filter to "close ESM" (using the inverse of the
  9915. * exponential to prevent steep falloff artifacts).
  9916. */
  9917. useCloseExponentialShadowMap: boolean;
  9918. /**
  9919. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  9920. * exponential to prevent steep falloff artifacts).
  9921. */
  9922. /**
  9923. * Sets the current filter to filtered "close ESM" (using the inverse of the
  9924. * exponential to prevent steep falloff artifacts).
  9925. */
  9926. useBlurCloseExponentialShadowMap: boolean;
  9927. /**
  9928. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  9929. */
  9930. /**
  9931. * Sets the current filter to "PCF" (percentage closer filtering).
  9932. */
  9933. usePercentageCloserFiltering: boolean;
  9934. private _filteringQuality;
  9935. /**
  9936. * Gets the PCF or PCSS Quality.
  9937. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9938. */
  9939. /**
  9940. * Sets the PCF or PCSS Quality.
  9941. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  9942. */
  9943. filteringQuality: number;
  9944. /**
  9945. * Gets if the current filter is set to "PCSS" (contact hardening).
  9946. */
  9947. /**
  9948. * Sets the current filter to "PCSS" (contact hardening).
  9949. */
  9950. useContactHardeningShadow: boolean;
  9951. private _contactHardeningLightSizeUVRatio;
  9952. /**
  9953. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9954. * Using a ratio helps keeping shape stability independently of the map size.
  9955. *
  9956. * It does not account for the light projection as it was having too much
  9957. * instability during the light setup or during light position changes.
  9958. *
  9959. * Only valid if useContactHardeningShadow is true.
  9960. */
  9961. /**
  9962. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  9963. * Using a ratio helps keeping shape stability independently of the map size.
  9964. *
  9965. * It does not account for the light projection as it was having too much
  9966. * instability during the light setup or during light position changes.
  9967. *
  9968. * Only valid if useContactHardeningShadow is true.
  9969. */
  9970. contactHardeningLightSizeUVRatio: number;
  9971. private _darkness;
  9972. /**
  9973. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  9974. * 0 means strongest and 1 would means no shadow.
  9975. * @returns the darkness.
  9976. */
  9977. getDarkness(): number;
  9978. /**
  9979. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  9980. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  9981. * @returns the shadow generator allowing fluent coding.
  9982. */
  9983. setDarkness(darkness: number): ShadowGenerator;
  9984. private _transparencyShadow;
  9985. /**
  9986. * Sets the ability to have transparent shadow (boolean).
  9987. * @param transparent True if transparent else False
  9988. * @returns the shadow generator allowing fluent coding
  9989. */
  9990. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  9991. private _shadowMap;
  9992. private _shadowMap2;
  9993. /**
  9994. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  9995. * @returns The render target texture if present otherwise, null
  9996. */
  9997. getShadowMap(): Nullable<RenderTargetTexture>;
  9998. /**
  9999. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  10000. * @returns The render target texture if the shadow map is present otherwise, null
  10001. */
  10002. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  10003. /**
  10004. * Helper function to add a mesh and its descendants to the list of shadow casters.
  10005. * @param mesh Mesh to add
  10006. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  10007. * @returns the Shadow Generator itself
  10008. */
  10009. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10010. /**
  10011. * Helper function to remove a mesh and its descendants from the list of shadow casters
  10012. * @param mesh Mesh to remove
  10013. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  10014. * @returns the Shadow Generator itself
  10015. */
  10016. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  10017. /**
  10018. * Controls the extent to which the shadows fade out at the edge of the frustum
  10019. * Used only by directionals and spots
  10020. */
  10021. frustumEdgeFalloff: number;
  10022. private _light;
  10023. /**
  10024. * Returns the associated light object.
  10025. * @returns the light generating the shadow
  10026. */
  10027. getLight(): IShadowLight;
  10028. /**
  10029. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  10030. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  10031. * It might on the other hand introduce peter panning.
  10032. */
  10033. forceBackFacesOnly: boolean;
  10034. private _scene;
  10035. private _lightDirection;
  10036. private _effect;
  10037. private _viewMatrix;
  10038. private _projectionMatrix;
  10039. private _transformMatrix;
  10040. private _cachedPosition;
  10041. private _cachedDirection;
  10042. private _cachedDefines;
  10043. private _currentRenderID;
  10044. private _boxBlurPostprocess;
  10045. private _kernelBlurXPostprocess;
  10046. private _kernelBlurYPostprocess;
  10047. private _blurPostProcesses;
  10048. private _mapSize;
  10049. private _currentFaceIndex;
  10050. private _currentFaceIndexCache;
  10051. private _textureType;
  10052. private _defaultTextureMatrix;
  10053. /** @hidden */
  10054. static _SceneComponentInitialization: (scene: Scene) => void;
  10055. /**
  10056. * Creates a ShadowGenerator object.
  10057. * A ShadowGenerator is the required tool to use the shadows.
  10058. * Each light casting shadows needs to use its own ShadowGenerator.
  10059. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  10060. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  10061. * @param light The light object generating the shadows.
  10062. * @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.
  10063. */
  10064. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  10065. private _initializeGenerator;
  10066. private _initializeShadowMap;
  10067. private _initializeBlurRTTAndPostProcesses;
  10068. private _renderForShadowMap;
  10069. private _renderSubMeshForShadowMap;
  10070. private _applyFilterValues;
  10071. /**
  10072. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10073. * @param onCompiled Callback triggered at the and of the effects compilation
  10074. * @param options Sets of optional options forcing the compilation with different modes
  10075. */
  10076. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  10077. useInstances: boolean;
  10078. }>): void;
  10079. /**
  10080. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  10081. * @param options Sets of optional options forcing the compilation with different modes
  10082. * @returns A promise that resolves when the compilation completes
  10083. */
  10084. forceCompilationAsync(options?: Partial<{
  10085. useInstances: boolean;
  10086. }>): Promise<void>;
  10087. /**
  10088. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  10089. * @param subMesh The submesh we want to render in the shadow map
  10090. * @param useInstances Defines wether will draw in the map using instances
  10091. * @returns true if ready otherwise, false
  10092. */
  10093. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  10094. /**
  10095. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  10096. * @param defines Defines of the material we want to update
  10097. * @param lightIndex Index of the light in the enabled light list of the material
  10098. */
  10099. prepareDefines(defines: any, lightIndex: number): void;
  10100. /**
  10101. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  10102. * defined in the generator but impacting the effect).
  10103. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  10104. * @param effect The effect we are binfing the information for
  10105. */
  10106. bindShadowLight(lightIndex: string, effect: Effect): void;
  10107. /**
  10108. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  10109. * (eq to shadow prjection matrix * light transform matrix)
  10110. * @returns The transform matrix used to create the shadow map
  10111. */
  10112. getTransformMatrix(): Matrix;
  10113. /**
  10114. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  10115. * Cube and 2D textures for instance.
  10116. */
  10117. recreateShadowMap(): void;
  10118. private _disposeBlurPostProcesses;
  10119. private _disposeRTTandPostProcesses;
  10120. /**
  10121. * Disposes the ShadowGenerator.
  10122. * Returns nothing.
  10123. */
  10124. dispose(): void;
  10125. /**
  10126. * Serializes the shadow generator setup to a json object.
  10127. * @returns The serialized JSON object
  10128. */
  10129. serialize(): any;
  10130. /**
  10131. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  10132. * @param parsedShadowGenerator The JSON object to parse
  10133. * @param scene The scene to create the shadow map for
  10134. * @returns The parsed shadow generator
  10135. */
  10136. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  10137. }
  10138. }
  10139. declare module "babylonjs/Lights/light" {
  10140. import { Nullable } from "babylonjs/types";
  10141. import { Scene } from "babylonjs/scene";
  10142. import { Vector3, Color3 } from "babylonjs/Maths/math";
  10143. import { Node } from "babylonjs/node";
  10144. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10145. import { Effect } from "babylonjs/Materials/effect";
  10146. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  10147. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  10148. /**
  10149. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  10150. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  10151. * 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.
  10152. */
  10153. export abstract class Light extends Node {
  10154. /**
  10155. * Falloff Default: light is falling off following the material specification:
  10156. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  10157. */
  10158. static readonly FALLOFF_DEFAULT: number;
  10159. /**
  10160. * Falloff Physical: light is falling off following the inverse squared distance law.
  10161. */
  10162. static readonly FALLOFF_PHYSICAL: number;
  10163. /**
  10164. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  10165. * to enhance interoperability with other engines.
  10166. */
  10167. static readonly FALLOFF_GLTF: number;
  10168. /**
  10169. * Falloff Standard: light is falling off like in the standard material
  10170. * to enhance interoperability with other materials.
  10171. */
  10172. static readonly FALLOFF_STANDARD: number;
  10173. /**
  10174. * If every light affecting the material is in this lightmapMode,
  10175. * material.lightmapTexture adds or multiplies
  10176. * (depends on material.useLightmapAsShadowmap)
  10177. * after every other light calculations.
  10178. */
  10179. static readonly LIGHTMAP_DEFAULT: number;
  10180. /**
  10181. * material.lightmapTexture as only diffuse lighting from this light
  10182. * adds only specular lighting from this light
  10183. * adds dynamic shadows
  10184. */
  10185. static readonly LIGHTMAP_SPECULAR: number;
  10186. /**
  10187. * material.lightmapTexture as only lighting
  10188. * no light calculation from this light
  10189. * only adds dynamic shadows from this light
  10190. */
  10191. static readonly LIGHTMAP_SHADOWSONLY: number;
  10192. /**
  10193. * Each light type uses the default quantity according to its type:
  10194. * point/spot lights use luminous intensity
  10195. * directional lights use illuminance
  10196. */
  10197. static readonly INTENSITYMODE_AUTOMATIC: number;
  10198. /**
  10199. * lumen (lm)
  10200. */
  10201. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  10202. /**
  10203. * candela (lm/sr)
  10204. */
  10205. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  10206. /**
  10207. * lux (lm/m^2)
  10208. */
  10209. static readonly INTENSITYMODE_ILLUMINANCE: number;
  10210. /**
  10211. * nit (cd/m^2)
  10212. */
  10213. static readonly INTENSITYMODE_LUMINANCE: number;
  10214. /**
  10215. * Light type const id of the point light.
  10216. */
  10217. static readonly LIGHTTYPEID_POINTLIGHT: number;
  10218. /**
  10219. * Light type const id of the directional light.
  10220. */
  10221. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  10222. /**
  10223. * Light type const id of the spot light.
  10224. */
  10225. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  10226. /**
  10227. * Light type const id of the hemispheric light.
  10228. */
  10229. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  10230. /**
  10231. * Diffuse gives the basic color to an object.
  10232. */
  10233. diffuse: Color3;
  10234. /**
  10235. * Specular produces a highlight color on an object.
  10236. * Note: This is note affecting PBR materials.
  10237. */
  10238. specular: Color3;
  10239. /**
  10240. * Defines the falloff type for this light. This lets overrriding how punctual light are
  10241. * falling off base on range or angle.
  10242. * This can be set to any values in Light.FALLOFF_x.
  10243. *
  10244. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  10245. * other types of materials.
  10246. */
  10247. falloffType: number;
  10248. /**
  10249. * Strength of the light.
  10250. * Note: By default it is define in the framework own unit.
  10251. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  10252. */
  10253. intensity: number;
  10254. private _range;
  10255. protected _inverseSquaredRange: number;
  10256. /**
  10257. * Defines how far from the source the light is impacting in scene units.
  10258. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10259. */
  10260. /**
  10261. * Defines how far from the source the light is impacting in scene units.
  10262. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  10263. */
  10264. range: number;
  10265. /**
  10266. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  10267. * of light.
  10268. */
  10269. private _photometricScale;
  10270. private _intensityMode;
  10271. /**
  10272. * Gets the photometric scale used to interpret the intensity.
  10273. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10274. */
  10275. /**
  10276. * Sets the photometric scale used to interpret the intensity.
  10277. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  10278. */
  10279. intensityMode: number;
  10280. private _radius;
  10281. /**
  10282. * Gets the light radius used by PBR Materials to simulate soft area lights.
  10283. */
  10284. /**
  10285. * sets the light radius used by PBR Materials to simulate soft area lights.
  10286. */
  10287. radius: number;
  10288. private _renderPriority;
  10289. /**
  10290. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  10291. * exceeding the number allowed of the materials.
  10292. */
  10293. renderPriority: number;
  10294. private _shadowEnabled;
  10295. /**
  10296. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10297. * the current shadow generator.
  10298. */
  10299. /**
  10300. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  10301. * the current shadow generator.
  10302. */
  10303. shadowEnabled: boolean;
  10304. private _includedOnlyMeshes;
  10305. /**
  10306. * Gets the only meshes impacted by this light.
  10307. */
  10308. /**
  10309. * Sets the only meshes impacted by this light.
  10310. */
  10311. includedOnlyMeshes: AbstractMesh[];
  10312. private _excludedMeshes;
  10313. /**
  10314. * Gets the meshes not impacted by this light.
  10315. */
  10316. /**
  10317. * Sets the meshes not impacted by this light.
  10318. */
  10319. excludedMeshes: AbstractMesh[];
  10320. private _excludeWithLayerMask;
  10321. /**
  10322. * Gets the layer id use to find what meshes are not impacted by the light.
  10323. * Inactive if 0
  10324. */
  10325. /**
  10326. * Sets the layer id use to find what meshes are not impacted by the light.
  10327. * Inactive if 0
  10328. */
  10329. excludeWithLayerMask: number;
  10330. private _includeOnlyWithLayerMask;
  10331. /**
  10332. * Gets the layer id use to find what meshes are impacted by the light.
  10333. * Inactive if 0
  10334. */
  10335. /**
  10336. * Sets the layer id use to find what meshes are impacted by the light.
  10337. * Inactive if 0
  10338. */
  10339. includeOnlyWithLayerMask: number;
  10340. private _lightmapMode;
  10341. /**
  10342. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10343. */
  10344. /**
  10345. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  10346. */
  10347. lightmapMode: number;
  10348. /**
  10349. * Shadow generator associted to the light.
  10350. * @hidden Internal use only.
  10351. */
  10352. _shadowGenerator: Nullable<IShadowGenerator>;
  10353. /**
  10354. * @hidden Internal use only.
  10355. */
  10356. _excludedMeshesIds: string[];
  10357. /**
  10358. * @hidden Internal use only.
  10359. */
  10360. _includedOnlyMeshesIds: string[];
  10361. /**
  10362. * The current light unifom buffer.
  10363. * @hidden Internal use only.
  10364. */
  10365. _uniformBuffer: UniformBuffer;
  10366. /**
  10367. * Creates a Light object in the scene.
  10368. * Documentation : https://doc.babylonjs.com/babylon101/lights
  10369. * @param name The firendly name of the light
  10370. * @param scene The scene the light belongs too
  10371. */
  10372. constructor(name: string, scene: Scene);
  10373. protected abstract _buildUniformLayout(): void;
  10374. /**
  10375. * Sets the passed Effect "effect" with the Light information.
  10376. * @param effect The effect to update
  10377. * @param lightIndex The index of the light in the effect to update
  10378. * @returns The light
  10379. */
  10380. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  10381. /**
  10382. * Returns the string "Light".
  10383. * @returns the class name
  10384. */
  10385. getClassName(): string;
  10386. /** @hidden */
  10387. readonly _isLight: boolean;
  10388. /**
  10389. * Converts the light information to a readable string for debug purpose.
  10390. * @param fullDetails Supports for multiple levels of logging within scene loading
  10391. * @returns the human readable light info
  10392. */
  10393. toString(fullDetails?: boolean): string;
  10394. /** @hidden */
  10395. protected _syncParentEnabledState(): void;
  10396. /**
  10397. * Set the enabled state of this node.
  10398. * @param value - the new enabled state
  10399. */
  10400. setEnabled(value: boolean): void;
  10401. /**
  10402. * Returns the Light associated shadow generator if any.
  10403. * @return the associated shadow generator.
  10404. */
  10405. getShadowGenerator(): Nullable<IShadowGenerator>;
  10406. /**
  10407. * Returns a Vector3, the absolute light position in the World.
  10408. * @returns the world space position of the light
  10409. */
  10410. getAbsolutePosition(): Vector3;
  10411. /**
  10412. * Specifies if the light will affect the passed mesh.
  10413. * @param mesh The mesh to test against the light
  10414. * @return true the mesh is affected otherwise, false.
  10415. */
  10416. canAffectMesh(mesh: AbstractMesh): boolean;
  10417. /**
  10418. * Sort function to order lights for rendering.
  10419. * @param a First Light object to compare to second.
  10420. * @param b Second Light object to compare first.
  10421. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  10422. */
  10423. static CompareLightsPriority(a: Light, b: Light): number;
  10424. /**
  10425. * Releases resources associated with this node.
  10426. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  10427. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  10428. */
  10429. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  10430. /**
  10431. * Returns the light type ID (integer).
  10432. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  10433. */
  10434. getTypeID(): number;
  10435. /**
  10436. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  10437. * @returns the scaled intensity in intensity mode unit
  10438. */
  10439. getScaledIntensity(): number;
  10440. /**
  10441. * Returns a new Light object, named "name", from the current one.
  10442. * @param name The name of the cloned light
  10443. * @returns the new created light
  10444. */
  10445. clone(name: string): Nullable<Light>;
  10446. /**
  10447. * Serializes the current light into a Serialization object.
  10448. * @returns the serialized object.
  10449. */
  10450. serialize(): any;
  10451. /**
  10452. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  10453. * This new light is named "name" and added to the passed scene.
  10454. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  10455. * @param name The friendly name of the light
  10456. * @param scene The scene the new light will belong to
  10457. * @returns the constructor function
  10458. */
  10459. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  10460. /**
  10461. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  10462. * @param parsedLight The JSON representation of the light
  10463. * @param scene The scene to create the parsed light in
  10464. * @returns the created light after parsing
  10465. */
  10466. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  10467. private _hookArrayForExcluded;
  10468. private _hookArrayForIncludedOnly;
  10469. private _resyncMeshes;
  10470. /**
  10471. * Forces the meshes to update their light related information in their rendering used effects
  10472. * @hidden Internal Use Only
  10473. */
  10474. _markMeshesAsLightDirty(): void;
  10475. /**
  10476. * Recomputes the cached photometric scale if needed.
  10477. */
  10478. private _computePhotometricScale;
  10479. /**
  10480. * Returns the Photometric Scale according to the light type and intensity mode.
  10481. */
  10482. private _getPhotometricScale;
  10483. /**
  10484. * Reorder the light in the scene according to their defined priority.
  10485. * @hidden Internal Use Only
  10486. */
  10487. _reorderLightsInScene(): void;
  10488. /**
  10489. * Prepares the list of defines specific to the light type.
  10490. * @param defines the list of defines
  10491. * @param lightIndex defines the index of the light for the effect
  10492. */
  10493. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  10494. }
  10495. }
  10496. declare module "babylonjs/Actions/action" {
  10497. import { Observable } from "babylonjs/Misc/observable";
  10498. import { Condition } from "babylonjs/Actions/condition";
  10499. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10500. import { ActionManager } from "babylonjs/Actions/actionManager";
  10501. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10502. /**
  10503. * Interface used to define Action
  10504. */
  10505. export interface IAction {
  10506. /**
  10507. * Trigger for the action
  10508. */
  10509. trigger: number;
  10510. /** Options of the trigger */
  10511. triggerOptions: any;
  10512. /**
  10513. * Gets the trigger parameters
  10514. * @returns the trigger parameters
  10515. */
  10516. getTriggerParameter(): any;
  10517. /**
  10518. * Internal only - executes current action event
  10519. * @hidden
  10520. */
  10521. _executeCurrent(evt?: ActionEvent): void;
  10522. /**
  10523. * Serialize placeholder for child classes
  10524. * @param parent of child
  10525. * @returns the serialized object
  10526. */
  10527. serialize(parent: any): any;
  10528. /**
  10529. * Internal only
  10530. * @hidden
  10531. */
  10532. _prepare(): void;
  10533. /**
  10534. * Internal only - manager for action
  10535. * @hidden
  10536. */
  10537. _actionManager: AbstractActionManager;
  10538. }
  10539. /**
  10540. * The action to be carried out following a trigger
  10541. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  10542. */
  10543. export class Action implements IAction {
  10544. /** the trigger, with or without parameters, for the action */
  10545. triggerOptions: any;
  10546. /**
  10547. * Trigger for the action
  10548. */
  10549. trigger: number;
  10550. /**
  10551. * Internal only - manager for action
  10552. * @hidden
  10553. */
  10554. _actionManager: ActionManager;
  10555. private _nextActiveAction;
  10556. private _child;
  10557. private _condition?;
  10558. private _triggerParameter;
  10559. /**
  10560. * An event triggered prior to action being executed.
  10561. */
  10562. onBeforeExecuteObservable: Observable<Action>;
  10563. /**
  10564. * Creates a new Action
  10565. * @param triggerOptions the trigger, with or without parameters, for the action
  10566. * @param condition an optional determinant of action
  10567. */
  10568. constructor(
  10569. /** the trigger, with or without parameters, for the action */
  10570. triggerOptions: any, condition?: Condition);
  10571. /**
  10572. * Internal only
  10573. * @hidden
  10574. */
  10575. _prepare(): void;
  10576. /**
  10577. * Gets the trigger parameters
  10578. * @returns the trigger parameters
  10579. */
  10580. getTriggerParameter(): any;
  10581. /**
  10582. * Internal only - executes current action event
  10583. * @hidden
  10584. */
  10585. _executeCurrent(evt?: ActionEvent): void;
  10586. /**
  10587. * Execute placeholder for child classes
  10588. * @param evt optional action event
  10589. */
  10590. execute(evt?: ActionEvent): void;
  10591. /**
  10592. * Skips to next active action
  10593. */
  10594. skipToNextActiveAction(): void;
  10595. /**
  10596. * Adds action to chain of actions, may be a DoNothingAction
  10597. * @param action defines the next action to execute
  10598. * @returns The action passed in
  10599. * @see https://www.babylonjs-playground.com/#1T30HR#0
  10600. */
  10601. then(action: Action): Action;
  10602. /**
  10603. * Internal only
  10604. * @hidden
  10605. */
  10606. _getProperty(propertyPath: string): string;
  10607. /**
  10608. * Internal only
  10609. * @hidden
  10610. */
  10611. _getEffectiveTarget(target: any, propertyPath: string): any;
  10612. /**
  10613. * Serialize placeholder for child classes
  10614. * @param parent of child
  10615. * @returns the serialized object
  10616. */
  10617. serialize(parent: any): any;
  10618. /**
  10619. * Internal only called by serialize
  10620. * @hidden
  10621. */
  10622. protected _serialize(serializedAction: any, parent?: any): any;
  10623. /**
  10624. * Internal only
  10625. * @hidden
  10626. */
  10627. static _SerializeValueAsString: (value: any) => string;
  10628. /**
  10629. * Internal only
  10630. * @hidden
  10631. */
  10632. static _GetTargetProperty: (target: import("babylonjs/scene").Scene | import("babylonjs/node").Node) => {
  10633. name: string;
  10634. targetType: string;
  10635. value: string;
  10636. };
  10637. }
  10638. }
  10639. declare module "babylonjs/Actions/condition" {
  10640. import { ActionManager } from "babylonjs/Actions/actionManager";
  10641. /**
  10642. * A Condition applied to an Action
  10643. */
  10644. export class Condition {
  10645. /**
  10646. * Internal only - manager for action
  10647. * @hidden
  10648. */
  10649. _actionManager: ActionManager;
  10650. /**
  10651. * Internal only
  10652. * @hidden
  10653. */
  10654. _evaluationId: number;
  10655. /**
  10656. * Internal only
  10657. * @hidden
  10658. */
  10659. _currentResult: boolean;
  10660. /**
  10661. * Creates a new Condition
  10662. * @param actionManager the manager of the action the condition is applied to
  10663. */
  10664. constructor(actionManager: ActionManager);
  10665. /**
  10666. * Check if the current condition is valid
  10667. * @returns a boolean
  10668. */
  10669. isValid(): boolean;
  10670. /**
  10671. * Internal only
  10672. * @hidden
  10673. */
  10674. _getProperty(propertyPath: string): string;
  10675. /**
  10676. * Internal only
  10677. * @hidden
  10678. */
  10679. _getEffectiveTarget(target: any, propertyPath: string): any;
  10680. /**
  10681. * Serialize placeholder for child classes
  10682. * @returns the serialized object
  10683. */
  10684. serialize(): any;
  10685. /**
  10686. * Internal only
  10687. * @hidden
  10688. */
  10689. protected _serialize(serializedCondition: any): any;
  10690. }
  10691. /**
  10692. * Defines specific conditional operators as extensions of Condition
  10693. */
  10694. export class ValueCondition extends Condition {
  10695. /** path to specify the property of the target the conditional operator uses */
  10696. propertyPath: string;
  10697. /** the value compared by the conditional operator against the current value of the property */
  10698. value: any;
  10699. /** the conditional operator, default ValueCondition.IsEqual */
  10700. operator: number;
  10701. /**
  10702. * Internal only
  10703. * @hidden
  10704. */
  10705. private static _IsEqual;
  10706. /**
  10707. * Internal only
  10708. * @hidden
  10709. */
  10710. private static _IsDifferent;
  10711. /**
  10712. * Internal only
  10713. * @hidden
  10714. */
  10715. private static _IsGreater;
  10716. /**
  10717. * Internal only
  10718. * @hidden
  10719. */
  10720. private static _IsLesser;
  10721. /**
  10722. * returns the number for IsEqual
  10723. */
  10724. static readonly IsEqual: number;
  10725. /**
  10726. * Returns the number for IsDifferent
  10727. */
  10728. static readonly IsDifferent: number;
  10729. /**
  10730. * Returns the number for IsGreater
  10731. */
  10732. static readonly IsGreater: number;
  10733. /**
  10734. * Returns the number for IsLesser
  10735. */
  10736. static readonly IsLesser: number;
  10737. /**
  10738. * Internal only The action manager for the condition
  10739. * @hidden
  10740. */
  10741. _actionManager: ActionManager;
  10742. /**
  10743. * Internal only
  10744. * @hidden
  10745. */
  10746. private _target;
  10747. /**
  10748. * Internal only
  10749. * @hidden
  10750. */
  10751. private _effectiveTarget;
  10752. /**
  10753. * Internal only
  10754. * @hidden
  10755. */
  10756. private _property;
  10757. /**
  10758. * Creates a new ValueCondition
  10759. * @param actionManager manager for the action the condition applies to
  10760. * @param target for the action
  10761. * @param propertyPath path to specify the property of the target the conditional operator uses
  10762. * @param value the value compared by the conditional operator against the current value of the property
  10763. * @param operator the conditional operator, default ValueCondition.IsEqual
  10764. */
  10765. constructor(actionManager: ActionManager, target: any,
  10766. /** path to specify the property of the target the conditional operator uses */
  10767. propertyPath: string,
  10768. /** the value compared by the conditional operator against the current value of the property */
  10769. value: any,
  10770. /** the conditional operator, default ValueCondition.IsEqual */
  10771. operator?: number);
  10772. /**
  10773. * Compares the given value with the property value for the specified conditional operator
  10774. * @returns the result of the comparison
  10775. */
  10776. isValid(): boolean;
  10777. /**
  10778. * Serialize the ValueCondition into a JSON compatible object
  10779. * @returns serialization object
  10780. */
  10781. serialize(): any;
  10782. /**
  10783. * Gets the name of the conditional operator for the ValueCondition
  10784. * @param operator the conditional operator
  10785. * @returns the name
  10786. */
  10787. static GetOperatorName(operator: number): string;
  10788. }
  10789. /**
  10790. * Defines a predicate condition as an extension of Condition
  10791. */
  10792. export class PredicateCondition extends Condition {
  10793. /** defines the predicate function used to validate the condition */
  10794. predicate: () => boolean;
  10795. /**
  10796. * Internal only - manager for action
  10797. * @hidden
  10798. */
  10799. _actionManager: ActionManager;
  10800. /**
  10801. * Creates a new PredicateCondition
  10802. * @param actionManager manager for the action the condition applies to
  10803. * @param predicate defines the predicate function used to validate the condition
  10804. */
  10805. constructor(actionManager: ActionManager,
  10806. /** defines the predicate function used to validate the condition */
  10807. predicate: () => boolean);
  10808. /**
  10809. * @returns the validity of the predicate condition
  10810. */
  10811. isValid(): boolean;
  10812. }
  10813. /**
  10814. * Defines a state condition as an extension of Condition
  10815. */
  10816. export class StateCondition extends Condition {
  10817. /** Value to compare with target state */
  10818. value: string;
  10819. /**
  10820. * Internal only - manager for action
  10821. * @hidden
  10822. */
  10823. _actionManager: ActionManager;
  10824. /**
  10825. * Internal only
  10826. * @hidden
  10827. */
  10828. private _target;
  10829. /**
  10830. * Creates a new StateCondition
  10831. * @param actionManager manager for the action the condition applies to
  10832. * @param target of the condition
  10833. * @param value to compare with target state
  10834. */
  10835. constructor(actionManager: ActionManager, target: any,
  10836. /** Value to compare with target state */
  10837. value: string);
  10838. /**
  10839. * Gets a boolean indicating if the current condition is met
  10840. * @returns the validity of the state
  10841. */
  10842. isValid(): boolean;
  10843. /**
  10844. * Serialize the StateCondition into a JSON compatible object
  10845. * @returns serialization object
  10846. */
  10847. serialize(): any;
  10848. }
  10849. }
  10850. declare module "babylonjs/Actions/directActions" {
  10851. import { Action } from "babylonjs/Actions/action";
  10852. import { Condition } from "babylonjs/Actions/condition";
  10853. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  10854. /**
  10855. * This defines an action responsible to toggle a boolean once triggered.
  10856. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10857. */
  10858. export class SwitchBooleanAction extends Action {
  10859. /**
  10860. * The path to the boolean property in the target object
  10861. */
  10862. propertyPath: string;
  10863. private _target;
  10864. private _effectiveTarget;
  10865. private _property;
  10866. /**
  10867. * Instantiate the action
  10868. * @param triggerOptions defines the trigger options
  10869. * @param target defines the object containing the boolean
  10870. * @param propertyPath defines the path to the boolean property in the target object
  10871. * @param condition defines the trigger related conditions
  10872. */
  10873. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  10874. /** @hidden */
  10875. _prepare(): void;
  10876. /**
  10877. * Execute the action toggle the boolean value.
  10878. */
  10879. execute(): void;
  10880. /**
  10881. * Serializes the actions and its related information.
  10882. * @param parent defines the object to serialize in
  10883. * @returns the serialized object
  10884. */
  10885. serialize(parent: any): any;
  10886. }
  10887. /**
  10888. * This defines an action responsible to set a the state field of the target
  10889. * to a desired value once triggered.
  10890. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10891. */
  10892. export class SetStateAction extends Action {
  10893. /**
  10894. * The value to store in the state field.
  10895. */
  10896. value: string;
  10897. private _target;
  10898. /**
  10899. * Instantiate the action
  10900. * @param triggerOptions defines the trigger options
  10901. * @param target defines the object containing the state property
  10902. * @param value defines the value to store in the state field
  10903. * @param condition defines the trigger related conditions
  10904. */
  10905. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10906. /**
  10907. * Execute the action and store the value on the target state property.
  10908. */
  10909. execute(): void;
  10910. /**
  10911. * Serializes the actions and its related information.
  10912. * @param parent defines the object to serialize in
  10913. * @returns the serialized object
  10914. */
  10915. serialize(parent: any): any;
  10916. }
  10917. /**
  10918. * This defines an action responsible to set a property of the target
  10919. * to a desired value once triggered.
  10920. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10921. */
  10922. export class SetValueAction extends Action {
  10923. /**
  10924. * The path of the property to set in the target.
  10925. */
  10926. propertyPath: string;
  10927. /**
  10928. * The value to set in the property
  10929. */
  10930. value: any;
  10931. private _target;
  10932. private _effectiveTarget;
  10933. private _property;
  10934. /**
  10935. * Instantiate the action
  10936. * @param triggerOptions defines the trigger options
  10937. * @param target defines the object containing the property
  10938. * @param propertyPath defines the path of the property to set in the target
  10939. * @param value defines the value to set in the property
  10940. * @param condition defines the trigger related conditions
  10941. */
  10942. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10943. /** @hidden */
  10944. _prepare(): void;
  10945. /**
  10946. * Execute the action and set the targetted property to the desired value.
  10947. */
  10948. execute(): void;
  10949. /**
  10950. * Serializes the actions and its related information.
  10951. * @param parent defines the object to serialize in
  10952. * @returns the serialized object
  10953. */
  10954. serialize(parent: any): any;
  10955. }
  10956. /**
  10957. * This defines an action responsible to increment the target value
  10958. * to a desired value once triggered.
  10959. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10960. */
  10961. export class IncrementValueAction extends Action {
  10962. /**
  10963. * The path of the property to increment in the target.
  10964. */
  10965. propertyPath: string;
  10966. /**
  10967. * The value we should increment the property by.
  10968. */
  10969. value: any;
  10970. private _target;
  10971. private _effectiveTarget;
  10972. private _property;
  10973. /**
  10974. * Instantiate the action
  10975. * @param triggerOptions defines the trigger options
  10976. * @param target defines the object containing the property
  10977. * @param propertyPath defines the path of the property to increment in the target
  10978. * @param value defines the value value we should increment the property by
  10979. * @param condition defines the trigger related conditions
  10980. */
  10981. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10982. /** @hidden */
  10983. _prepare(): void;
  10984. /**
  10985. * Execute the action and increment the target of the value amount.
  10986. */
  10987. execute(): void;
  10988. /**
  10989. * Serializes the actions and its related information.
  10990. * @param parent defines the object to serialize in
  10991. * @returns the serialized object
  10992. */
  10993. serialize(parent: any): any;
  10994. }
  10995. /**
  10996. * This defines an action responsible to start an animation once triggered.
  10997. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  10998. */
  10999. export class PlayAnimationAction extends Action {
  11000. /**
  11001. * Where the animation should start (animation frame)
  11002. */
  11003. from: number;
  11004. /**
  11005. * Where the animation should stop (animation frame)
  11006. */
  11007. to: number;
  11008. /**
  11009. * Define if the animation should loop or stop after the first play.
  11010. */
  11011. loop?: boolean;
  11012. private _target;
  11013. /**
  11014. * Instantiate the action
  11015. * @param triggerOptions defines the trigger options
  11016. * @param target defines the target animation or animation name
  11017. * @param from defines from where the animation should start (animation frame)
  11018. * @param end defines where the animation should stop (animation frame)
  11019. * @param loop defines if the animation should loop or stop after the first play
  11020. * @param condition defines the trigger related conditions
  11021. */
  11022. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  11023. /** @hidden */
  11024. _prepare(): void;
  11025. /**
  11026. * Execute the action and play the animation.
  11027. */
  11028. execute(): void;
  11029. /**
  11030. * Serializes the actions and its related information.
  11031. * @param parent defines the object to serialize in
  11032. * @returns the serialized object
  11033. */
  11034. serialize(parent: any): any;
  11035. }
  11036. /**
  11037. * This defines an action responsible to stop an animation once triggered.
  11038. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11039. */
  11040. export class StopAnimationAction extends Action {
  11041. private _target;
  11042. /**
  11043. * Instantiate the action
  11044. * @param triggerOptions defines the trigger options
  11045. * @param target defines the target animation or animation name
  11046. * @param condition defines the trigger related conditions
  11047. */
  11048. constructor(triggerOptions: any, target: any, condition?: Condition);
  11049. /** @hidden */
  11050. _prepare(): void;
  11051. /**
  11052. * Execute the action and stop the animation.
  11053. */
  11054. execute(): void;
  11055. /**
  11056. * Serializes the actions and its related information.
  11057. * @param parent defines the object to serialize in
  11058. * @returns the serialized object
  11059. */
  11060. serialize(parent: any): any;
  11061. }
  11062. /**
  11063. * This defines an action responsible that does nothing once triggered.
  11064. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11065. */
  11066. export class DoNothingAction extends Action {
  11067. /**
  11068. * Instantiate the action
  11069. * @param triggerOptions defines the trigger options
  11070. * @param condition defines the trigger related conditions
  11071. */
  11072. constructor(triggerOptions?: any, condition?: Condition);
  11073. /**
  11074. * Execute the action and do nothing.
  11075. */
  11076. execute(): void;
  11077. /**
  11078. * Serializes the actions and its related information.
  11079. * @param parent defines the object to serialize in
  11080. * @returns the serialized object
  11081. */
  11082. serialize(parent: any): any;
  11083. }
  11084. /**
  11085. * This defines an action responsible to trigger several actions once triggered.
  11086. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11087. */
  11088. export class CombineAction extends Action {
  11089. /**
  11090. * The list of aggregated animations to run.
  11091. */
  11092. children: Action[];
  11093. /**
  11094. * Instantiate the action
  11095. * @param triggerOptions defines the trigger options
  11096. * @param children defines the list of aggregated animations to run
  11097. * @param condition defines the trigger related conditions
  11098. */
  11099. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  11100. /** @hidden */
  11101. _prepare(): void;
  11102. /**
  11103. * Execute the action and executes all the aggregated actions.
  11104. */
  11105. execute(evt: ActionEvent): void;
  11106. /**
  11107. * Serializes the actions and its related information.
  11108. * @param parent defines the object to serialize in
  11109. * @returns the serialized object
  11110. */
  11111. serialize(parent: any): any;
  11112. }
  11113. /**
  11114. * This defines an action responsible to run code (external event) once triggered.
  11115. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11116. */
  11117. export class ExecuteCodeAction extends Action {
  11118. /**
  11119. * The callback function to run.
  11120. */
  11121. func: (evt: ActionEvent) => void;
  11122. /**
  11123. * Instantiate the action
  11124. * @param triggerOptions defines the trigger options
  11125. * @param func defines the callback function to run
  11126. * @param condition defines the trigger related conditions
  11127. */
  11128. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  11129. /**
  11130. * Execute the action and run the attached code.
  11131. */
  11132. execute(evt: ActionEvent): void;
  11133. }
  11134. /**
  11135. * This defines an action responsible to set the parent property of the target once triggered.
  11136. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11137. */
  11138. export class SetParentAction extends Action {
  11139. private _parent;
  11140. private _target;
  11141. /**
  11142. * Instantiate the action
  11143. * @param triggerOptions defines the trigger options
  11144. * @param target defines the target containing the parent property
  11145. * @param parent defines from where the animation should start (animation frame)
  11146. * @param condition defines the trigger related conditions
  11147. */
  11148. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  11149. /** @hidden */
  11150. _prepare(): void;
  11151. /**
  11152. * Execute the action and set the parent property.
  11153. */
  11154. execute(): void;
  11155. /**
  11156. * Serializes the actions and its related information.
  11157. * @param parent defines the object to serialize in
  11158. * @returns the serialized object
  11159. */
  11160. serialize(parent: any): any;
  11161. }
  11162. }
  11163. declare module "babylonjs/Actions/actionManager" {
  11164. import { Nullable } from "babylonjs/types";
  11165. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11166. import { Scene } from "babylonjs/scene";
  11167. import { IAction } from "babylonjs/Actions/action";
  11168. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  11169. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  11170. /**
  11171. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  11172. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  11173. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  11174. */
  11175. export class ActionManager extends AbstractActionManager {
  11176. /**
  11177. * Nothing
  11178. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11179. */
  11180. static readonly NothingTrigger: number;
  11181. /**
  11182. * On pick
  11183. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11184. */
  11185. static readonly OnPickTrigger: number;
  11186. /**
  11187. * On left pick
  11188. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11189. */
  11190. static readonly OnLeftPickTrigger: number;
  11191. /**
  11192. * On right pick
  11193. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11194. */
  11195. static readonly OnRightPickTrigger: number;
  11196. /**
  11197. * On center pick
  11198. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11199. */
  11200. static readonly OnCenterPickTrigger: number;
  11201. /**
  11202. * On pick down
  11203. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11204. */
  11205. static readonly OnPickDownTrigger: number;
  11206. /**
  11207. * On double pick
  11208. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11209. */
  11210. static readonly OnDoublePickTrigger: number;
  11211. /**
  11212. * On pick up
  11213. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11214. */
  11215. static readonly OnPickUpTrigger: number;
  11216. /**
  11217. * On pick out.
  11218. * This trigger will only be raised if you also declared a OnPickDown
  11219. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11220. */
  11221. static readonly OnPickOutTrigger: number;
  11222. /**
  11223. * On long press
  11224. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11225. */
  11226. static readonly OnLongPressTrigger: number;
  11227. /**
  11228. * On pointer over
  11229. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11230. */
  11231. static readonly OnPointerOverTrigger: number;
  11232. /**
  11233. * On pointer out
  11234. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11235. */
  11236. static readonly OnPointerOutTrigger: number;
  11237. /**
  11238. * On every frame
  11239. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11240. */
  11241. static readonly OnEveryFrameTrigger: number;
  11242. /**
  11243. * On intersection enter
  11244. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11245. */
  11246. static readonly OnIntersectionEnterTrigger: number;
  11247. /**
  11248. * On intersection exit
  11249. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11250. */
  11251. static readonly OnIntersectionExitTrigger: number;
  11252. /**
  11253. * On key down
  11254. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11255. */
  11256. static readonly OnKeyDownTrigger: number;
  11257. /**
  11258. * On key up
  11259. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  11260. */
  11261. static readonly OnKeyUpTrigger: number;
  11262. private _scene;
  11263. /**
  11264. * Creates a new action manager
  11265. * @param scene defines the hosting scene
  11266. */
  11267. constructor(scene: Scene);
  11268. /**
  11269. * Releases all associated resources
  11270. */
  11271. dispose(): void;
  11272. /**
  11273. * Gets hosting scene
  11274. * @returns the hosting scene
  11275. */
  11276. getScene(): Scene;
  11277. /**
  11278. * Does this action manager handles actions of any of the given triggers
  11279. * @param triggers defines the triggers to be tested
  11280. * @return a boolean indicating whether one (or more) of the triggers is handled
  11281. */
  11282. hasSpecificTriggers(triggers: number[]): boolean;
  11283. /**
  11284. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  11285. * speed.
  11286. * @param triggerA defines the trigger to be tested
  11287. * @param triggerB defines the trigger to be tested
  11288. * @return a boolean indicating whether one (or more) of the triggers is handled
  11289. */
  11290. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  11291. /**
  11292. * Does this action manager handles actions of a given trigger
  11293. * @param trigger defines the trigger to be tested
  11294. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  11295. * @return whether the trigger is handled
  11296. */
  11297. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  11298. /**
  11299. * Does this action manager has pointer triggers
  11300. */
  11301. readonly hasPointerTriggers: boolean;
  11302. /**
  11303. * Does this action manager has pick triggers
  11304. */
  11305. readonly hasPickTriggers: boolean;
  11306. /**
  11307. * Registers an action to this action manager
  11308. * @param action defines the action to be registered
  11309. * @return the action amended (prepared) after registration
  11310. */
  11311. registerAction(action: IAction): Nullable<IAction>;
  11312. /**
  11313. * Unregisters an action to this action manager
  11314. * @param action defines the action to be unregistered
  11315. * @return a boolean indicating whether the action has been unregistered
  11316. */
  11317. unregisterAction(action: IAction): Boolean;
  11318. /**
  11319. * Process a specific trigger
  11320. * @param trigger defines the trigger to process
  11321. * @param evt defines the event details to be processed
  11322. */
  11323. processTrigger(trigger: number, evt?: IActionEvent): void;
  11324. /** @hidden */
  11325. _getEffectiveTarget(target: any, propertyPath: string): any;
  11326. /** @hidden */
  11327. _getProperty(propertyPath: string): string;
  11328. /**
  11329. * Serialize this manager to a JSON object
  11330. * @param name defines the property name to store this manager
  11331. * @returns a JSON representation of this manager
  11332. */
  11333. serialize(name: string): any;
  11334. /**
  11335. * Creates a new ActionManager from a JSON data
  11336. * @param parsedActions defines the JSON data to read from
  11337. * @param object defines the hosting mesh
  11338. * @param scene defines the hosting scene
  11339. */
  11340. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  11341. /**
  11342. * Get a trigger name by index
  11343. * @param trigger defines the trigger index
  11344. * @returns a trigger name
  11345. */
  11346. static GetTriggerName(trigger: number): string;
  11347. }
  11348. }
  11349. declare module "babylonjs/Culling/ray" {
  11350. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  11351. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  11352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11353. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11354. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  11355. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  11356. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  11357. /**
  11358. * Class representing a ray with position and direction
  11359. */
  11360. export class Ray {
  11361. /** origin point */
  11362. origin: Vector3;
  11363. /** direction */
  11364. direction: Vector3;
  11365. /** length of the ray */
  11366. length: number;
  11367. private static readonly TmpVector3;
  11368. private _tmpRay;
  11369. /**
  11370. * Creates a new ray
  11371. * @param origin origin point
  11372. * @param direction direction
  11373. * @param length length of the ray
  11374. */
  11375. constructor(
  11376. /** origin point */
  11377. origin: Vector3,
  11378. /** direction */
  11379. direction: Vector3,
  11380. /** length of the ray */
  11381. length?: number);
  11382. /**
  11383. * Checks if the ray intersects a box
  11384. * @param minimum bound of the box
  11385. * @param maximum bound of the box
  11386. * @param intersectionTreshold extra extend to be added to the box in all direction
  11387. * @returns if the box was hit
  11388. */
  11389. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  11390. /**
  11391. * Checks if the ray intersects a box
  11392. * @param box the bounding box to check
  11393. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  11394. * @returns if the box was hit
  11395. */
  11396. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  11397. /**
  11398. * If the ray hits a sphere
  11399. * @param sphere the bounding sphere to check
  11400. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  11401. * @returns true if it hits the sphere
  11402. */
  11403. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  11404. /**
  11405. * If the ray hits a triange
  11406. * @param vertex0 triangle vertex
  11407. * @param vertex1 triangle vertex
  11408. * @param vertex2 triangle vertex
  11409. * @returns intersection information if hit
  11410. */
  11411. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  11412. /**
  11413. * Checks if ray intersects a plane
  11414. * @param plane the plane to check
  11415. * @returns the distance away it was hit
  11416. */
  11417. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  11418. /**
  11419. * Checks if ray intersects a mesh
  11420. * @param mesh the mesh to check
  11421. * @param fastCheck if only the bounding box should checked
  11422. * @returns picking info of the intersecton
  11423. */
  11424. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  11425. /**
  11426. * Checks if ray intersects a mesh
  11427. * @param meshes the meshes to check
  11428. * @param fastCheck if only the bounding box should checked
  11429. * @param results array to store result in
  11430. * @returns Array of picking infos
  11431. */
  11432. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  11433. private _comparePickingInfo;
  11434. private static smallnum;
  11435. private static rayl;
  11436. /**
  11437. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  11438. * @param sega the first point of the segment to test the intersection against
  11439. * @param segb the second point of the segment to test the intersection against
  11440. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  11441. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  11442. */
  11443. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  11444. /**
  11445. * Update the ray from viewport position
  11446. * @param x position
  11447. * @param y y position
  11448. * @param viewportWidth viewport width
  11449. * @param viewportHeight viewport height
  11450. * @param world world matrix
  11451. * @param view view matrix
  11452. * @param projection projection matrix
  11453. * @returns this ray updated
  11454. */
  11455. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11456. /**
  11457. * Creates a ray with origin and direction of 0,0,0
  11458. * @returns the new ray
  11459. */
  11460. static Zero(): Ray;
  11461. /**
  11462. * Creates a new ray from screen space and viewport
  11463. * @param x position
  11464. * @param y y position
  11465. * @param viewportWidth viewport width
  11466. * @param viewportHeight viewport height
  11467. * @param world world matrix
  11468. * @param view view matrix
  11469. * @param projection projection matrix
  11470. * @returns new ray
  11471. */
  11472. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  11473. /**
  11474. * 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
  11475. * transformed to the given world matrix.
  11476. * @param origin The origin point
  11477. * @param end The end point
  11478. * @param world a matrix to transform the ray to. Default is the identity matrix.
  11479. * @returns the new ray
  11480. */
  11481. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  11482. /**
  11483. * Transforms a ray by a matrix
  11484. * @param ray ray to transform
  11485. * @param matrix matrix to apply
  11486. * @returns the resulting new ray
  11487. */
  11488. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  11489. /**
  11490. * Transforms a ray by a matrix
  11491. * @param ray ray to transform
  11492. * @param matrix matrix to apply
  11493. * @param result ray to store result in
  11494. */
  11495. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  11496. /**
  11497. * Unproject a ray from screen space to object space
  11498. * @param sourceX defines the screen space x coordinate to use
  11499. * @param sourceY defines the screen space y coordinate to use
  11500. * @param viewportWidth defines the current width of the viewport
  11501. * @param viewportHeight defines the current height of the viewport
  11502. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  11503. * @param view defines the view matrix to use
  11504. * @param projection defines the projection matrix to use
  11505. */
  11506. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  11507. }
  11508. /**
  11509. * Type used to define predicate used to select faces when a mesh intersection is detected
  11510. */
  11511. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  11512. module "babylonjs/scene" {
  11513. interface Scene {
  11514. /** @hidden */
  11515. _tempPickingRay: Nullable<Ray>;
  11516. /** @hidden */
  11517. _cachedRayForTransform: Ray;
  11518. /** @hidden */
  11519. _pickWithRayInverseMatrix: Matrix;
  11520. /** @hidden */
  11521. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  11522. /** @hidden */
  11523. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  11524. }
  11525. }
  11526. }
  11527. declare module "babylonjs/sceneComponent" {
  11528. import { Scene } from "babylonjs/scene";
  11529. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  11530. import { SubMesh } from "babylonjs/Meshes/subMesh";
  11531. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  11532. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  11533. import { Nullable } from "babylonjs/types";
  11534. import { Camera } from "babylonjs/Cameras/camera";
  11535. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  11536. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11537. import { AbstractScene } from "babylonjs/abstractScene";
  11538. /**
  11539. * Groups all the scene component constants in one place to ease maintenance.
  11540. * @hidden
  11541. */
  11542. export class SceneComponentConstants {
  11543. static readonly NAME_EFFECTLAYER: string;
  11544. static readonly NAME_LAYER: string;
  11545. static readonly NAME_LENSFLARESYSTEM: string;
  11546. static readonly NAME_BOUNDINGBOXRENDERER: string;
  11547. static readonly NAME_PARTICLESYSTEM: string;
  11548. static readonly NAME_GAMEPAD: string;
  11549. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  11550. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  11551. static readonly NAME_DEPTHRENDERER: string;
  11552. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  11553. static readonly NAME_SPRITE: string;
  11554. static readonly NAME_OUTLINERENDERER: string;
  11555. static readonly NAME_PROCEDURALTEXTURE: string;
  11556. static readonly NAME_SHADOWGENERATOR: string;
  11557. static readonly NAME_OCTREE: string;
  11558. static readonly NAME_PHYSICSENGINE: string;
  11559. static readonly NAME_AUDIO: string;
  11560. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  11561. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11562. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  11563. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  11564. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  11565. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  11566. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  11567. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  11568. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  11569. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  11570. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  11571. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  11572. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  11573. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  11574. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  11575. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  11576. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  11577. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  11578. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  11579. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  11580. static readonly STEP_AFTERRENDER_AUDIO: number;
  11581. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  11582. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  11583. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  11584. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  11585. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  11586. static readonly STEP_POINTERMOVE_SPRITE: number;
  11587. static readonly STEP_POINTERDOWN_SPRITE: number;
  11588. static readonly STEP_POINTERUP_SPRITE: number;
  11589. }
  11590. /**
  11591. * This represents a scene component.
  11592. *
  11593. * This is used to decouple the dependency the scene is having on the different workloads like
  11594. * layers, post processes...
  11595. */
  11596. export interface ISceneComponent {
  11597. /**
  11598. * The name of the component. Each component must have a unique name.
  11599. */
  11600. name: string;
  11601. /**
  11602. * The scene the component belongs to.
  11603. */
  11604. scene: Scene;
  11605. /**
  11606. * Register the component to one instance of a scene.
  11607. */
  11608. register(): void;
  11609. /**
  11610. * Rebuilds the elements related to this component in case of
  11611. * context lost for instance.
  11612. */
  11613. rebuild(): void;
  11614. /**
  11615. * Disposes the component and the associated ressources.
  11616. */
  11617. dispose(): void;
  11618. }
  11619. /**
  11620. * This represents a SERIALIZABLE scene component.
  11621. *
  11622. * This extends Scene Component to add Serialization methods on top.
  11623. */
  11624. export interface ISceneSerializableComponent extends ISceneComponent {
  11625. /**
  11626. * Adds all the element from the container to the scene
  11627. * @param container the container holding the elements
  11628. */
  11629. addFromContainer(container: AbstractScene): void;
  11630. /**
  11631. * Removes all the elements in the container from the scene
  11632. * @param container contains the elements to remove
  11633. * @param dispose if the removed element should be disposed (default: false)
  11634. */
  11635. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  11636. /**
  11637. * Serializes the component data to the specified json object
  11638. * @param serializationObject The object to serialize to
  11639. */
  11640. serialize(serializationObject: any): void;
  11641. }
  11642. /**
  11643. * Strong typing of a Mesh related stage step action
  11644. */
  11645. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  11646. /**
  11647. * Strong typing of a Evaluate Sub Mesh related stage step action
  11648. */
  11649. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  11650. /**
  11651. * Strong typing of a Active Mesh related stage step action
  11652. */
  11653. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  11654. /**
  11655. * Strong typing of a Camera related stage step action
  11656. */
  11657. export type CameraStageAction = (camera: Camera) => void;
  11658. /**
  11659. * Strong typing of a Camera Frame buffer related stage step action
  11660. */
  11661. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11662. /**
  11663. * Strong typing of a Render Target related stage step action
  11664. */
  11665. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11666. /**
  11667. * Strong typing of a RenderingGroup related stage step action
  11668. */
  11669. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11670. /**
  11671. * Strong typing of a Mesh Render related stage step action
  11672. */
  11673. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11674. /**
  11675. * Strong typing of a simple stage step action
  11676. */
  11677. export type SimpleStageAction = () => void;
  11678. /**
  11679. * Strong typing of a render target action.
  11680. */
  11681. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11682. /**
  11683. * Strong typing of a pointer move action.
  11684. */
  11685. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  11686. /**
  11687. * Strong typing of a pointer up/down action.
  11688. */
  11689. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11690. /**
  11691. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  11692. * @hidden
  11693. */
  11694. export class Stage<T extends Function> extends Array<{
  11695. index: number;
  11696. component: ISceneComponent;
  11697. action: T;
  11698. }> {
  11699. /**
  11700. * Hide ctor from the rest of the world.
  11701. * @param items The items to add.
  11702. */
  11703. private constructor();
  11704. /**
  11705. * Creates a new Stage.
  11706. * @returns A new instance of a Stage
  11707. */
  11708. static Create<T extends Function>(): Stage<T>;
  11709. /**
  11710. * Registers a step in an ordered way in the targeted stage.
  11711. * @param index Defines the position to register the step in
  11712. * @param component Defines the component attached to the step
  11713. * @param action Defines the action to launch during the step
  11714. */
  11715. registerStep(index: number, component: ISceneComponent, action: T): void;
  11716. /**
  11717. * Clears all the steps from the stage.
  11718. */
  11719. clear(): void;
  11720. }
  11721. }
  11722. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11723. import { Nullable } from "babylonjs/types";
  11724. import { Observable } from "babylonjs/Misc/observable";
  11725. import { Scene } from "babylonjs/scene";
  11726. import { Sprite } from "babylonjs/Sprites/sprite";
  11727. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11728. import { Ray } from "babylonjs/Culling/ray";
  11729. import { Camera } from "babylonjs/Cameras/camera";
  11730. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11731. import { ISceneComponent } from "babylonjs/sceneComponent";
  11732. module "babylonjs/scene" {
  11733. interface Scene {
  11734. /** @hidden */
  11735. _pointerOverSprite: Nullable<Sprite>;
  11736. /** @hidden */
  11737. _pickedDownSprite: Nullable<Sprite>;
  11738. /** @hidden */
  11739. _tempSpritePickingRay: Nullable<Ray>;
  11740. /**
  11741. * All of the sprite managers added to this scene
  11742. * @see http://doc.babylonjs.com/babylon101/sprites
  11743. */
  11744. spriteManagers: Array<ISpriteManager>;
  11745. /**
  11746. * An event triggered when sprites rendering is about to start
  11747. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11748. */
  11749. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11750. /**
  11751. * An event triggered when sprites rendering is done
  11752. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11753. */
  11754. onAfterSpritesRenderingObservable: Observable<Scene>;
  11755. /** @hidden */
  11756. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11757. /** Launch a ray to try to pick a sprite in the scene
  11758. * @param x position on screen
  11759. * @param y position on screen
  11760. * @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
  11761. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11762. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11763. * @returns a PickingInfo
  11764. */
  11765. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11766. /** Use the given ray to pick a sprite in the scene
  11767. * @param ray The ray (in world space) to use to pick meshes
  11768. * @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
  11769. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  11770. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11771. * @returns a PickingInfo
  11772. */
  11773. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11774. /**
  11775. * Force the sprite under the pointer
  11776. * @param sprite defines the sprite to use
  11777. */
  11778. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11779. /**
  11780. * Gets the sprite under the pointer
  11781. * @returns a Sprite or null if no sprite is under the pointer
  11782. */
  11783. getPointerOverSprite(): Nullable<Sprite>;
  11784. }
  11785. }
  11786. /**
  11787. * Defines the sprite scene component responsible to manage sprites
  11788. * in a given scene.
  11789. */
  11790. export class SpriteSceneComponent implements ISceneComponent {
  11791. /**
  11792. * The component name helpfull to identify the component in the list of scene components.
  11793. */
  11794. readonly name: string;
  11795. /**
  11796. * The scene the component belongs to.
  11797. */
  11798. scene: Scene;
  11799. /** @hidden */
  11800. private _spritePredicate;
  11801. /**
  11802. * Creates a new instance of the component for the given scene
  11803. * @param scene Defines the scene to register the component in
  11804. */
  11805. constructor(scene: Scene);
  11806. /**
  11807. * Registers the component in a given scene
  11808. */
  11809. register(): void;
  11810. /**
  11811. * Rebuilds the elements related to this component in case of
  11812. * context lost for instance.
  11813. */
  11814. rebuild(): void;
  11815. /**
  11816. * Disposes the component and the associated ressources.
  11817. */
  11818. dispose(): void;
  11819. private _pickSpriteButKeepRay;
  11820. private _pointerMove;
  11821. private _pointerDown;
  11822. private _pointerUp;
  11823. }
  11824. }
  11825. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11826. /** @hidden */
  11827. export var fogFragmentDeclaration: {
  11828. name: string;
  11829. shader: string;
  11830. };
  11831. }
  11832. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11833. /** @hidden */
  11834. export var fogFragment: {
  11835. name: string;
  11836. shader: string;
  11837. };
  11838. }
  11839. declare module "babylonjs/Shaders/sprites.fragment" {
  11840. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11841. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11842. /** @hidden */
  11843. export var spritesPixelShader: {
  11844. name: string;
  11845. shader: string;
  11846. };
  11847. }
  11848. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11849. /** @hidden */
  11850. export var fogVertexDeclaration: {
  11851. name: string;
  11852. shader: string;
  11853. };
  11854. }
  11855. declare module "babylonjs/Shaders/sprites.vertex" {
  11856. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11857. /** @hidden */
  11858. export var spritesVertexShader: {
  11859. name: string;
  11860. shader: string;
  11861. };
  11862. }
  11863. declare module "babylonjs/Sprites/spriteManager" {
  11864. import { IDisposable, Scene } from "babylonjs/scene";
  11865. import { Nullable } from "babylonjs/types";
  11866. import { Observable } from "babylonjs/Misc/observable";
  11867. import { Sprite } from "babylonjs/Sprites/sprite";
  11868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11869. import { Camera } from "babylonjs/Cameras/camera";
  11870. import { Texture } from "babylonjs/Materials/Textures/texture";
  11871. import "babylonjs/Shaders/sprites.fragment";
  11872. import "babylonjs/Shaders/sprites.vertex";
  11873. import { Ray } from "babylonjs/Culling/ray";
  11874. /**
  11875. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11876. */
  11877. export interface ISpriteManager extends IDisposable {
  11878. /**
  11879. * Restricts the camera to viewing objects with the same layerMask.
  11880. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11881. */
  11882. layerMask: number;
  11883. /**
  11884. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11885. */
  11886. isPickable: boolean;
  11887. /**
  11888. * Specifies the rendering group id for this mesh (0 by default)
  11889. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11890. */
  11891. renderingGroupId: number;
  11892. /**
  11893. * Defines the list of sprites managed by the manager.
  11894. */
  11895. sprites: Array<Sprite>;
  11896. /**
  11897. * Tests the intersection of a sprite with a specific ray.
  11898. * @param ray The ray we are sending to test the collision
  11899. * @param camera The camera space we are sending rays in
  11900. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11901. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  11902. * @returns picking info or null.
  11903. */
  11904. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11905. /**
  11906. * Renders the list of sprites on screen.
  11907. */
  11908. render(): void;
  11909. }
  11910. /**
  11911. * Class used to manage multiple sprites on the same spritesheet
  11912. * @see http://doc.babylonjs.com/babylon101/sprites
  11913. */
  11914. export class SpriteManager implements ISpriteManager {
  11915. /** defines the manager's name */
  11916. name: string;
  11917. /** Gets the list of sprites */
  11918. sprites: Sprite[];
  11919. /** Gets or sets the rendering group id (0 by default) */
  11920. renderingGroupId: number;
  11921. /** Gets or sets camera layer mask */
  11922. layerMask: number;
  11923. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11924. fogEnabled: boolean;
  11925. /** Gets or sets a boolean indicating if the sprites are pickable */
  11926. isPickable: boolean;
  11927. /** Defines the default width of a cell in the spritesheet */
  11928. cellWidth: number;
  11929. /** Defines the default height of a cell in the spritesheet */
  11930. cellHeight: number;
  11931. /**
  11932. * An event triggered when the manager is disposed.
  11933. */
  11934. onDisposeObservable: Observable<SpriteManager>;
  11935. private _onDisposeObserver;
  11936. /**
  11937. * Callback called when the manager is disposed
  11938. */
  11939. onDispose: () => void;
  11940. private _capacity;
  11941. private _spriteTexture;
  11942. private _epsilon;
  11943. private _scene;
  11944. private _vertexData;
  11945. private _buffer;
  11946. private _vertexBuffers;
  11947. private _indexBuffer;
  11948. private _effectBase;
  11949. private _effectFog;
  11950. /**
  11951. * Gets or sets the spritesheet texture
  11952. */
  11953. texture: Texture;
  11954. /**
  11955. * Creates a new sprite manager
  11956. * @param name defines the manager's name
  11957. * @param imgUrl defines the sprite sheet url
  11958. * @param capacity defines the maximum allowed number of sprites
  11959. * @param cellSize defines the size of a sprite cell
  11960. * @param scene defines the hosting scene
  11961. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11962. * @param samplingMode defines the smapling mode to use with spritesheet
  11963. */
  11964. constructor(
  11965. /** defines the manager's name */
  11966. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  11967. private _appendSpriteVertex;
  11968. /**
  11969. * Intersects the sprites with a ray
  11970. * @param ray defines the ray to intersect with
  11971. * @param camera defines the current active camera
  11972. * @param predicate defines a predicate used to select candidate sprites
  11973. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11974. * @returns null if no hit or a PickingInfo
  11975. */
  11976. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11977. /**
  11978. * Render all child sprites
  11979. */
  11980. render(): void;
  11981. /**
  11982. * Release associated resources
  11983. */
  11984. dispose(): void;
  11985. }
  11986. }
  11987. declare module "babylonjs/Sprites/sprite" {
  11988. import { Vector3, Color4 } from "babylonjs/Maths/math";
  11989. import { Nullable } from "babylonjs/types";
  11990. import { ActionManager } from "babylonjs/Actions/actionManager";
  11991. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11992. /**
  11993. * Class used to represent a sprite
  11994. * @see http://doc.babylonjs.com/babylon101/sprites
  11995. */
  11996. export class Sprite {
  11997. /** defines the name */
  11998. name: string;
  11999. /** Gets or sets the current world position */
  12000. position: Vector3;
  12001. /** Gets or sets the main color */
  12002. color: Color4;
  12003. /** Gets or sets the width */
  12004. width: number;
  12005. /** Gets or sets the height */
  12006. height: number;
  12007. /** Gets or sets rotation angle */
  12008. angle: number;
  12009. /** Gets or sets the cell index in the sprite sheet */
  12010. cellIndex: number;
  12011. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  12012. invertU: number;
  12013. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  12014. invertV: number;
  12015. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  12016. disposeWhenFinishedAnimating: boolean;
  12017. /** Gets the list of attached animations */
  12018. animations: Animation[];
  12019. /** Gets or sets a boolean indicating if the sprite can be picked */
  12020. isPickable: boolean;
  12021. /**
  12022. * Gets or sets the associated action manager
  12023. */
  12024. actionManager: Nullable<ActionManager>;
  12025. private _animationStarted;
  12026. private _loopAnimation;
  12027. private _fromIndex;
  12028. private _toIndex;
  12029. private _delay;
  12030. private _direction;
  12031. private _manager;
  12032. private _time;
  12033. private _onAnimationEnd;
  12034. /**
  12035. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  12036. */
  12037. isVisible: boolean;
  12038. /**
  12039. * Gets or sets the sprite size
  12040. */
  12041. size: number;
  12042. /**
  12043. * Creates a new Sprite
  12044. * @param name defines the name
  12045. * @param manager defines the manager
  12046. */
  12047. constructor(
  12048. /** defines the name */
  12049. name: string, manager: ISpriteManager);
  12050. /**
  12051. * Starts an animation
  12052. * @param from defines the initial key
  12053. * @param to defines the end key
  12054. * @param loop defines if the animation must loop
  12055. * @param delay defines the start delay (in ms)
  12056. * @param onAnimationEnd defines a callback to call when animation ends
  12057. */
  12058. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  12059. /** Stops current animation (if any) */
  12060. stopAnimation(): void;
  12061. /** @hidden */
  12062. _animate(deltaTime: number): void;
  12063. /** Release associated resources */
  12064. dispose(): void;
  12065. }
  12066. }
  12067. declare module "babylonjs/Collisions/pickingInfo" {
  12068. import { Nullable } from "babylonjs/types";
  12069. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  12070. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12071. import { Sprite } from "babylonjs/Sprites/sprite";
  12072. import { Ray } from "babylonjs/Culling/ray";
  12073. /**
  12074. * Information about the result of picking within a scene
  12075. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  12076. */
  12077. export class PickingInfo {
  12078. /** @hidden */
  12079. _pickingUnavailable: boolean;
  12080. /**
  12081. * If the pick collided with an object
  12082. */
  12083. hit: boolean;
  12084. /**
  12085. * Distance away where the pick collided
  12086. */
  12087. distance: number;
  12088. /**
  12089. * The location of pick collision
  12090. */
  12091. pickedPoint: Nullable<Vector3>;
  12092. /**
  12093. * The mesh corresponding the the pick collision
  12094. */
  12095. pickedMesh: Nullable<AbstractMesh>;
  12096. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  12097. bu: number;
  12098. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  12099. bv: number;
  12100. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  12101. faceId: number;
  12102. /** Id of the the submesh that was picked */
  12103. subMeshId: number;
  12104. /** If a sprite was picked, this will be the sprite the pick collided with */
  12105. pickedSprite: Nullable<Sprite>;
  12106. /**
  12107. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  12108. */
  12109. originMesh: Nullable<AbstractMesh>;
  12110. /**
  12111. * The ray that was used to perform the picking.
  12112. */
  12113. ray: Nullable<Ray>;
  12114. /**
  12115. * Gets the normal correspodning to the face the pick collided with
  12116. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  12117. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  12118. * @returns The normal correspodning to the face the pick collided with
  12119. */
  12120. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  12121. /**
  12122. * Gets the texture coordinates of where the pick occured
  12123. * @returns the vector containing the coordnates of the texture
  12124. */
  12125. getTextureCoordinates(): Nullable<Vector2>;
  12126. }
  12127. }
  12128. declare module "babylonjs/Events/pointerEvents" {
  12129. import { Nullable } from "babylonjs/types";
  12130. import { Vector2 } from "babylonjs/Maths/math";
  12131. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  12132. import { Ray } from "babylonjs/Culling/ray";
  12133. /**
  12134. * Gather the list of pointer event types as constants.
  12135. */
  12136. export class PointerEventTypes {
  12137. /**
  12138. * 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.
  12139. */
  12140. static readonly POINTERDOWN: number;
  12141. /**
  12142. * The pointerup event is fired when a pointer is no longer active.
  12143. */
  12144. static readonly POINTERUP: number;
  12145. /**
  12146. * The pointermove event is fired when a pointer changes coordinates.
  12147. */
  12148. static readonly POINTERMOVE: number;
  12149. /**
  12150. * The pointerwheel event is fired when a mouse wheel has been rotated.
  12151. */
  12152. static readonly POINTERWHEEL: number;
  12153. /**
  12154. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  12155. */
  12156. static readonly POINTERPICK: number;
  12157. /**
  12158. * The pointertap event is fired when a the object has been touched and released without drag.
  12159. */
  12160. static readonly POINTERTAP: number;
  12161. /**
  12162. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  12163. */
  12164. static readonly POINTERDOUBLETAP: number;
  12165. }
  12166. /**
  12167. * Base class of pointer info types.
  12168. */
  12169. export class PointerInfoBase {
  12170. /**
  12171. * Defines the type of event (PointerEventTypes)
  12172. */
  12173. type: number;
  12174. /**
  12175. * Defines the related dom event
  12176. */
  12177. event: PointerEvent | MouseWheelEvent;
  12178. /**
  12179. * Instantiates the base class of pointers info.
  12180. * @param type Defines the type of event (PointerEventTypes)
  12181. * @param event Defines the related dom event
  12182. */
  12183. constructor(
  12184. /**
  12185. * Defines the type of event (PointerEventTypes)
  12186. */
  12187. type: number,
  12188. /**
  12189. * Defines the related dom event
  12190. */
  12191. event: PointerEvent | MouseWheelEvent);
  12192. }
  12193. /**
  12194. * This class is used to store pointer related info for the onPrePointerObservable event.
  12195. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  12196. */
  12197. export class PointerInfoPre extends PointerInfoBase {
  12198. /**
  12199. * Ray from a pointer if availible (eg. 6dof controller)
  12200. */
  12201. ray: Nullable<Ray>;
  12202. /**
  12203. * Defines the local position of the pointer on the canvas.
  12204. */
  12205. localPosition: Vector2;
  12206. /**
  12207. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  12208. */
  12209. skipOnPointerObservable: boolean;
  12210. /**
  12211. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  12212. * @param type Defines the type of event (PointerEventTypes)
  12213. * @param event Defines the related dom event
  12214. * @param localX Defines the local x coordinates of the pointer when the event occured
  12215. * @param localY Defines the local y coordinates of the pointer when the event occured
  12216. */
  12217. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  12218. }
  12219. /**
  12220. * This type contains all the data related to a pointer event in Babylon.js.
  12221. * 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.
  12222. */
  12223. export class PointerInfo extends PointerInfoBase {
  12224. /**
  12225. * Defines the picking info associated to the info (if any)\
  12226. */
  12227. pickInfo: Nullable<PickingInfo>;
  12228. /**
  12229. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  12230. * @param type Defines the type of event (PointerEventTypes)
  12231. * @param event Defines the related dom event
  12232. * @param pickInfo Defines the picking info associated to the info (if any)\
  12233. */
  12234. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  12235. /**
  12236. * Defines the picking info associated to the info (if any)\
  12237. */
  12238. pickInfo: Nullable<PickingInfo>);
  12239. }
  12240. /**
  12241. * Data relating to a touch event on the screen.
  12242. */
  12243. export interface PointerTouch {
  12244. /**
  12245. * X coordinate of touch.
  12246. */
  12247. x: number;
  12248. /**
  12249. * Y coordinate of touch.
  12250. */
  12251. y: number;
  12252. /**
  12253. * Id of touch. Unique for each finger.
  12254. */
  12255. pointerId: number;
  12256. /**
  12257. * Event type passed from DOM.
  12258. */
  12259. type: any;
  12260. }
  12261. }
  12262. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  12263. import { Observable } from "babylonjs/Misc/observable";
  12264. import { Nullable } from "babylonjs/types";
  12265. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12266. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12267. /**
  12268. * Manage the mouse inputs to control the movement of a free camera.
  12269. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12270. */
  12271. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  12272. /**
  12273. * Define if touch is enabled in the mouse input
  12274. */
  12275. touchEnabled: boolean;
  12276. /**
  12277. * Defines the camera the input is attached to.
  12278. */
  12279. camera: FreeCamera;
  12280. /**
  12281. * Defines the buttons associated with the input to handle camera move.
  12282. */
  12283. buttons: number[];
  12284. /**
  12285. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  12286. */
  12287. angularSensibility: number;
  12288. private _pointerInput;
  12289. private _onMouseMove;
  12290. private _observer;
  12291. private previousPosition;
  12292. /**
  12293. * Observable for when a pointer move event occurs containing the move offset
  12294. */
  12295. onPointerMovedObservable: Observable<{
  12296. offsetX: number;
  12297. offsetY: number;
  12298. }>;
  12299. /**
  12300. * @hidden
  12301. * If the camera should be rotated automatically based on pointer movement
  12302. */
  12303. _allowCameraRotation: boolean;
  12304. /**
  12305. * Manage the mouse inputs to control the movement of a free camera.
  12306. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12307. * @param touchEnabled Defines if touch is enabled or not
  12308. */
  12309. constructor(
  12310. /**
  12311. * Define if touch is enabled in the mouse input
  12312. */
  12313. touchEnabled?: boolean);
  12314. /**
  12315. * Attach the input controls to a specific dom element to get the input from.
  12316. * @param element Defines the element the controls should be listened from
  12317. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12318. */
  12319. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12320. /**
  12321. * Called on JS contextmenu event.
  12322. * Override this method to provide functionality.
  12323. */
  12324. protected onContextMenu(evt: PointerEvent): void;
  12325. /**
  12326. * Detach the current controls from the specified dom element.
  12327. * @param element Defines the element to stop listening the inputs from
  12328. */
  12329. detachControl(element: Nullable<HTMLElement>): void;
  12330. /**
  12331. * Gets the class name of the current intput.
  12332. * @returns the class name
  12333. */
  12334. getClassName(): string;
  12335. /**
  12336. * Get the friendly name associated with the input class.
  12337. * @returns the input friendly name
  12338. */
  12339. getSimpleName(): string;
  12340. }
  12341. }
  12342. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  12343. import { Nullable } from "babylonjs/types";
  12344. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  12345. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12346. /**
  12347. * Manage the touch inputs to control the movement of a free camera.
  12348. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12349. */
  12350. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  12351. /**
  12352. * Defines the camera the input is attached to.
  12353. */
  12354. camera: FreeCamera;
  12355. /**
  12356. * Defines the touch sensibility for rotation.
  12357. * The higher the faster.
  12358. */
  12359. touchAngularSensibility: number;
  12360. /**
  12361. * Defines the touch sensibility for move.
  12362. * The higher the faster.
  12363. */
  12364. touchMoveSensibility: number;
  12365. private _offsetX;
  12366. private _offsetY;
  12367. private _pointerPressed;
  12368. private _pointerInput;
  12369. private _observer;
  12370. private _onLostFocus;
  12371. /**
  12372. * Attach the input controls to a specific dom element to get the input from.
  12373. * @param element Defines the element the controls should be listened from
  12374. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12375. */
  12376. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12377. /**
  12378. * Detach the current controls from the specified dom element.
  12379. * @param element Defines the element to stop listening the inputs from
  12380. */
  12381. detachControl(element: Nullable<HTMLElement>): void;
  12382. /**
  12383. * Update the current camera state depending on the inputs that have been used this frame.
  12384. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12385. */
  12386. checkInputs(): void;
  12387. /**
  12388. * Gets the class name of the current intput.
  12389. * @returns the class name
  12390. */
  12391. getClassName(): string;
  12392. /**
  12393. * Get the friendly name associated with the input class.
  12394. * @returns the input friendly name
  12395. */
  12396. getSimpleName(): string;
  12397. }
  12398. }
  12399. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  12400. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  12401. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  12402. import { FreeCameraKeyboardMoveInput } from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  12403. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  12404. import { Nullable } from "babylonjs/types";
  12405. /**
  12406. * Default Inputs manager for the FreeCamera.
  12407. * It groups all the default supported inputs for ease of use.
  12408. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12409. */
  12410. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  12411. /**
  12412. * @hidden
  12413. */
  12414. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  12415. /**
  12416. * @hidden
  12417. */
  12418. _mouseInput: Nullable<FreeCameraMouseInput>;
  12419. /**
  12420. * Instantiates a new FreeCameraInputsManager.
  12421. * @param camera Defines the camera the inputs belong to
  12422. */
  12423. constructor(camera: FreeCamera);
  12424. /**
  12425. * Add keyboard input support to the input manager.
  12426. * @returns the current input manager
  12427. */
  12428. addKeyboard(): FreeCameraInputsManager;
  12429. /**
  12430. * Add mouse input support to the input manager.
  12431. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  12432. * @returns the current input manager
  12433. */
  12434. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  12435. /**
  12436. * Removes the mouse input support from the manager
  12437. * @returns the current input manager
  12438. */
  12439. removeMouse(): FreeCameraInputsManager;
  12440. /**
  12441. * Add touch input support to the input manager.
  12442. * @returns the current input manager
  12443. */
  12444. addTouch(): FreeCameraInputsManager;
  12445. }
  12446. }
  12447. declare module "babylonjs/Cameras/freeCamera" {
  12448. import { Vector3 } from "babylonjs/Maths/math";
  12449. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12450. import { Scene } from "babylonjs/scene";
  12451. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12452. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  12453. /**
  12454. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12455. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  12456. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12457. */
  12458. export class FreeCamera extends TargetCamera {
  12459. /**
  12460. * Define the collision ellipsoid of the camera.
  12461. * This is helpful to simulate a camera body like the player body around the camera
  12462. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  12463. */
  12464. ellipsoid: Vector3;
  12465. /**
  12466. * Define an offset for the position of the ellipsoid around the camera.
  12467. * This can be helpful to determine the center of the body near the gravity center of the body
  12468. * instead of its head.
  12469. */
  12470. ellipsoidOffset: Vector3;
  12471. /**
  12472. * Enable or disable collisions of the camera with the rest of the scene objects.
  12473. */
  12474. checkCollisions: boolean;
  12475. /**
  12476. * Enable or disable gravity on the camera.
  12477. */
  12478. applyGravity: boolean;
  12479. /**
  12480. * Define the input manager associated to the camera.
  12481. */
  12482. inputs: FreeCameraInputsManager;
  12483. /**
  12484. * Gets the input sensibility for a mouse input. (default is 2000.0)
  12485. * Higher values reduce sensitivity.
  12486. */
  12487. /**
  12488. * Sets the input sensibility for a mouse input. (default is 2000.0)
  12489. * Higher values reduce sensitivity.
  12490. */
  12491. angularSensibility: number;
  12492. /**
  12493. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  12494. */
  12495. keysUp: number[];
  12496. /**
  12497. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  12498. */
  12499. keysDown: number[];
  12500. /**
  12501. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  12502. */
  12503. keysLeft: number[];
  12504. /**
  12505. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  12506. */
  12507. keysRight: number[];
  12508. /**
  12509. * Event raised when the camera collide with a mesh in the scene.
  12510. */
  12511. onCollide: (collidedMesh: AbstractMesh) => void;
  12512. private _collider;
  12513. private _needMoveForGravity;
  12514. private _oldPosition;
  12515. private _diffPosition;
  12516. private _newPosition;
  12517. /** @hidden */
  12518. _localDirection: Vector3;
  12519. /** @hidden */
  12520. _transformedDirection: Vector3;
  12521. /**
  12522. * Instantiates a Free Camera.
  12523. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  12524. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  12525. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  12526. * @param name Define the name of the camera in the scene
  12527. * @param position Define the start position of the camera in the scene
  12528. * @param scene Define the scene the camera belongs to
  12529. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  12530. */
  12531. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  12532. /**
  12533. * Attached controls to the current camera.
  12534. * @param element Defines the element the controls should be listened from
  12535. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12536. */
  12537. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  12538. /**
  12539. * Detach the current controls from the camera.
  12540. * The camera will stop reacting to inputs.
  12541. * @param element Defines the element to stop listening the inputs from
  12542. */
  12543. detachControl(element: HTMLElement): void;
  12544. private _collisionMask;
  12545. /**
  12546. * Define a collision mask to limit the list of object the camera can collide with
  12547. */
  12548. collisionMask: number;
  12549. /** @hidden */
  12550. _collideWithWorld(displacement: Vector3): void;
  12551. private _onCollisionPositionChange;
  12552. /** @hidden */
  12553. _checkInputs(): void;
  12554. /** @hidden */
  12555. _decideIfNeedsToMove(): boolean;
  12556. /** @hidden */
  12557. _updatePosition(): void;
  12558. /**
  12559. * Destroy the camera and release the current resources hold by it.
  12560. */
  12561. dispose(): void;
  12562. /**
  12563. * Gets the current object class name.
  12564. * @return the class name
  12565. */
  12566. getClassName(): string;
  12567. }
  12568. }
  12569. declare module "babylonjs/Gamepads/gamepad" {
  12570. import { Observable } from "babylonjs/Misc/observable";
  12571. /**
  12572. * Represents a gamepad control stick position
  12573. */
  12574. export class StickValues {
  12575. /**
  12576. * The x component of the control stick
  12577. */
  12578. x: number;
  12579. /**
  12580. * The y component of the control stick
  12581. */
  12582. y: number;
  12583. /**
  12584. * Initializes the gamepad x and y control stick values
  12585. * @param x The x component of the gamepad control stick value
  12586. * @param y The y component of the gamepad control stick value
  12587. */
  12588. constructor(
  12589. /**
  12590. * The x component of the control stick
  12591. */
  12592. x: number,
  12593. /**
  12594. * The y component of the control stick
  12595. */
  12596. y: number);
  12597. }
  12598. /**
  12599. * An interface which manages callbacks for gamepad button changes
  12600. */
  12601. export interface GamepadButtonChanges {
  12602. /**
  12603. * Called when a gamepad has been changed
  12604. */
  12605. changed: boolean;
  12606. /**
  12607. * Called when a gamepad press event has been triggered
  12608. */
  12609. pressChanged: boolean;
  12610. /**
  12611. * Called when a touch event has been triggered
  12612. */
  12613. touchChanged: boolean;
  12614. /**
  12615. * Called when a value has changed
  12616. */
  12617. valueChanged: boolean;
  12618. }
  12619. /**
  12620. * Represents a gamepad
  12621. */
  12622. export class Gamepad {
  12623. /**
  12624. * The id of the gamepad
  12625. */
  12626. id: string;
  12627. /**
  12628. * The index of the gamepad
  12629. */
  12630. index: number;
  12631. /**
  12632. * The browser gamepad
  12633. */
  12634. browserGamepad: any;
  12635. /**
  12636. * Specifies what type of gamepad this represents
  12637. */
  12638. type: number;
  12639. private _leftStick;
  12640. private _rightStick;
  12641. /** @hidden */
  12642. _isConnected: boolean;
  12643. private _leftStickAxisX;
  12644. private _leftStickAxisY;
  12645. private _rightStickAxisX;
  12646. private _rightStickAxisY;
  12647. /**
  12648. * Triggered when the left control stick has been changed
  12649. */
  12650. private _onleftstickchanged;
  12651. /**
  12652. * Triggered when the right control stick has been changed
  12653. */
  12654. private _onrightstickchanged;
  12655. /**
  12656. * Represents a gamepad controller
  12657. */
  12658. static GAMEPAD: number;
  12659. /**
  12660. * Represents a generic controller
  12661. */
  12662. static GENERIC: number;
  12663. /**
  12664. * Represents an XBox controller
  12665. */
  12666. static XBOX: number;
  12667. /**
  12668. * Represents a pose-enabled controller
  12669. */
  12670. static POSE_ENABLED: number;
  12671. /**
  12672. * Specifies whether the left control stick should be Y-inverted
  12673. */
  12674. protected _invertLeftStickY: boolean;
  12675. /**
  12676. * Specifies if the gamepad has been connected
  12677. */
  12678. readonly isConnected: boolean;
  12679. /**
  12680. * Initializes the gamepad
  12681. * @param id The id of the gamepad
  12682. * @param index The index of the gamepad
  12683. * @param browserGamepad The browser gamepad
  12684. * @param leftStickX The x component of the left joystick
  12685. * @param leftStickY The y component of the left joystick
  12686. * @param rightStickX The x component of the right joystick
  12687. * @param rightStickY The y component of the right joystick
  12688. */
  12689. constructor(
  12690. /**
  12691. * The id of the gamepad
  12692. */
  12693. id: string,
  12694. /**
  12695. * The index of the gamepad
  12696. */
  12697. index: number,
  12698. /**
  12699. * The browser gamepad
  12700. */
  12701. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  12702. /**
  12703. * Callback triggered when the left joystick has changed
  12704. * @param callback
  12705. */
  12706. onleftstickchanged(callback: (values: StickValues) => void): void;
  12707. /**
  12708. * Callback triggered when the right joystick has changed
  12709. * @param callback
  12710. */
  12711. onrightstickchanged(callback: (values: StickValues) => void): void;
  12712. /**
  12713. * Gets the left joystick
  12714. */
  12715. /**
  12716. * Sets the left joystick values
  12717. */
  12718. leftStick: StickValues;
  12719. /**
  12720. * Gets the right joystick
  12721. */
  12722. /**
  12723. * Sets the right joystick value
  12724. */
  12725. rightStick: StickValues;
  12726. /**
  12727. * Updates the gamepad joystick positions
  12728. */
  12729. update(): void;
  12730. /**
  12731. * Disposes the gamepad
  12732. */
  12733. dispose(): void;
  12734. }
  12735. /**
  12736. * Represents a generic gamepad
  12737. */
  12738. export class GenericPad extends Gamepad {
  12739. private _buttons;
  12740. private _onbuttondown;
  12741. private _onbuttonup;
  12742. /**
  12743. * Observable triggered when a button has been pressed
  12744. */
  12745. onButtonDownObservable: Observable<number>;
  12746. /**
  12747. * Observable triggered when a button has been released
  12748. */
  12749. onButtonUpObservable: Observable<number>;
  12750. /**
  12751. * Callback triggered when a button has been pressed
  12752. * @param callback Called when a button has been pressed
  12753. */
  12754. onbuttondown(callback: (buttonPressed: number) => void): void;
  12755. /**
  12756. * Callback triggered when a button has been released
  12757. * @param callback Called when a button has been released
  12758. */
  12759. onbuttonup(callback: (buttonReleased: number) => void): void;
  12760. /**
  12761. * Initializes the generic gamepad
  12762. * @param id The id of the generic gamepad
  12763. * @param index The index of the generic gamepad
  12764. * @param browserGamepad The browser gamepad
  12765. */
  12766. constructor(id: string, index: number, browserGamepad: any);
  12767. private _setButtonValue;
  12768. /**
  12769. * Updates the generic gamepad
  12770. */
  12771. update(): void;
  12772. /**
  12773. * Disposes the generic gamepad
  12774. */
  12775. dispose(): void;
  12776. }
  12777. }
  12778. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  12779. import { Observable } from "babylonjs/Misc/observable";
  12780. import { Nullable } from "babylonjs/types";
  12781. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  12782. import { TransformNode } from "babylonjs/Meshes/transformNode";
  12783. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12784. import { Ray } from "babylonjs/Culling/ray";
  12785. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  12786. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  12787. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  12788. /**
  12789. * Defines the types of pose enabled controllers that are supported
  12790. */
  12791. export enum PoseEnabledControllerType {
  12792. /**
  12793. * HTC Vive
  12794. */
  12795. VIVE = 0,
  12796. /**
  12797. * Oculus Rift
  12798. */
  12799. OCULUS = 1,
  12800. /**
  12801. * Windows mixed reality
  12802. */
  12803. WINDOWS = 2,
  12804. /**
  12805. * Samsung gear VR
  12806. */
  12807. GEAR_VR = 3,
  12808. /**
  12809. * Google Daydream
  12810. */
  12811. DAYDREAM = 4,
  12812. /**
  12813. * Generic
  12814. */
  12815. GENERIC = 5
  12816. }
  12817. /**
  12818. * Defines the MutableGamepadButton interface for the state of a gamepad button
  12819. */
  12820. export interface MutableGamepadButton {
  12821. /**
  12822. * Value of the button/trigger
  12823. */
  12824. value: number;
  12825. /**
  12826. * If the button/trigger is currently touched
  12827. */
  12828. touched: boolean;
  12829. /**
  12830. * If the button/trigger is currently pressed
  12831. */
  12832. pressed: boolean;
  12833. }
  12834. /**
  12835. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  12836. * @hidden
  12837. */
  12838. export interface ExtendedGamepadButton extends GamepadButton {
  12839. /**
  12840. * If the button/trigger is currently pressed
  12841. */
  12842. readonly pressed: boolean;
  12843. /**
  12844. * If the button/trigger is currently touched
  12845. */
  12846. readonly touched: boolean;
  12847. /**
  12848. * Value of the button/trigger
  12849. */
  12850. readonly value: number;
  12851. }
  12852. /** @hidden */
  12853. export interface _GamePadFactory {
  12854. /**
  12855. * Returns wether or not the current gamepad can be created for this type of controller.
  12856. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12857. * @returns true if it can be created, otherwise false
  12858. */
  12859. canCreate(gamepadInfo: any): boolean;
  12860. /**
  12861. * Creates a new instance of the Gamepad.
  12862. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  12863. * @returns the new gamepad instance
  12864. */
  12865. create(gamepadInfo: any): Gamepad;
  12866. }
  12867. /**
  12868. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12869. */
  12870. export class PoseEnabledControllerHelper {
  12871. /** @hidden */
  12872. static _ControllerFactories: _GamePadFactory[];
  12873. /** @hidden */
  12874. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  12875. /**
  12876. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  12877. * @param vrGamepad the gamepad to initialized
  12878. * @returns a vr controller of the type the gamepad identified as
  12879. */
  12880. static InitiateController(vrGamepad: any): Gamepad;
  12881. }
  12882. /**
  12883. * Defines the PoseEnabledController object that contains state of a vr capable controller
  12884. */
  12885. export class PoseEnabledController extends Gamepad implements PoseControlled {
  12886. private _deviceRoomPosition;
  12887. private _deviceRoomRotationQuaternion;
  12888. /**
  12889. * The device position in babylon space
  12890. */
  12891. devicePosition: Vector3;
  12892. /**
  12893. * The device rotation in babylon space
  12894. */
  12895. deviceRotationQuaternion: Quaternion;
  12896. /**
  12897. * The scale factor of the device in babylon space
  12898. */
  12899. deviceScaleFactor: number;
  12900. /**
  12901. * (Likely devicePosition should be used instead) The device position in its room space
  12902. */
  12903. position: Vector3;
  12904. /**
  12905. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  12906. */
  12907. rotationQuaternion: Quaternion;
  12908. /**
  12909. * The type of controller (Eg. Windows mixed reality)
  12910. */
  12911. controllerType: PoseEnabledControllerType;
  12912. protected _calculatedPosition: Vector3;
  12913. private _calculatedRotation;
  12914. /**
  12915. * The raw pose from the device
  12916. */
  12917. rawPose: DevicePose;
  12918. private _trackPosition;
  12919. private _maxRotationDistFromHeadset;
  12920. private _draggedRoomRotation;
  12921. /**
  12922. * @hidden
  12923. */
  12924. _disableTrackPosition(fixedPosition: Vector3): void;
  12925. /**
  12926. * Internal, the mesh attached to the controller
  12927. * @hidden
  12928. */
  12929. _mesh: Nullable<AbstractMesh>;
  12930. private _poseControlledCamera;
  12931. private _leftHandSystemQuaternion;
  12932. /**
  12933. * Internal, matrix used to convert room space to babylon space
  12934. * @hidden
  12935. */
  12936. _deviceToWorld: Matrix;
  12937. /**
  12938. * Node to be used when casting a ray from the controller
  12939. * @hidden
  12940. */
  12941. _pointingPoseNode: Nullable<TransformNode>;
  12942. /**
  12943. * Name of the child mesh that can be used to cast a ray from the controller
  12944. */
  12945. static readonly POINTING_POSE: string;
  12946. /**
  12947. * Creates a new PoseEnabledController from a gamepad
  12948. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  12949. */
  12950. constructor(browserGamepad: any);
  12951. private _workingMatrix;
  12952. /**
  12953. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  12954. */
  12955. update(): void;
  12956. /**
  12957. * Updates only the pose device and mesh without doing any button event checking
  12958. */
  12959. protected _updatePoseAndMesh(): void;
  12960. /**
  12961. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  12962. * @param poseData raw pose fromthe device
  12963. */
  12964. updateFromDevice(poseData: DevicePose): void;
  12965. /**
  12966. * @hidden
  12967. */
  12968. _meshAttachedObservable: Observable<AbstractMesh>;
  12969. /**
  12970. * Attaches a mesh to the controller
  12971. * @param mesh the mesh to be attached
  12972. */
  12973. attachToMesh(mesh: AbstractMesh): void;
  12974. /**
  12975. * Attaches the controllers mesh to a camera
  12976. * @param camera the camera the mesh should be attached to
  12977. */
  12978. attachToPoseControlledCamera(camera: TargetCamera): void;
  12979. /**
  12980. * Disposes of the controller
  12981. */
  12982. dispose(): void;
  12983. /**
  12984. * The mesh that is attached to the controller
  12985. */
  12986. readonly mesh: Nullable<AbstractMesh>;
  12987. /**
  12988. * Gets the ray of the controller in the direction the controller is pointing
  12989. * @param length the length the resulting ray should be
  12990. * @returns a ray in the direction the controller is pointing
  12991. */
  12992. getForwardRay(length?: number): Ray;
  12993. }
  12994. }
  12995. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  12996. import { Observable } from "babylonjs/Misc/observable";
  12997. import { Scene } from "babylonjs/scene";
  12998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12999. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  13000. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  13001. /**
  13002. * Defines the WebVRController object that represents controllers tracked in 3D space
  13003. */
  13004. export abstract class WebVRController extends PoseEnabledController {
  13005. /**
  13006. * Internal, the default controller model for the controller
  13007. */
  13008. protected _defaultModel: AbstractMesh;
  13009. /**
  13010. * Fired when the trigger state has changed
  13011. */
  13012. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  13013. /**
  13014. * Fired when the main button state has changed
  13015. */
  13016. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13017. /**
  13018. * Fired when the secondary button state has changed
  13019. */
  13020. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  13021. /**
  13022. * Fired when the pad state has changed
  13023. */
  13024. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  13025. /**
  13026. * Fired when controllers stick values have changed
  13027. */
  13028. onPadValuesChangedObservable: Observable<StickValues>;
  13029. /**
  13030. * Array of button availible on the controller
  13031. */
  13032. protected _buttons: Array<MutableGamepadButton>;
  13033. private _onButtonStateChange;
  13034. /**
  13035. * Fired when a controller button's state has changed
  13036. * @param callback the callback containing the button that was modified
  13037. */
  13038. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  13039. /**
  13040. * X and Y axis corrisponding to the controllers joystick
  13041. */
  13042. pad: StickValues;
  13043. /**
  13044. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  13045. */
  13046. hand: string;
  13047. /**
  13048. * The default controller model for the controller
  13049. */
  13050. readonly defaultModel: AbstractMesh;
  13051. /**
  13052. * Creates a new WebVRController from a gamepad
  13053. * @param vrGamepad the gamepad that the WebVRController should be created from
  13054. */
  13055. constructor(vrGamepad: any);
  13056. /**
  13057. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  13058. */
  13059. update(): void;
  13060. /**
  13061. * Function to be called when a button is modified
  13062. */
  13063. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  13064. /**
  13065. * Loads a mesh and attaches it to the controller
  13066. * @param scene the scene the mesh should be added to
  13067. * @param meshLoaded callback for when the mesh has been loaded
  13068. */
  13069. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  13070. private _setButtonValue;
  13071. private _changes;
  13072. private _checkChanges;
  13073. /**
  13074. * Disposes of th webVRCOntroller
  13075. */
  13076. dispose(): void;
  13077. }
  13078. }
  13079. declare module "babylonjs/Lights/hemisphericLight" {
  13080. import { Nullable } from "babylonjs/types";
  13081. import { Scene } from "babylonjs/scene";
  13082. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  13083. import { Effect } from "babylonjs/Materials/effect";
  13084. import { Light } from "babylonjs/Lights/light";
  13085. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  13086. /**
  13087. * The HemisphericLight simulates the ambient environment light,
  13088. * so the passed direction is the light reflection direction, not the incoming direction.
  13089. */
  13090. export class HemisphericLight extends Light {
  13091. /**
  13092. * The groundColor is the light in the opposite direction to the one specified during creation.
  13093. * 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.
  13094. */
  13095. groundColor: Color3;
  13096. /**
  13097. * The light reflection direction, not the incoming direction.
  13098. */
  13099. direction: Vector3;
  13100. /**
  13101. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  13102. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  13103. * The HemisphericLight can't cast shadows.
  13104. * Documentation : https://doc.babylonjs.com/babylon101/lights
  13105. * @param name The friendly name of the light
  13106. * @param direction The direction of the light reflection
  13107. * @param scene The scene the light belongs to
  13108. */
  13109. constructor(name: string, direction: Vector3, scene: Scene);
  13110. protected _buildUniformLayout(): void;
  13111. /**
  13112. * Returns the string "HemisphericLight".
  13113. * @return The class name
  13114. */
  13115. getClassName(): string;
  13116. /**
  13117. * Sets the HemisphericLight direction towards the passed target (Vector3).
  13118. * Returns the updated direction.
  13119. * @param target The target the direction should point to
  13120. * @return The computed direction
  13121. */
  13122. setDirectionToTarget(target: Vector3): Vector3;
  13123. /**
  13124. * Returns the shadow generator associated to the light.
  13125. * @returns Always null for hemispheric lights because it does not support shadows.
  13126. */
  13127. getShadowGenerator(): Nullable<IShadowGenerator>;
  13128. /**
  13129. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  13130. * @param effect The effect to update
  13131. * @param lightIndex The index of the light in the effect to update
  13132. * @returns The hemispheric light
  13133. */
  13134. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  13135. /**
  13136. * Computes the world matrix of the node
  13137. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  13138. * @param useWasUpdatedFlag defines a reserved property
  13139. * @returns the world matrix
  13140. */
  13141. computeWorldMatrix(): Matrix;
  13142. /**
  13143. * Returns the integer 3.
  13144. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  13145. */
  13146. getTypeID(): number;
  13147. /**
  13148. * Prepares the list of defines specific to the light type.
  13149. * @param defines the list of defines
  13150. * @param lightIndex defines the index of the light for the effect
  13151. */
  13152. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  13153. }
  13154. }
  13155. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  13156. /** @hidden */
  13157. export var vrMultiviewToSingleviewPixelShader: {
  13158. name: string;
  13159. shader: string;
  13160. };
  13161. }
  13162. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  13163. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13164. import { Scene } from "babylonjs/scene";
  13165. /**
  13166. * Renders to multiple views with a single draw call
  13167. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  13168. */
  13169. export class MultiviewRenderTarget extends RenderTargetTexture {
  13170. /**
  13171. * Creates a multiview render target
  13172. * @param scene scene used with the render target
  13173. * @param size the size of the render target (used for each view)
  13174. */
  13175. constructor(scene: Scene, size?: number | {
  13176. width: number;
  13177. height: number;
  13178. } | {
  13179. ratio: number;
  13180. });
  13181. /**
  13182. * @hidden
  13183. * @param faceIndex the face index, if its a cube texture
  13184. */
  13185. _bindFrameBuffer(faceIndex?: number): void;
  13186. /**
  13187. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  13188. * @returns the view count
  13189. */
  13190. getViewCount(): number;
  13191. }
  13192. }
  13193. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  13194. import { Camera } from "babylonjs/Cameras/camera";
  13195. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13196. import { Nullable } from "babylonjs/types";
  13197. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  13198. import { Matrix } from "babylonjs/Maths/math";
  13199. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  13200. module "babylonjs/Engines/engine" {
  13201. interface Engine {
  13202. /**
  13203. * Creates a new multiview render target
  13204. * @param width defines the width of the texture
  13205. * @param height defines the height of the texture
  13206. * @returns the created multiview texture
  13207. */
  13208. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  13209. /**
  13210. * Binds a multiview framebuffer to be drawn to
  13211. * @param multiviewTexture texture to bind
  13212. */
  13213. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  13214. }
  13215. }
  13216. module "babylonjs/Cameras/camera" {
  13217. interface Camera {
  13218. /**
  13219. * @hidden
  13220. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13221. */
  13222. _useMultiviewToSingleView: boolean;
  13223. /**
  13224. * @hidden
  13225. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  13226. */
  13227. _multiviewTexture: Nullable<RenderTargetTexture>;
  13228. /**
  13229. * @hidden
  13230. * ensures the multiview texture of the camera exists and has the specified width/height
  13231. * @param width height to set on the multiview texture
  13232. * @param height width to set on the multiview texture
  13233. */
  13234. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  13235. }
  13236. }
  13237. module "babylonjs/scene" {
  13238. interface Scene {
  13239. /** @hidden */
  13240. _transformMatrixR: Matrix;
  13241. /** @hidden */
  13242. _multiviewSceneUbo: Nullable<UniformBuffer>;
  13243. /** @hidden */
  13244. _createMultiviewUbo(): void;
  13245. /** @hidden */
  13246. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  13247. /** @hidden */
  13248. _renderMultiviewToSingleView(camera: Camera): void;
  13249. }
  13250. }
  13251. }
  13252. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  13253. import { Camera } from "babylonjs/Cameras/camera";
  13254. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13255. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  13256. import "babylonjs/Engines/Extensions/engine.multiview";
  13257. /**
  13258. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  13259. * This will not be used for webXR as it supports displaying texture arrays directly
  13260. */
  13261. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  13262. /**
  13263. * Initializes a VRMultiviewToSingleview
  13264. * @param name name of the post process
  13265. * @param camera camera to be applied to
  13266. * @param scaleFactor scaling factor to the size of the output texture
  13267. */
  13268. constructor(name: string, camera: Camera, scaleFactor: number);
  13269. }
  13270. }
  13271. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  13272. declare module "babylonjs/Cameras/VR/webVRCamera" {
  13273. import { Nullable } from "babylonjs/types";
  13274. import { Observable } from "babylonjs/Misc/observable";
  13275. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  13276. import { Scene } from "babylonjs/scene";
  13277. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  13278. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  13279. import { Node } from "babylonjs/node";
  13280. import { Ray } from "babylonjs/Culling/ray";
  13281. import "babylonjs/Cameras/RigModes/webVRRigMode";
  13282. /**
  13283. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  13284. * IMPORTANT!! The data is right-hand data.
  13285. * @export
  13286. * @interface DevicePose
  13287. */
  13288. export interface DevicePose {
  13289. /**
  13290. * The position of the device, values in array are [x,y,z].
  13291. */
  13292. readonly position: Nullable<Float32Array>;
  13293. /**
  13294. * The linearVelocity of the device, values in array are [x,y,z].
  13295. */
  13296. readonly linearVelocity: Nullable<Float32Array>;
  13297. /**
  13298. * The linearAcceleration of the device, values in array are [x,y,z].
  13299. */
  13300. readonly linearAcceleration: Nullable<Float32Array>;
  13301. /**
  13302. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  13303. */
  13304. readonly orientation: Nullable<Float32Array>;
  13305. /**
  13306. * The angularVelocity of the device, values in array are [x,y,z].
  13307. */
  13308. readonly angularVelocity: Nullable<Float32Array>;
  13309. /**
  13310. * The angularAcceleration of the device, values in array are [x,y,z].
  13311. */
  13312. readonly angularAcceleration: Nullable<Float32Array>;
  13313. }
  13314. /**
  13315. * Interface representing a pose controlled object in Babylon.
  13316. * A pose controlled object has both regular pose values as well as pose values
  13317. * from an external device such as a VR head mounted display
  13318. */
  13319. export interface PoseControlled {
  13320. /**
  13321. * The position of the object in babylon space.
  13322. */
  13323. position: Vector3;
  13324. /**
  13325. * The rotation quaternion of the object in babylon space.
  13326. */
  13327. rotationQuaternion: Quaternion;
  13328. /**
  13329. * The position of the device in babylon space.
  13330. */
  13331. devicePosition?: Vector3;
  13332. /**
  13333. * The rotation quaternion of the device in babylon space.
  13334. */
  13335. deviceRotationQuaternion: Quaternion;
  13336. /**
  13337. * The raw pose coming from the device.
  13338. */
  13339. rawPose: Nullable<DevicePose>;
  13340. /**
  13341. * The scale of the device to be used when translating from device space to babylon space.
  13342. */
  13343. deviceScaleFactor: number;
  13344. /**
  13345. * Updates the poseControlled values based on the input device pose.
  13346. * @param poseData the pose data to update the object with
  13347. */
  13348. updateFromDevice(poseData: DevicePose): void;
  13349. }
  13350. /**
  13351. * Set of options to customize the webVRCamera
  13352. */
  13353. export interface WebVROptions {
  13354. /**
  13355. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  13356. */
  13357. trackPosition?: boolean;
  13358. /**
  13359. * Sets the scale of the vrDevice in babylon space. (default: 1)
  13360. */
  13361. positionScale?: number;
  13362. /**
  13363. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  13364. */
  13365. displayName?: string;
  13366. /**
  13367. * Should the native controller meshes be initialized. (default: true)
  13368. */
  13369. controllerMeshes?: boolean;
  13370. /**
  13371. * Creating a default HemiLight only on controllers. (default: true)
  13372. */
  13373. defaultLightingOnControllers?: boolean;
  13374. /**
  13375. * If you don't want to use the default VR button of the helper. (default: false)
  13376. */
  13377. useCustomVRButton?: boolean;
  13378. /**
  13379. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  13380. */
  13381. customVRButton?: HTMLButtonElement;
  13382. /**
  13383. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  13384. */
  13385. rayLength?: number;
  13386. /**
  13387. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  13388. */
  13389. defaultHeight?: number;
  13390. /**
  13391. * If multiview should be used if availible (default: false)
  13392. */
  13393. useMultiview?: boolean;
  13394. }
  13395. /**
  13396. * This represents a WebVR camera.
  13397. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  13398. * @example http://doc.babylonjs.com/how_to/webvr_camera
  13399. */
  13400. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  13401. private webVROptions;
  13402. /**
  13403. * @hidden
  13404. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  13405. */
  13406. _vrDevice: any;
  13407. /**
  13408. * The rawPose of the vrDevice.
  13409. */
  13410. rawPose: Nullable<DevicePose>;
  13411. private _onVREnabled;
  13412. private _specsVersion;
  13413. private _attached;
  13414. private _frameData;
  13415. protected _descendants: Array<Node>;
  13416. private _deviceRoomPosition;
  13417. /** @hidden */
  13418. _deviceRoomRotationQuaternion: Quaternion;
  13419. private _standingMatrix;
  13420. /**
  13421. * Represents device position in babylon space.
  13422. */
  13423. devicePosition: Vector3;
  13424. /**
  13425. * Represents device rotation in babylon space.
  13426. */
  13427. deviceRotationQuaternion: Quaternion;
  13428. /**
  13429. * The scale of the device to be used when translating from device space to babylon space.
  13430. */
  13431. deviceScaleFactor: number;
  13432. private _deviceToWorld;
  13433. private _worldToDevice;
  13434. /**
  13435. * References to the webVR controllers for the vrDevice.
  13436. */
  13437. controllers: Array<WebVRController>;
  13438. /**
  13439. * Emits an event when a controller is attached.
  13440. */
  13441. onControllersAttachedObservable: Observable<WebVRController[]>;
  13442. /**
  13443. * Emits an event when a controller's mesh has been loaded;
  13444. */
  13445. onControllerMeshLoadedObservable: Observable<WebVRController>;
  13446. /**
  13447. * Emits an event when the HMD's pose has been updated.
  13448. */
  13449. onPoseUpdatedFromDeviceObservable: Observable<any>;
  13450. private _poseSet;
  13451. /**
  13452. * If the rig cameras be used as parent instead of this camera.
  13453. */
  13454. rigParenting: boolean;
  13455. private _lightOnControllers;
  13456. private _defaultHeight?;
  13457. /**
  13458. * Instantiates a WebVRFreeCamera.
  13459. * @param name The name of the WebVRFreeCamera
  13460. * @param position The starting anchor position for the camera
  13461. * @param scene The scene the camera belongs to
  13462. * @param webVROptions a set of customizable options for the webVRCamera
  13463. */
  13464. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  13465. /**
  13466. * Gets the device distance from the ground in meters.
  13467. * @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.
  13468. */
  13469. deviceDistanceToRoomGround(): number;
  13470. /**
  13471. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13472. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  13473. */
  13474. useStandingMatrix(callback?: (bool: boolean) => void): void;
  13475. /**
  13476. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  13477. * @returns A promise with a boolean set to if the standing matrix is supported.
  13478. */
  13479. useStandingMatrixAsync(): Promise<boolean>;
  13480. /**
  13481. * Disposes the camera
  13482. */
  13483. dispose(): void;
  13484. /**
  13485. * Gets a vrController by name.
  13486. * @param name The name of the controller to retreive
  13487. * @returns the controller matching the name specified or null if not found
  13488. */
  13489. getControllerByName(name: string): Nullable<WebVRController>;
  13490. private _leftController;
  13491. /**
  13492. * The controller corrisponding to the users left hand.
  13493. */
  13494. readonly leftController: Nullable<WebVRController>;
  13495. private _rightController;
  13496. /**
  13497. * The controller corrisponding to the users right hand.
  13498. */
  13499. readonly rightController: Nullable<WebVRController>;
  13500. /**
  13501. * Casts a ray forward from the vrCamera's gaze.
  13502. * @param length Length of the ray (default: 100)
  13503. * @returns the ray corrisponding to the gaze
  13504. */
  13505. getForwardRay(length?: number): Ray;
  13506. /**
  13507. * @hidden
  13508. * Updates the camera based on device's frame data
  13509. */
  13510. _checkInputs(): void;
  13511. /**
  13512. * Updates the poseControlled values based on the input device pose.
  13513. * @param poseData Pose coming from the device
  13514. */
  13515. updateFromDevice(poseData: DevicePose): void;
  13516. private _htmlElementAttached;
  13517. private _detachIfAttached;
  13518. /**
  13519. * WebVR's attach control will start broadcasting frames to the device.
  13520. * Note that in certain browsers (chrome for example) this function must be called
  13521. * within a user-interaction callback. Example:
  13522. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  13523. *
  13524. * @param element html element to attach the vrDevice to
  13525. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  13526. */
  13527. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  13528. /**
  13529. * Detaches the camera from the html element and disables VR
  13530. *
  13531. * @param element html element to detach from
  13532. */
  13533. detachControl(element: HTMLElement): void;
  13534. /**
  13535. * @returns the name of this class
  13536. */
  13537. getClassName(): string;
  13538. /**
  13539. * Calls resetPose on the vrDisplay
  13540. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  13541. */
  13542. resetToCurrentRotation(): void;
  13543. /**
  13544. * @hidden
  13545. * Updates the rig cameras (left and right eye)
  13546. */
  13547. _updateRigCameras(): void;
  13548. private _workingVector;
  13549. private _oneVector;
  13550. private _workingMatrix;
  13551. private updateCacheCalled;
  13552. private _correctPositionIfNotTrackPosition;
  13553. /**
  13554. * @hidden
  13555. * Updates the cached values of the camera
  13556. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  13557. */
  13558. _updateCache(ignoreParentClass?: boolean): void;
  13559. /**
  13560. * @hidden
  13561. * Get current device position in babylon world
  13562. */
  13563. _computeDevicePosition(): void;
  13564. /**
  13565. * Updates the current device position and rotation in the babylon world
  13566. */
  13567. update(): void;
  13568. /**
  13569. * @hidden
  13570. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  13571. * @returns an identity matrix
  13572. */
  13573. _getViewMatrix(): Matrix;
  13574. private _tmpMatrix;
  13575. /**
  13576. * This function is called by the two RIG cameras.
  13577. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  13578. * @hidden
  13579. */
  13580. _getWebVRViewMatrix(): Matrix;
  13581. /** @hidden */
  13582. _getWebVRProjectionMatrix(): Matrix;
  13583. private _onGamepadConnectedObserver;
  13584. private _onGamepadDisconnectedObserver;
  13585. private _updateCacheWhenTrackingDisabledObserver;
  13586. /**
  13587. * Initializes the controllers and their meshes
  13588. */
  13589. initControllers(): void;
  13590. }
  13591. }
  13592. declare module "babylonjs/PostProcesses/postProcess" {
  13593. import { Nullable } from "babylonjs/types";
  13594. import { SmartArray } from "babylonjs/Misc/smartArray";
  13595. import { Observable } from "babylonjs/Misc/observable";
  13596. import { Color4, Vector2 } from "babylonjs/Maths/math";
  13597. import { Camera } from "babylonjs/Cameras/camera";
  13598. import { Effect } from "babylonjs/Materials/effect";
  13599. import "babylonjs/Shaders/postprocess.vertex";
  13600. import { IInspectable } from "babylonjs/Misc/iInspectable";
  13601. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13602. import { Engine } from "babylonjs/Engines/engine";
  13603. /**
  13604. * Size options for a post process
  13605. */
  13606. export type PostProcessOptions = {
  13607. width: number;
  13608. height: number;
  13609. };
  13610. /**
  13611. * PostProcess can be used to apply a shader to a texture after it has been rendered
  13612. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13613. */
  13614. export class PostProcess {
  13615. /** Name of the PostProcess. */
  13616. name: string;
  13617. /**
  13618. * Gets or sets the unique id of the post process
  13619. */
  13620. uniqueId: number;
  13621. /**
  13622. * Width of the texture to apply the post process on
  13623. */
  13624. width: number;
  13625. /**
  13626. * Height of the texture to apply the post process on
  13627. */
  13628. height: number;
  13629. /**
  13630. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  13631. * @hidden
  13632. */
  13633. _outputTexture: Nullable<InternalTexture>;
  13634. /**
  13635. * Sampling mode used by the shader
  13636. * See https://doc.babylonjs.com/classes/3.1/texture
  13637. */
  13638. renderTargetSamplingMode: number;
  13639. /**
  13640. * Clear color to use when screen clearing
  13641. */
  13642. clearColor: Color4;
  13643. /**
  13644. * If the buffer needs to be cleared before applying the post process. (default: true)
  13645. * Should be set to false if shader will overwrite all previous pixels.
  13646. */
  13647. autoClear: boolean;
  13648. /**
  13649. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  13650. */
  13651. alphaMode: number;
  13652. /**
  13653. * Sets the setAlphaBlendConstants of the babylon engine
  13654. */
  13655. alphaConstants: Color4;
  13656. /**
  13657. * Animations to be used for the post processing
  13658. */
  13659. animations: import("babylonjs/Animations/animation").Animation[];
  13660. /**
  13661. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  13662. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  13663. */
  13664. enablePixelPerfectMode: boolean;
  13665. /**
  13666. * Force the postprocess to be applied without taking in account viewport
  13667. */
  13668. forceFullscreenViewport: boolean;
  13669. /**
  13670. * List of inspectable custom properties (used by the Inspector)
  13671. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  13672. */
  13673. inspectableCustomProperties: IInspectable[];
  13674. /**
  13675. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  13676. *
  13677. * | Value | Type | Description |
  13678. * | ----- | ----------------------------------- | ----------- |
  13679. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  13680. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  13681. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  13682. *
  13683. */
  13684. scaleMode: number;
  13685. /**
  13686. * Force textures to be a power of two (default: false)
  13687. */
  13688. alwaysForcePOT: boolean;
  13689. private _samples;
  13690. /**
  13691. * Number of sample textures (default: 1)
  13692. */
  13693. samples: number;
  13694. /**
  13695. * Modify the scale of the post process to be the same as the viewport (default: false)
  13696. */
  13697. adaptScaleToCurrentViewport: boolean;
  13698. private _camera;
  13699. private _scene;
  13700. private _engine;
  13701. private _options;
  13702. private _reusable;
  13703. private _textureType;
  13704. /**
  13705. * Smart array of input and output textures for the post process.
  13706. * @hidden
  13707. */
  13708. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  13709. /**
  13710. * The index in _textures that corresponds to the output texture.
  13711. * @hidden
  13712. */
  13713. _currentRenderTextureInd: number;
  13714. private _effect;
  13715. private _samplers;
  13716. private _fragmentUrl;
  13717. private _vertexUrl;
  13718. private _parameters;
  13719. private _scaleRatio;
  13720. protected _indexParameters: any;
  13721. private _shareOutputWithPostProcess;
  13722. private _texelSize;
  13723. private _forcedOutputTexture;
  13724. /**
  13725. * Returns the fragment url or shader name used in the post process.
  13726. * @returns the fragment url or name in the shader store.
  13727. */
  13728. getEffectName(): string;
  13729. /**
  13730. * An event triggered when the postprocess is activated.
  13731. */
  13732. onActivateObservable: Observable<Camera>;
  13733. private _onActivateObserver;
  13734. /**
  13735. * A function that is added to the onActivateObservable
  13736. */
  13737. onActivate: Nullable<(camera: Camera) => void>;
  13738. /**
  13739. * An event triggered when the postprocess changes its size.
  13740. */
  13741. onSizeChangedObservable: Observable<PostProcess>;
  13742. private _onSizeChangedObserver;
  13743. /**
  13744. * A function that is added to the onSizeChangedObservable
  13745. */
  13746. onSizeChanged: (postProcess: PostProcess) => void;
  13747. /**
  13748. * An event triggered when the postprocess applies its effect.
  13749. */
  13750. onApplyObservable: Observable<Effect>;
  13751. private _onApplyObserver;
  13752. /**
  13753. * A function that is added to the onApplyObservable
  13754. */
  13755. onApply: (effect: Effect) => void;
  13756. /**
  13757. * An event triggered before rendering the postprocess
  13758. */
  13759. onBeforeRenderObservable: Observable<Effect>;
  13760. private _onBeforeRenderObserver;
  13761. /**
  13762. * A function that is added to the onBeforeRenderObservable
  13763. */
  13764. onBeforeRender: (effect: Effect) => void;
  13765. /**
  13766. * An event triggered after rendering the postprocess
  13767. */
  13768. onAfterRenderObservable: Observable<Effect>;
  13769. private _onAfterRenderObserver;
  13770. /**
  13771. * A function that is added to the onAfterRenderObservable
  13772. */
  13773. onAfterRender: (efect: Effect) => void;
  13774. /**
  13775. * 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
  13776. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  13777. */
  13778. inputTexture: InternalTexture;
  13779. /**
  13780. * Gets the camera which post process is applied to.
  13781. * @returns The camera the post process is applied to.
  13782. */
  13783. getCamera(): Camera;
  13784. /**
  13785. * Gets the texel size of the postprocess.
  13786. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  13787. */
  13788. readonly texelSize: Vector2;
  13789. /**
  13790. * Creates a new instance PostProcess
  13791. * @param name The name of the PostProcess.
  13792. * @param fragmentUrl The url of the fragment shader to be used.
  13793. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  13794. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  13795. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  13796. * @param camera The camera to apply the render pass to.
  13797. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  13798. * @param engine The engine which the post process will be applied. (default: current engine)
  13799. * @param reusable If the post process can be reused on the same frame. (default: false)
  13800. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  13801. * @param textureType Type of textures used when performing the post process. (default: 0)
  13802. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  13803. * @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
  13804. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  13805. */
  13806. constructor(
  13807. /** Name of the PostProcess. */
  13808. 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);
  13809. /**
  13810. * Gets a string idenfifying the name of the class
  13811. * @returns "PostProcess" string
  13812. */
  13813. getClassName(): string;
  13814. /**
  13815. * Gets the engine which this post process belongs to.
  13816. * @returns The engine the post process was enabled with.
  13817. */
  13818. getEngine(): Engine;
  13819. /**
  13820. * The effect that is created when initializing the post process.
  13821. * @returns The created effect corrisponding the the postprocess.
  13822. */
  13823. getEffect(): Effect;
  13824. /**
  13825. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  13826. * @param postProcess The post process to share the output with.
  13827. * @returns This post process.
  13828. */
  13829. shareOutputWith(postProcess: PostProcess): PostProcess;
  13830. /**
  13831. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  13832. * This should be called if the post process that shares output with this post process is disabled/disposed.
  13833. */
  13834. useOwnOutput(): void;
  13835. /**
  13836. * Updates the effect with the current post process compile time values and recompiles the shader.
  13837. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  13838. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  13839. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  13840. * @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
  13841. * @param onCompiled Called when the shader has been compiled.
  13842. * @param onError Called if there is an error when compiling a shader.
  13843. */
  13844. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  13845. /**
  13846. * The post process is reusable if it can be used multiple times within one frame.
  13847. * @returns If the post process is reusable
  13848. */
  13849. isReusable(): boolean;
  13850. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  13851. markTextureDirty(): void;
  13852. /**
  13853. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  13854. * 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.
  13855. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  13856. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  13857. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  13858. * @returns The target texture that was bound to be written to.
  13859. */
  13860. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  13861. /**
  13862. * If the post process is supported.
  13863. */
  13864. readonly isSupported: boolean;
  13865. /**
  13866. * The aspect ratio of the output texture.
  13867. */
  13868. readonly aspectRatio: number;
  13869. /**
  13870. * Get a value indicating if the post-process is ready to be used
  13871. * @returns true if the post-process is ready (shader is compiled)
  13872. */
  13873. isReady(): boolean;
  13874. /**
  13875. * Binds all textures and uniforms to the shader, this will be run on every pass.
  13876. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  13877. */
  13878. apply(): Nullable<Effect>;
  13879. private _disposeTextures;
  13880. /**
  13881. * Disposes the post process.
  13882. * @param camera The camera to dispose the post process on.
  13883. */
  13884. dispose(camera?: Camera): void;
  13885. }
  13886. }
  13887. declare module "babylonjs/PostProcesses/postProcessManager" {
  13888. import { Nullable } from "babylonjs/types";
  13889. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  13890. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  13891. import { Scene } from "babylonjs/scene";
  13892. /**
  13893. * PostProcessManager is used to manage one or more post processes or post process pipelines
  13894. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  13895. */
  13896. export class PostProcessManager {
  13897. private _scene;
  13898. private _indexBuffer;
  13899. private _vertexBuffers;
  13900. /**
  13901. * Creates a new instance PostProcess
  13902. * @param scene The scene that the post process is associated with.
  13903. */
  13904. constructor(scene: Scene);
  13905. private _prepareBuffers;
  13906. private _buildIndexBuffer;
  13907. /**
  13908. * Rebuilds the vertex buffers of the manager.
  13909. * @hidden
  13910. */
  13911. _rebuild(): void;
  13912. /**
  13913. * Prepares a frame to be run through a post process.
  13914. * @param sourceTexture The input texture to the post procesess. (default: null)
  13915. * @param postProcesses An array of post processes to be run. (default: null)
  13916. * @returns True if the post processes were able to be run.
  13917. * @hidden
  13918. */
  13919. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  13920. /**
  13921. * Manually render a set of post processes to a texture.
  13922. * @param postProcesses An array of post processes to be run.
  13923. * @param targetTexture The target texture to render to.
  13924. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  13925. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  13926. * @param lodLevel defines which lod of the texture to render to
  13927. */
  13928. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  13929. /**
  13930. * Finalize the result of the output of the postprocesses.
  13931. * @param doNotPresent If true the result will not be displayed to the screen.
  13932. * @param targetTexture The target texture to render to.
  13933. * @param faceIndex The index of the face to bind the target texture to.
  13934. * @param postProcesses The array of post processes to render.
  13935. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  13936. * @hidden
  13937. */
  13938. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  13939. /**
  13940. * Disposes of the post process manager.
  13941. */
  13942. dispose(): void;
  13943. }
  13944. }
  13945. declare module "babylonjs/Layers/layerSceneComponent" {
  13946. import { Scene } from "babylonjs/scene";
  13947. import { ISceneComponent } from "babylonjs/sceneComponent";
  13948. import { Layer } from "babylonjs/Layers/layer";
  13949. module "babylonjs/abstractScene" {
  13950. interface AbstractScene {
  13951. /**
  13952. * The list of layers (background and foreground) of the scene
  13953. */
  13954. layers: Array<Layer>;
  13955. }
  13956. }
  13957. /**
  13958. * Defines the layer scene component responsible to manage any layers
  13959. * in a given scene.
  13960. */
  13961. export class LayerSceneComponent implements ISceneComponent {
  13962. /**
  13963. * The component name helpfull to identify the component in the list of scene components.
  13964. */
  13965. readonly name: string;
  13966. /**
  13967. * The scene the component belongs to.
  13968. */
  13969. scene: Scene;
  13970. private _engine;
  13971. /**
  13972. * Creates a new instance of the component for the given scene
  13973. * @param scene Defines the scene to register the component in
  13974. */
  13975. constructor(scene: Scene);
  13976. /**
  13977. * Registers the component in a given scene
  13978. */
  13979. register(): void;
  13980. /**
  13981. * Rebuilds the elements related to this component in case of
  13982. * context lost for instance.
  13983. */
  13984. rebuild(): void;
  13985. /**
  13986. * Disposes the component and the associated ressources.
  13987. */
  13988. dispose(): void;
  13989. private _draw;
  13990. private _drawCameraPredicate;
  13991. private _drawCameraBackground;
  13992. private _drawCameraForeground;
  13993. private _drawRenderTargetPredicate;
  13994. private _drawRenderTargetBackground;
  13995. private _drawRenderTargetForeground;
  13996. }
  13997. }
  13998. declare module "babylonjs/Shaders/layer.fragment" {
  13999. /** @hidden */
  14000. export var layerPixelShader: {
  14001. name: string;
  14002. shader: string;
  14003. };
  14004. }
  14005. declare module "babylonjs/Shaders/layer.vertex" {
  14006. /** @hidden */
  14007. export var layerVertexShader: {
  14008. name: string;
  14009. shader: string;
  14010. };
  14011. }
  14012. declare module "babylonjs/Layers/layer" {
  14013. import { Observable } from "babylonjs/Misc/observable";
  14014. import { Nullable } from "babylonjs/types";
  14015. import { Scene } from "babylonjs/scene";
  14016. import { Vector2, Color4 } from "babylonjs/Maths/math";
  14017. import { Texture } from "babylonjs/Materials/Textures/texture";
  14018. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  14019. import "babylonjs/Shaders/layer.fragment";
  14020. import "babylonjs/Shaders/layer.vertex";
  14021. /**
  14022. * This represents a full screen 2d layer.
  14023. * This can be useful to display a picture in the background of your scene for instance.
  14024. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14025. */
  14026. export class Layer {
  14027. /**
  14028. * Define the name of the layer.
  14029. */
  14030. name: string;
  14031. /**
  14032. * Define the texture the layer should display.
  14033. */
  14034. texture: Nullable<Texture>;
  14035. /**
  14036. * Is the layer in background or foreground.
  14037. */
  14038. isBackground: boolean;
  14039. /**
  14040. * Define the color of the layer (instead of texture).
  14041. */
  14042. color: Color4;
  14043. /**
  14044. * Define the scale of the layer in order to zoom in out of the texture.
  14045. */
  14046. scale: Vector2;
  14047. /**
  14048. * Define an offset for the layer in order to shift the texture.
  14049. */
  14050. offset: Vector2;
  14051. /**
  14052. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  14053. */
  14054. alphaBlendingMode: number;
  14055. /**
  14056. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  14057. * Alpha test will not mix with the background color in case of transparency.
  14058. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  14059. */
  14060. alphaTest: boolean;
  14061. /**
  14062. * Define a mask to restrict the layer to only some of the scene cameras.
  14063. */
  14064. layerMask: number;
  14065. /**
  14066. * Define the list of render target the layer is visible into.
  14067. */
  14068. renderTargetTextures: RenderTargetTexture[];
  14069. /**
  14070. * Define if the layer is only used in renderTarget or if it also
  14071. * renders in the main frame buffer of the canvas.
  14072. */
  14073. renderOnlyInRenderTargetTextures: boolean;
  14074. private _scene;
  14075. private _vertexBuffers;
  14076. private _indexBuffer;
  14077. private _effect;
  14078. private _alphaTestEffect;
  14079. /**
  14080. * An event triggered when the layer is disposed.
  14081. */
  14082. onDisposeObservable: Observable<Layer>;
  14083. private _onDisposeObserver;
  14084. /**
  14085. * Back compatibility with callback before the onDisposeObservable existed.
  14086. * The set callback will be triggered when the layer has been disposed.
  14087. */
  14088. onDispose: () => void;
  14089. /**
  14090. * An event triggered before rendering the scene
  14091. */
  14092. onBeforeRenderObservable: Observable<Layer>;
  14093. private _onBeforeRenderObserver;
  14094. /**
  14095. * Back compatibility with callback before the onBeforeRenderObservable existed.
  14096. * The set callback will be triggered just before rendering the layer.
  14097. */
  14098. onBeforeRender: () => void;
  14099. /**
  14100. * An event triggered after rendering the scene
  14101. */
  14102. onAfterRenderObservable: Observable<Layer>;
  14103. private _onAfterRenderObserver;
  14104. /**
  14105. * Back compatibility with callback before the onAfterRenderObservable existed.
  14106. * The set callback will be triggered just after rendering the layer.
  14107. */
  14108. onAfterRender: () => void;
  14109. /**
  14110. * Instantiates a new layer.
  14111. * This represents a full screen 2d layer.
  14112. * This can be useful to display a picture in the background of your scene for instance.
  14113. * @see https://www.babylonjs-playground.com/#08A2BS#1
  14114. * @param name Define the name of the layer in the scene
  14115. * @param imgUrl Define the url of the texture to display in the layer
  14116. * @param scene Define the scene the layer belongs to
  14117. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  14118. * @param color Defines a color for the layer
  14119. */
  14120. constructor(
  14121. /**
  14122. * Define the name of the layer.
  14123. */
  14124. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  14125. private _createIndexBuffer;
  14126. /** @hidden */
  14127. _rebuild(): void;
  14128. /**
  14129. * Renders the layer in the scene.
  14130. */
  14131. render(): void;
  14132. /**
  14133. * Disposes and releases the associated ressources.
  14134. */
  14135. dispose(): void;
  14136. }
  14137. }
  14138. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  14139. import { Scene } from "babylonjs/scene";
  14140. import { ISceneComponent } from "babylonjs/sceneComponent";
  14141. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14142. module "babylonjs/abstractScene" {
  14143. interface AbstractScene {
  14144. /**
  14145. * The list of procedural textures added to the scene
  14146. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14147. */
  14148. proceduralTextures: Array<ProceduralTexture>;
  14149. }
  14150. }
  14151. /**
  14152. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  14153. * in a given scene.
  14154. */
  14155. export class ProceduralTextureSceneComponent implements ISceneComponent {
  14156. /**
  14157. * The component name helpfull to identify the component in the list of scene components.
  14158. */
  14159. readonly name: string;
  14160. /**
  14161. * The scene the component belongs to.
  14162. */
  14163. scene: Scene;
  14164. /**
  14165. * Creates a new instance of the component for the given scene
  14166. * @param scene Defines the scene to register the component in
  14167. */
  14168. constructor(scene: Scene);
  14169. /**
  14170. * Registers the component in a given scene
  14171. */
  14172. register(): void;
  14173. /**
  14174. * Rebuilds the elements related to this component in case of
  14175. * context lost for instance.
  14176. */
  14177. rebuild(): void;
  14178. /**
  14179. * Disposes the component and the associated ressources.
  14180. */
  14181. dispose(): void;
  14182. private _beforeClear;
  14183. }
  14184. }
  14185. declare module "babylonjs/Shaders/procedural.vertex" {
  14186. /** @hidden */
  14187. export var proceduralVertexShader: {
  14188. name: string;
  14189. shader: string;
  14190. };
  14191. }
  14192. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  14193. import { Observable } from "babylonjs/Misc/observable";
  14194. import { Nullable } from "babylonjs/types";
  14195. import { Scene } from "babylonjs/scene";
  14196. import { Matrix, Vector3, Vector2, Color3, Color4 } from "babylonjs/Maths/math";
  14197. import { Effect } from "babylonjs/Materials/effect";
  14198. import { Texture } from "babylonjs/Materials/Textures/texture";
  14199. import "babylonjs/Shaders/procedural.vertex";
  14200. /**
  14201. * 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.
  14202. * This is the base class of any Procedural texture and contains most of the shareable code.
  14203. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14204. */
  14205. export class ProceduralTexture extends Texture {
  14206. isCube: boolean;
  14207. /**
  14208. * Define if the texture is enabled or not (disabled texture will not render)
  14209. */
  14210. isEnabled: boolean;
  14211. /**
  14212. * Define if the texture must be cleared before rendering (default is true)
  14213. */
  14214. autoClear: boolean;
  14215. /**
  14216. * Callback called when the texture is generated
  14217. */
  14218. onGenerated: () => void;
  14219. /**
  14220. * Event raised when the texture is generated
  14221. */
  14222. onGeneratedObservable: Observable<ProceduralTexture>;
  14223. /** @hidden */
  14224. _generateMipMaps: boolean;
  14225. /** @hidden **/
  14226. _effect: Effect;
  14227. /** @hidden */
  14228. _textures: {
  14229. [key: string]: Texture;
  14230. };
  14231. private _size;
  14232. private _currentRefreshId;
  14233. private _refreshRate;
  14234. private _vertexBuffers;
  14235. private _indexBuffer;
  14236. private _uniforms;
  14237. private _samplers;
  14238. private _fragment;
  14239. private _floats;
  14240. private _ints;
  14241. private _floatsArrays;
  14242. private _colors3;
  14243. private _colors4;
  14244. private _vectors2;
  14245. private _vectors3;
  14246. private _matrices;
  14247. private _fallbackTexture;
  14248. private _fallbackTextureUsed;
  14249. private _engine;
  14250. private _cachedDefines;
  14251. private _contentUpdateId;
  14252. private _contentData;
  14253. /**
  14254. * Instantiates a new procedural texture.
  14255. * 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.
  14256. * This is the base class of any Procedural texture and contains most of the shareable code.
  14257. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  14258. * @param name Define the name of the texture
  14259. * @param size Define the size of the texture to create
  14260. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  14261. * @param scene Define the scene the texture belongs to
  14262. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  14263. * @param generateMipMaps Define if the texture should creates mip maps or not
  14264. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  14265. */
  14266. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  14267. /**
  14268. * The effect that is created when initializing the post process.
  14269. * @returns The created effect corrisponding the the postprocess.
  14270. */
  14271. getEffect(): Effect;
  14272. /**
  14273. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  14274. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  14275. */
  14276. getContent(): Nullable<ArrayBufferView>;
  14277. private _createIndexBuffer;
  14278. /** @hidden */
  14279. _rebuild(): void;
  14280. /**
  14281. * Resets the texture in order to recreate its associated resources.
  14282. * This can be called in case of context loss
  14283. */
  14284. reset(): void;
  14285. protected _getDefines(): string;
  14286. /**
  14287. * Is the texture ready to be used ? (rendered at least once)
  14288. * @returns true if ready, otherwise, false.
  14289. */
  14290. isReady(): boolean;
  14291. /**
  14292. * Resets the refresh counter of the texture and start bak from scratch.
  14293. * Could be useful to regenerate the texture if it is setup to render only once.
  14294. */
  14295. resetRefreshCounter(): void;
  14296. /**
  14297. * Set the fragment shader to use in order to render the texture.
  14298. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  14299. */
  14300. setFragment(fragment: any): void;
  14301. /**
  14302. * Define the refresh rate of the texture or the rendering frequency.
  14303. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  14304. */
  14305. refreshRate: number;
  14306. /** @hidden */
  14307. _shouldRender(): boolean;
  14308. /**
  14309. * Get the size the texture is rendering at.
  14310. * @returns the size (texture is always squared)
  14311. */
  14312. getRenderSize(): number;
  14313. /**
  14314. * Resize the texture to new value.
  14315. * @param size Define the new size the texture should have
  14316. * @param generateMipMaps Define whether the new texture should create mip maps
  14317. */
  14318. resize(size: number, generateMipMaps: boolean): void;
  14319. private _checkUniform;
  14320. /**
  14321. * Set a texture in the shader program used to render.
  14322. * @param name Define the name of the uniform samplers as defined in the shader
  14323. * @param texture Define the texture to bind to this sampler
  14324. * @return the texture itself allowing "fluent" like uniform updates
  14325. */
  14326. setTexture(name: string, texture: Texture): ProceduralTexture;
  14327. /**
  14328. * Set a float in the shader.
  14329. * @param name Define the name of the uniform as defined in the shader
  14330. * @param value Define the value to give to the uniform
  14331. * @return the texture itself allowing "fluent" like uniform updates
  14332. */
  14333. setFloat(name: string, value: number): ProceduralTexture;
  14334. /**
  14335. * Set a int in the shader.
  14336. * @param name Define the name of the uniform as defined in the shader
  14337. * @param value Define the value to give to the uniform
  14338. * @return the texture itself allowing "fluent" like uniform updates
  14339. */
  14340. setInt(name: string, value: number): ProceduralTexture;
  14341. /**
  14342. * Set an array of floats in the shader.
  14343. * @param name Define the name of the uniform as defined in the shader
  14344. * @param value Define the value to give to the uniform
  14345. * @return the texture itself allowing "fluent" like uniform updates
  14346. */
  14347. setFloats(name: string, value: number[]): ProceduralTexture;
  14348. /**
  14349. * Set a vec3 in the shader from a Color3.
  14350. * @param name Define the name of the uniform as defined in the shader
  14351. * @param value Define the value to give to the uniform
  14352. * @return the texture itself allowing "fluent" like uniform updates
  14353. */
  14354. setColor3(name: string, value: Color3): ProceduralTexture;
  14355. /**
  14356. * Set a vec4 in the shader from a Color4.
  14357. * @param name Define the name of the uniform as defined in the shader
  14358. * @param value Define the value to give to the uniform
  14359. * @return the texture itself allowing "fluent" like uniform updates
  14360. */
  14361. setColor4(name: string, value: Color4): ProceduralTexture;
  14362. /**
  14363. * Set a vec2 in the shader from a Vector2.
  14364. * @param name Define the name of the uniform as defined in the shader
  14365. * @param value Define the value to give to the uniform
  14366. * @return the texture itself allowing "fluent" like uniform updates
  14367. */
  14368. setVector2(name: string, value: Vector2): ProceduralTexture;
  14369. /**
  14370. * Set a vec3 in the shader from a Vector3.
  14371. * @param name Define the name of the uniform as defined in the shader
  14372. * @param value Define the value to give to the uniform
  14373. * @return the texture itself allowing "fluent" like uniform updates
  14374. */
  14375. setVector3(name: string, value: Vector3): ProceduralTexture;
  14376. /**
  14377. * Set a mat4 in the shader from a MAtrix.
  14378. * @param name Define the name of the uniform as defined in the shader
  14379. * @param value Define the value to give to the uniform
  14380. * @return the texture itself allowing "fluent" like uniform updates
  14381. */
  14382. setMatrix(name: string, value: Matrix): ProceduralTexture;
  14383. /**
  14384. * Render the texture to its associated render target.
  14385. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  14386. */
  14387. render(useCameraPostProcess?: boolean): void;
  14388. /**
  14389. * Clone the texture.
  14390. * @returns the cloned texture
  14391. */
  14392. clone(): ProceduralTexture;
  14393. /**
  14394. * Dispose the texture and release its asoociated resources.
  14395. */
  14396. dispose(): void;
  14397. }
  14398. }
  14399. declare module "babylonjs/Particles/baseParticleSystem" {
  14400. import { Nullable } from "babylonjs/types";
  14401. import { Color4, Vector2, Vector3 } from "babylonjs/Maths/math";
  14402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14403. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  14404. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  14405. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  14406. import { Scene } from "babylonjs/scene";
  14407. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/tools";
  14408. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14409. import { Texture } from "babylonjs/Materials/Textures/texture";
  14410. import { Animation } from "babylonjs/Animations/animation";
  14411. /**
  14412. * This represents the base class for particle system in Babylon.
  14413. * 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.
  14414. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  14415. * @example https://doc.babylonjs.com/babylon101/particles
  14416. */
  14417. export class BaseParticleSystem {
  14418. /**
  14419. * Source color is added to the destination color without alpha affecting the result
  14420. */
  14421. static BLENDMODE_ONEONE: number;
  14422. /**
  14423. * Blend current color and particle color using particle’s alpha
  14424. */
  14425. static BLENDMODE_STANDARD: number;
  14426. /**
  14427. * Add current color and particle color multiplied by particle’s alpha
  14428. */
  14429. static BLENDMODE_ADD: number;
  14430. /**
  14431. * Multiply current color with particle color
  14432. */
  14433. static BLENDMODE_MULTIPLY: number;
  14434. /**
  14435. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  14436. */
  14437. static BLENDMODE_MULTIPLYADD: number;
  14438. /**
  14439. * List of animations used by the particle system.
  14440. */
  14441. animations: Animation[];
  14442. /**
  14443. * The id of the Particle system.
  14444. */
  14445. id: string;
  14446. /**
  14447. * The friendly name of the Particle system.
  14448. */
  14449. name: string;
  14450. /**
  14451. * The rendering group used by the Particle system to chose when to render.
  14452. */
  14453. renderingGroupId: number;
  14454. /**
  14455. * The emitter represents the Mesh or position we are attaching the particle system to.
  14456. */
  14457. emitter: Nullable<AbstractMesh | Vector3>;
  14458. /**
  14459. * The maximum number of particles to emit per frame
  14460. */
  14461. emitRate: number;
  14462. /**
  14463. * If you want to launch only a few particles at once, that can be done, as well.
  14464. */
  14465. manualEmitCount: number;
  14466. /**
  14467. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14468. */
  14469. updateSpeed: number;
  14470. /**
  14471. * The amount of time the particle system is running (depends of the overall update speed).
  14472. */
  14473. targetStopDuration: number;
  14474. /**
  14475. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14476. */
  14477. disposeOnStop: boolean;
  14478. /**
  14479. * Minimum power of emitting particles.
  14480. */
  14481. minEmitPower: number;
  14482. /**
  14483. * Maximum power of emitting particles.
  14484. */
  14485. maxEmitPower: number;
  14486. /**
  14487. * Minimum life time of emitting particles.
  14488. */
  14489. minLifeTime: number;
  14490. /**
  14491. * Maximum life time of emitting particles.
  14492. */
  14493. maxLifeTime: number;
  14494. /**
  14495. * Minimum Size of emitting particles.
  14496. */
  14497. minSize: number;
  14498. /**
  14499. * Maximum Size of emitting particles.
  14500. */
  14501. maxSize: number;
  14502. /**
  14503. * Minimum scale of emitting particles on X axis.
  14504. */
  14505. minScaleX: number;
  14506. /**
  14507. * Maximum scale of emitting particles on X axis.
  14508. */
  14509. maxScaleX: number;
  14510. /**
  14511. * Minimum scale of emitting particles on Y axis.
  14512. */
  14513. minScaleY: number;
  14514. /**
  14515. * Maximum scale of emitting particles on Y axis.
  14516. */
  14517. maxScaleY: number;
  14518. /**
  14519. * Gets or sets the minimal initial rotation in radians.
  14520. */
  14521. minInitialRotation: number;
  14522. /**
  14523. * Gets or sets the maximal initial rotation in radians.
  14524. */
  14525. maxInitialRotation: number;
  14526. /**
  14527. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14528. */
  14529. minAngularSpeed: number;
  14530. /**
  14531. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14532. */
  14533. maxAngularSpeed: number;
  14534. /**
  14535. * The texture used to render each particle. (this can be a spritesheet)
  14536. */
  14537. particleTexture: Nullable<Texture>;
  14538. /**
  14539. * The layer mask we are rendering the particles through.
  14540. */
  14541. layerMask: number;
  14542. /**
  14543. * This can help using your own shader to render the particle system.
  14544. * The according effect will be created
  14545. */
  14546. customShader: any;
  14547. /**
  14548. * By default particle system starts as soon as they are created. This prevents the
  14549. * automatic start to happen and let you decide when to start emitting particles.
  14550. */
  14551. preventAutoStart: boolean;
  14552. private _noiseTexture;
  14553. /**
  14554. * Gets or sets a texture used to add random noise to particle positions
  14555. */
  14556. noiseTexture: Nullable<ProceduralTexture>;
  14557. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14558. noiseStrength: Vector3;
  14559. /**
  14560. * Callback triggered when the particle animation is ending.
  14561. */
  14562. onAnimationEnd: Nullable<() => void>;
  14563. /**
  14564. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  14565. */
  14566. blendMode: number;
  14567. /**
  14568. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  14569. * to override the particles.
  14570. */
  14571. forceDepthWrite: boolean;
  14572. /** 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 */
  14573. preWarmCycles: number;
  14574. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  14575. preWarmStepOffset: number;
  14576. /**
  14577. * 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)
  14578. */
  14579. spriteCellChangeSpeed: number;
  14580. /**
  14581. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14582. */
  14583. startSpriteCellID: number;
  14584. /**
  14585. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14586. */
  14587. endSpriteCellID: number;
  14588. /**
  14589. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14590. */
  14591. spriteCellWidth: number;
  14592. /**
  14593. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14594. */
  14595. spriteCellHeight: number;
  14596. /**
  14597. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14598. */
  14599. spriteRandomStartCell: boolean;
  14600. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14601. translationPivot: Vector2;
  14602. /** @hidden */
  14603. protected _isAnimationSheetEnabled: boolean;
  14604. /**
  14605. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14606. */
  14607. beginAnimationOnStart: boolean;
  14608. /**
  14609. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14610. */
  14611. beginAnimationFrom: number;
  14612. /**
  14613. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14614. */
  14615. beginAnimationTo: number;
  14616. /**
  14617. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14618. */
  14619. beginAnimationLoop: boolean;
  14620. /**
  14621. * Gets or sets a world offset applied to all particles
  14622. */
  14623. worldOffset: Vector3;
  14624. /**
  14625. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  14626. */
  14627. isAnimationSheetEnabled: boolean;
  14628. /**
  14629. * Get hosting scene
  14630. * @returns the scene
  14631. */
  14632. getScene(): Scene;
  14633. /**
  14634. * You can use gravity if you want to give an orientation to your particles.
  14635. */
  14636. gravity: Vector3;
  14637. protected _colorGradients: Nullable<Array<ColorGradient>>;
  14638. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  14639. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  14640. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  14641. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  14642. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  14643. protected _dragGradients: Nullable<Array<FactorGradient>>;
  14644. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  14645. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  14646. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  14647. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  14648. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  14649. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  14650. /**
  14651. * Defines the delay in milliseconds before starting the system (0 by default)
  14652. */
  14653. startDelay: number;
  14654. /**
  14655. * Gets the current list of drag gradients.
  14656. * You must use addDragGradient and removeDragGradient to udpate this list
  14657. * @returns the list of drag gradients
  14658. */
  14659. getDragGradients(): Nullable<Array<FactorGradient>>;
  14660. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14661. limitVelocityDamping: number;
  14662. /**
  14663. * Gets the current list of limit velocity gradients.
  14664. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14665. * @returns the list of limit velocity gradients
  14666. */
  14667. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14668. /**
  14669. * Gets the current list of color gradients.
  14670. * You must use addColorGradient and removeColorGradient to udpate this list
  14671. * @returns the list of color gradients
  14672. */
  14673. getColorGradients(): Nullable<Array<ColorGradient>>;
  14674. /**
  14675. * Gets the current list of size gradients.
  14676. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14677. * @returns the list of size gradients
  14678. */
  14679. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14680. /**
  14681. * Gets the current list of color remap gradients.
  14682. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14683. * @returns the list of color remap gradients
  14684. */
  14685. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14686. /**
  14687. * Gets the current list of alpha remap gradients.
  14688. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14689. * @returns the list of alpha remap gradients
  14690. */
  14691. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14692. /**
  14693. * Gets the current list of life time gradients.
  14694. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14695. * @returns the list of life time gradients
  14696. */
  14697. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14698. /**
  14699. * Gets the current list of angular speed gradients.
  14700. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14701. * @returns the list of angular speed gradients
  14702. */
  14703. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14704. /**
  14705. * Gets the current list of velocity gradients.
  14706. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14707. * @returns the list of velocity gradients
  14708. */
  14709. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14710. /**
  14711. * Gets the current list of start size gradients.
  14712. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14713. * @returns the list of start size gradients
  14714. */
  14715. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14716. /**
  14717. * Gets the current list of emit rate gradients.
  14718. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14719. * @returns the list of emit rate gradients
  14720. */
  14721. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14722. /**
  14723. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14724. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14725. */
  14726. direction1: Vector3;
  14727. /**
  14728. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14729. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14730. */
  14731. direction2: Vector3;
  14732. /**
  14733. * 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.
  14734. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14735. */
  14736. minEmitBox: Vector3;
  14737. /**
  14738. * 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.
  14739. * This only works when particleEmitterTyps is a BoxParticleEmitter
  14740. */
  14741. maxEmitBox: Vector3;
  14742. /**
  14743. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14744. */
  14745. color1: Color4;
  14746. /**
  14747. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  14748. */
  14749. color2: Color4;
  14750. /**
  14751. * Color the particle will have at the end of its lifetime
  14752. */
  14753. colorDead: Color4;
  14754. /**
  14755. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  14756. */
  14757. textureMask: Color4;
  14758. /**
  14759. * The particle emitter type defines the emitter used by the particle system.
  14760. * It can be for example box, sphere, or cone...
  14761. */
  14762. particleEmitterType: IParticleEmitterType;
  14763. /** @hidden */
  14764. _isSubEmitter: boolean;
  14765. /**
  14766. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14767. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14768. */
  14769. billboardMode: number;
  14770. protected _isBillboardBased: boolean;
  14771. /**
  14772. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14773. */
  14774. isBillboardBased: boolean;
  14775. /**
  14776. * The scene the particle system belongs to.
  14777. */
  14778. protected _scene: Scene;
  14779. /**
  14780. * Local cache of defines for image processing.
  14781. */
  14782. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  14783. /**
  14784. * Default configuration related to image processing available in the standard Material.
  14785. */
  14786. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  14787. /**
  14788. * Gets the image processing configuration used either in this material.
  14789. */
  14790. /**
  14791. * Sets the Default image processing configuration used either in the this material.
  14792. *
  14793. * If sets to null, the scene one is in use.
  14794. */
  14795. imageProcessingConfiguration: ImageProcessingConfiguration;
  14796. /**
  14797. * Attaches a new image processing configuration to the Standard Material.
  14798. * @param configuration
  14799. */
  14800. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  14801. /** @hidden */
  14802. protected _reset(): void;
  14803. /** @hidden */
  14804. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  14805. /**
  14806. * Instantiates a particle system.
  14807. * 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.
  14808. * @param name The name of the particle system
  14809. */
  14810. constructor(name: string);
  14811. /**
  14812. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14813. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14814. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14815. * @returns the emitter
  14816. */
  14817. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14818. /**
  14819. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14820. * @param radius The radius of the hemisphere to emit from
  14821. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14822. * @returns the emitter
  14823. */
  14824. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  14825. /**
  14826. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  14827. * @param radius The radius of the sphere to emit from
  14828. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14829. * @returns the emitter
  14830. */
  14831. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  14832. /**
  14833. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  14834. * @param radius The radius of the sphere to emit from
  14835. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  14836. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  14837. * @returns the emitter
  14838. */
  14839. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  14840. /**
  14841. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  14842. * @param radius The radius of the emission cylinder
  14843. * @param height The height of the emission cylinder
  14844. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  14845. * @param directionRandomizer How much to randomize the particle direction [0-1]
  14846. * @returns the emitter
  14847. */
  14848. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  14849. /**
  14850. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  14851. * @param radius The radius of the cylinder to emit from
  14852. * @param height The height of the emission cylinder
  14853. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14854. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  14855. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  14856. * @returns the emitter
  14857. */
  14858. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  14859. /**
  14860. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  14861. * @param radius The radius of the cone to emit from
  14862. * @param angle The base angle of the cone
  14863. * @returns the emitter
  14864. */
  14865. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  14866. /**
  14867. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  14868. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14869. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14870. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14871. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  14872. * @returns the emitter
  14873. */
  14874. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  14875. }
  14876. }
  14877. declare module "babylonjs/Particles/subEmitter" {
  14878. import { Scene } from "babylonjs/scene";
  14879. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  14880. /**
  14881. * Type of sub emitter
  14882. */
  14883. export enum SubEmitterType {
  14884. /**
  14885. * Attached to the particle over it's lifetime
  14886. */
  14887. ATTACHED = 0,
  14888. /**
  14889. * Created when the particle dies
  14890. */
  14891. END = 1
  14892. }
  14893. /**
  14894. * Sub emitter class used to emit particles from an existing particle
  14895. */
  14896. export class SubEmitter {
  14897. /**
  14898. * the particle system to be used by the sub emitter
  14899. */
  14900. particleSystem: ParticleSystem;
  14901. /**
  14902. * Type of the submitter (Default: END)
  14903. */
  14904. type: SubEmitterType;
  14905. /**
  14906. * 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)
  14907. * Note: This only is supported when using an emitter of type Mesh
  14908. */
  14909. inheritDirection: boolean;
  14910. /**
  14911. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  14912. */
  14913. inheritedVelocityAmount: number;
  14914. /**
  14915. * Creates a sub emitter
  14916. * @param particleSystem the particle system to be used by the sub emitter
  14917. */
  14918. constructor(
  14919. /**
  14920. * the particle system to be used by the sub emitter
  14921. */
  14922. particleSystem: ParticleSystem);
  14923. /**
  14924. * Clones the sub emitter
  14925. * @returns the cloned sub emitter
  14926. */
  14927. clone(): SubEmitter;
  14928. /**
  14929. * Serialize current object to a JSON object
  14930. * @returns the serialized object
  14931. */
  14932. serialize(): any;
  14933. /** @hidden */
  14934. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  14935. /**
  14936. * Creates a new SubEmitter from a serialized JSON version
  14937. * @param serializationObject defines the JSON object to read from
  14938. * @param scene defines the hosting scene
  14939. * @param rootUrl defines the rootUrl for data loading
  14940. * @returns a new SubEmitter
  14941. */
  14942. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  14943. /** Release associated resources */
  14944. dispose(): void;
  14945. }
  14946. }
  14947. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  14948. /** @hidden */
  14949. export var clipPlaneFragmentDeclaration: {
  14950. name: string;
  14951. shader: string;
  14952. };
  14953. }
  14954. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  14955. /** @hidden */
  14956. export var imageProcessingDeclaration: {
  14957. name: string;
  14958. shader: string;
  14959. };
  14960. }
  14961. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  14962. /** @hidden */
  14963. export var imageProcessingFunctions: {
  14964. name: string;
  14965. shader: string;
  14966. };
  14967. }
  14968. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  14969. /** @hidden */
  14970. export var clipPlaneFragment: {
  14971. name: string;
  14972. shader: string;
  14973. };
  14974. }
  14975. declare module "babylonjs/Shaders/particles.fragment" {
  14976. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  14977. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  14978. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  14979. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  14980. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  14981. /** @hidden */
  14982. export var particlesPixelShader: {
  14983. name: string;
  14984. shader: string;
  14985. };
  14986. }
  14987. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  14988. /** @hidden */
  14989. export var clipPlaneVertexDeclaration: {
  14990. name: string;
  14991. shader: string;
  14992. };
  14993. }
  14994. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  14995. /** @hidden */
  14996. export var clipPlaneVertex: {
  14997. name: string;
  14998. shader: string;
  14999. };
  15000. }
  15001. declare module "babylonjs/Shaders/particles.vertex" {
  15002. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  15003. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  15004. /** @hidden */
  15005. export var particlesVertexShader: {
  15006. name: string;
  15007. shader: string;
  15008. };
  15009. }
  15010. declare module "babylonjs/Particles/particleSystem" {
  15011. import { Nullable } from "babylonjs/types";
  15012. import { IAnimatable, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  15013. import { Observable } from "babylonjs/Misc/observable";
  15014. import { Color4, Color3, Vector3, Matrix } from "babylonjs/Maths/math";
  15015. import { Effect } from "babylonjs/Materials/effect";
  15016. import { Scene, IDisposable } from "babylonjs/scene";
  15017. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  15018. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  15019. import { Particle } from "babylonjs/Particles/particle";
  15020. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15021. import "babylonjs/Shaders/particles.fragment";
  15022. import "babylonjs/Shaders/particles.vertex";
  15023. /**
  15024. * This represents a particle system in Babylon.
  15025. * 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.
  15026. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  15027. * @example https://doc.babylonjs.com/babylon101/particles
  15028. */
  15029. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  15030. /**
  15031. * Billboard mode will only apply to Y axis
  15032. */
  15033. static readonly BILLBOARDMODE_Y: number;
  15034. /**
  15035. * Billboard mode will apply to all axes
  15036. */
  15037. static readonly BILLBOARDMODE_ALL: number;
  15038. /**
  15039. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  15040. */
  15041. static readonly BILLBOARDMODE_STRETCHED: number;
  15042. /**
  15043. * This function can be defined to provide custom update for active particles.
  15044. * This function will be called instead of regular update (age, position, color, etc.).
  15045. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  15046. */
  15047. updateFunction: (particles: Particle[]) => void;
  15048. private _emitterWorldMatrix;
  15049. /**
  15050. * This function can be defined to specify initial direction for every new particle.
  15051. * It by default use the emitterType defined function
  15052. */
  15053. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  15054. /**
  15055. * This function can be defined to specify initial position for every new particle.
  15056. * It by default use the emitterType defined function
  15057. */
  15058. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  15059. /**
  15060. * @hidden
  15061. */
  15062. _inheritedVelocityOffset: Vector3;
  15063. /**
  15064. * An event triggered when the system is disposed
  15065. */
  15066. onDisposeObservable: Observable<ParticleSystem>;
  15067. private _onDisposeObserver;
  15068. /**
  15069. * Sets a callback that will be triggered when the system is disposed
  15070. */
  15071. onDispose: () => void;
  15072. private _particles;
  15073. private _epsilon;
  15074. private _capacity;
  15075. private _stockParticles;
  15076. private _newPartsExcess;
  15077. private _vertexData;
  15078. private _vertexBuffer;
  15079. private _vertexBuffers;
  15080. private _spriteBuffer;
  15081. private _indexBuffer;
  15082. private _effect;
  15083. private _customEffect;
  15084. private _cachedDefines;
  15085. private _scaledColorStep;
  15086. private _colorDiff;
  15087. private _scaledDirection;
  15088. private _scaledGravity;
  15089. private _currentRenderId;
  15090. private _alive;
  15091. private _useInstancing;
  15092. private _started;
  15093. private _stopped;
  15094. private _actualFrame;
  15095. private _scaledUpdateSpeed;
  15096. private _vertexBufferSize;
  15097. /** @hidden */
  15098. _currentEmitRateGradient: Nullable<FactorGradient>;
  15099. /** @hidden */
  15100. _currentEmitRate1: number;
  15101. /** @hidden */
  15102. _currentEmitRate2: number;
  15103. /** @hidden */
  15104. _currentStartSizeGradient: Nullable<FactorGradient>;
  15105. /** @hidden */
  15106. _currentStartSize1: number;
  15107. /** @hidden */
  15108. _currentStartSize2: number;
  15109. private readonly _rawTextureWidth;
  15110. private _rampGradientsTexture;
  15111. private _useRampGradients;
  15112. /** Gets or sets a boolean indicating that ramp gradients must be used
  15113. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  15114. */
  15115. useRampGradients: boolean;
  15116. /**
  15117. * 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.
  15118. * 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: [])
  15119. */
  15120. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  15121. private _subEmitters;
  15122. /**
  15123. * @hidden
  15124. * If the particle systems emitter should be disposed when the particle system is disposed
  15125. */
  15126. _disposeEmitterOnDispose: boolean;
  15127. /**
  15128. * The current active Sub-systems, this property is used by the root particle system only.
  15129. */
  15130. activeSubSystems: Array<ParticleSystem>;
  15131. private _rootParticleSystem;
  15132. /**
  15133. * Gets the current list of active particles
  15134. */
  15135. readonly particles: Particle[];
  15136. /**
  15137. * Returns the string "ParticleSystem"
  15138. * @returns a string containing the class name
  15139. */
  15140. getClassName(): string;
  15141. /**
  15142. * Instantiates a particle system.
  15143. * 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.
  15144. * @param name The name of the particle system
  15145. * @param capacity The max number of particles alive at the same time
  15146. * @param scene The scene the particle system belongs to
  15147. * @param customEffect a custom effect used to change the way particles are rendered by default
  15148. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  15149. * @param epsilon Offset used to render the particles
  15150. */
  15151. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  15152. private _addFactorGradient;
  15153. private _removeFactorGradient;
  15154. /**
  15155. * Adds a new life time gradient
  15156. * @param gradient defines the gradient to use (between 0 and 1)
  15157. * @param factor defines the life time factor to affect to the specified gradient
  15158. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15159. * @returns the current particle system
  15160. */
  15161. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15162. /**
  15163. * Remove a specific life time gradient
  15164. * @param gradient defines the gradient to remove
  15165. * @returns the current particle system
  15166. */
  15167. removeLifeTimeGradient(gradient: number): IParticleSystem;
  15168. /**
  15169. * Adds a new size gradient
  15170. * @param gradient defines the gradient to use (between 0 and 1)
  15171. * @param factor defines the size factor to affect to the specified gradient
  15172. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15173. * @returns the current particle system
  15174. */
  15175. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15176. /**
  15177. * Remove a specific size gradient
  15178. * @param gradient defines the gradient to remove
  15179. * @returns the current particle system
  15180. */
  15181. removeSizeGradient(gradient: number): IParticleSystem;
  15182. /**
  15183. * Adds a new color remap gradient
  15184. * @param gradient defines the gradient to use (between 0 and 1)
  15185. * @param min defines the color remap minimal range
  15186. * @param max defines the color remap maximal range
  15187. * @returns the current particle system
  15188. */
  15189. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15190. /**
  15191. * Remove a specific color remap gradient
  15192. * @param gradient defines the gradient to remove
  15193. * @returns the current particle system
  15194. */
  15195. removeColorRemapGradient(gradient: number): IParticleSystem;
  15196. /**
  15197. * Adds a new alpha remap gradient
  15198. * @param gradient defines the gradient to use (between 0 and 1)
  15199. * @param min defines the alpha remap minimal range
  15200. * @param max defines the alpha remap maximal range
  15201. * @returns the current particle system
  15202. */
  15203. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  15204. /**
  15205. * Remove a specific alpha remap gradient
  15206. * @param gradient defines the gradient to remove
  15207. * @returns the current particle system
  15208. */
  15209. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  15210. /**
  15211. * Adds a new angular speed gradient
  15212. * @param gradient defines the gradient to use (between 0 and 1)
  15213. * @param factor defines the angular speed to affect to the specified gradient
  15214. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15215. * @returns the current particle system
  15216. */
  15217. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15218. /**
  15219. * Remove a specific angular speed gradient
  15220. * @param gradient defines the gradient to remove
  15221. * @returns the current particle system
  15222. */
  15223. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  15224. /**
  15225. * Adds a new velocity gradient
  15226. * @param gradient defines the gradient to use (between 0 and 1)
  15227. * @param factor defines the velocity to affect to the specified gradient
  15228. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15229. * @returns the current particle system
  15230. */
  15231. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15232. /**
  15233. * Remove a specific velocity gradient
  15234. * @param gradient defines the gradient to remove
  15235. * @returns the current particle system
  15236. */
  15237. removeVelocityGradient(gradient: number): IParticleSystem;
  15238. /**
  15239. * Adds a new limit velocity gradient
  15240. * @param gradient defines the gradient to use (between 0 and 1)
  15241. * @param factor defines the limit velocity value to affect to the specified gradient
  15242. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15243. * @returns the current particle system
  15244. */
  15245. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15246. /**
  15247. * Remove a specific limit velocity gradient
  15248. * @param gradient defines the gradient to remove
  15249. * @returns the current particle system
  15250. */
  15251. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  15252. /**
  15253. * Adds a new drag gradient
  15254. * @param gradient defines the gradient to use (between 0 and 1)
  15255. * @param factor defines the drag value to affect to the specified gradient
  15256. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15257. * @returns the current particle system
  15258. */
  15259. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15260. /**
  15261. * Remove a specific drag gradient
  15262. * @param gradient defines the gradient to remove
  15263. * @returns the current particle system
  15264. */
  15265. removeDragGradient(gradient: number): IParticleSystem;
  15266. /**
  15267. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  15268. * @param gradient defines the gradient to use (between 0 and 1)
  15269. * @param factor defines the emit rate value to affect to the specified gradient
  15270. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15271. * @returns the current particle system
  15272. */
  15273. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15274. /**
  15275. * Remove a specific emit rate gradient
  15276. * @param gradient defines the gradient to remove
  15277. * @returns the current particle system
  15278. */
  15279. removeEmitRateGradient(gradient: number): IParticleSystem;
  15280. /**
  15281. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  15282. * @param gradient defines the gradient to use (between 0 and 1)
  15283. * @param factor defines the start size value to affect to the specified gradient
  15284. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  15285. * @returns the current particle system
  15286. */
  15287. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  15288. /**
  15289. * Remove a specific start size gradient
  15290. * @param gradient defines the gradient to remove
  15291. * @returns the current particle system
  15292. */
  15293. removeStartSizeGradient(gradient: number): IParticleSystem;
  15294. private _createRampGradientTexture;
  15295. /**
  15296. * Gets the current list of ramp gradients.
  15297. * You must use addRampGradient and removeRampGradient to udpate this list
  15298. * @returns the list of ramp gradients
  15299. */
  15300. getRampGradients(): Nullable<Array<Color3Gradient>>;
  15301. /**
  15302. * Adds a new ramp gradient used to remap particle colors
  15303. * @param gradient defines the gradient to use (between 0 and 1)
  15304. * @param color defines the color to affect to the specified gradient
  15305. * @returns the current particle system
  15306. */
  15307. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  15308. /**
  15309. * Remove a specific ramp gradient
  15310. * @param gradient defines the gradient to remove
  15311. * @returns the current particle system
  15312. */
  15313. removeRampGradient(gradient: number): ParticleSystem;
  15314. /**
  15315. * Adds a new color gradient
  15316. * @param gradient defines the gradient to use (between 0 and 1)
  15317. * @param color1 defines the color to affect to the specified gradient
  15318. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  15319. * @returns this particle system
  15320. */
  15321. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  15322. /**
  15323. * Remove a specific color gradient
  15324. * @param gradient defines the gradient to remove
  15325. * @returns this particle system
  15326. */
  15327. removeColorGradient(gradient: number): IParticleSystem;
  15328. private _fetchR;
  15329. protected _reset(): void;
  15330. private _resetEffect;
  15331. private _createVertexBuffers;
  15332. private _createIndexBuffer;
  15333. /**
  15334. * Gets the maximum number of particles active at the same time.
  15335. * @returns The max number of active particles.
  15336. */
  15337. getCapacity(): number;
  15338. /**
  15339. * Gets whether there are still active particles in the system.
  15340. * @returns True if it is alive, otherwise false.
  15341. */
  15342. isAlive(): boolean;
  15343. /**
  15344. * Gets if the system has been started. (Note: this will still be true after stop is called)
  15345. * @returns True if it has been started, otherwise false.
  15346. */
  15347. isStarted(): boolean;
  15348. private _prepareSubEmitterInternalArray;
  15349. /**
  15350. * Starts the particle system and begins to emit
  15351. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  15352. */
  15353. start(delay?: number): void;
  15354. /**
  15355. * Stops the particle system.
  15356. * @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.
  15357. */
  15358. stop(stopSubEmitters?: boolean): void;
  15359. /**
  15360. * Remove all active particles
  15361. */
  15362. reset(): void;
  15363. /**
  15364. * @hidden (for internal use only)
  15365. */
  15366. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  15367. /**
  15368. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  15369. * Its lifetime will start back at 0.
  15370. */
  15371. recycleParticle: (particle: Particle) => void;
  15372. private _stopSubEmitters;
  15373. private _createParticle;
  15374. private _removeFromRoot;
  15375. private _emitFromParticle;
  15376. private _update;
  15377. /** @hidden */
  15378. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  15379. /** @hidden */
  15380. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  15381. /** @hidden */
  15382. private _getEffect;
  15383. /**
  15384. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  15385. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  15386. */
  15387. animate(preWarmOnly?: boolean): void;
  15388. private _appendParticleVertices;
  15389. /**
  15390. * Rebuilds the particle system.
  15391. */
  15392. rebuild(): void;
  15393. /**
  15394. * Is this system ready to be used/rendered
  15395. * @return true if the system is ready
  15396. */
  15397. isReady(): boolean;
  15398. private _render;
  15399. /**
  15400. * Renders the particle system in its current state.
  15401. * @returns the current number of particles
  15402. */
  15403. render(): number;
  15404. /**
  15405. * Disposes the particle system and free the associated resources
  15406. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  15407. */
  15408. dispose(disposeTexture?: boolean): void;
  15409. /**
  15410. * Clones the particle system.
  15411. * @param name The name of the cloned object
  15412. * @param newEmitter The new emitter to use
  15413. * @returns the cloned particle system
  15414. */
  15415. clone(name: string, newEmitter: any): ParticleSystem;
  15416. /**
  15417. * Serializes the particle system to a JSON object.
  15418. * @returns the JSON object
  15419. */
  15420. serialize(): any;
  15421. /** @hidden */
  15422. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  15423. /** @hidden */
  15424. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  15425. /**
  15426. * Parses a JSON object to create a particle system.
  15427. * @param parsedParticleSystem The JSON object to parse
  15428. * @param scene The scene to create the particle system in
  15429. * @param rootUrl The root url to use to load external dependencies like texture
  15430. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  15431. * @returns the Parsed particle system
  15432. */
  15433. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  15434. }
  15435. }
  15436. declare module "babylonjs/Particles/particle" {
  15437. import { Nullable } from "babylonjs/types";
  15438. import { Color4, Vector2, Vector3, Vector4 } from "babylonjs/Maths/math";
  15439. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  15440. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  15441. import { ColorGradient, FactorGradient } from "babylonjs/Misc/tools";
  15442. /**
  15443. * A particle represents one of the element emitted by a particle system.
  15444. * This is mainly define by its coordinates, direction, velocity and age.
  15445. */
  15446. export class Particle {
  15447. /**
  15448. * The particle system the particle belongs to.
  15449. */
  15450. particleSystem: ParticleSystem;
  15451. private static _Count;
  15452. /**
  15453. * Unique ID of the particle
  15454. */
  15455. id: number;
  15456. /**
  15457. * The world position of the particle in the scene.
  15458. */
  15459. position: Vector3;
  15460. /**
  15461. * The world direction of the particle in the scene.
  15462. */
  15463. direction: Vector3;
  15464. /**
  15465. * The color of the particle.
  15466. */
  15467. color: Color4;
  15468. /**
  15469. * The color change of the particle per step.
  15470. */
  15471. colorStep: Color4;
  15472. /**
  15473. * Defines how long will the life of the particle be.
  15474. */
  15475. lifeTime: number;
  15476. /**
  15477. * The current age of the particle.
  15478. */
  15479. age: number;
  15480. /**
  15481. * The current size of the particle.
  15482. */
  15483. size: number;
  15484. /**
  15485. * The current scale of the particle.
  15486. */
  15487. scale: Vector2;
  15488. /**
  15489. * The current angle of the particle.
  15490. */
  15491. angle: number;
  15492. /**
  15493. * Defines how fast is the angle changing.
  15494. */
  15495. angularSpeed: number;
  15496. /**
  15497. * Defines the cell index used by the particle to be rendered from a sprite.
  15498. */
  15499. cellIndex: number;
  15500. /**
  15501. * The information required to support color remapping
  15502. */
  15503. remapData: Vector4;
  15504. /** @hidden */
  15505. _randomCellOffset?: number;
  15506. /** @hidden */
  15507. _initialDirection: Nullable<Vector3>;
  15508. /** @hidden */
  15509. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  15510. /** @hidden */
  15511. _initialStartSpriteCellID: number;
  15512. /** @hidden */
  15513. _initialEndSpriteCellID: number;
  15514. /** @hidden */
  15515. _currentColorGradient: Nullable<ColorGradient>;
  15516. /** @hidden */
  15517. _currentColor1: Color4;
  15518. /** @hidden */
  15519. _currentColor2: Color4;
  15520. /** @hidden */
  15521. _currentSizeGradient: Nullable<FactorGradient>;
  15522. /** @hidden */
  15523. _currentSize1: number;
  15524. /** @hidden */
  15525. _currentSize2: number;
  15526. /** @hidden */
  15527. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  15528. /** @hidden */
  15529. _currentAngularSpeed1: number;
  15530. /** @hidden */
  15531. _currentAngularSpeed2: number;
  15532. /** @hidden */
  15533. _currentVelocityGradient: Nullable<FactorGradient>;
  15534. /** @hidden */
  15535. _currentVelocity1: number;
  15536. /** @hidden */
  15537. _currentVelocity2: number;
  15538. /** @hidden */
  15539. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  15540. /** @hidden */
  15541. _currentLimitVelocity1: number;
  15542. /** @hidden */
  15543. _currentLimitVelocity2: number;
  15544. /** @hidden */
  15545. _currentDragGradient: Nullable<FactorGradient>;
  15546. /** @hidden */
  15547. _currentDrag1: number;
  15548. /** @hidden */
  15549. _currentDrag2: number;
  15550. /** @hidden */
  15551. _randomNoiseCoordinates1: Vector3;
  15552. /** @hidden */
  15553. _randomNoiseCoordinates2: Vector3;
  15554. /**
  15555. * Creates a new instance Particle
  15556. * @param particleSystem the particle system the particle belongs to
  15557. */
  15558. constructor(
  15559. /**
  15560. * The particle system the particle belongs to.
  15561. */
  15562. particleSystem: ParticleSystem);
  15563. private updateCellInfoFromSystem;
  15564. /**
  15565. * Defines how the sprite cell index is updated for the particle
  15566. */
  15567. updateCellIndex(): void;
  15568. /** @hidden */
  15569. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  15570. /** @hidden */
  15571. _inheritParticleInfoToSubEmitters(): void;
  15572. /** @hidden */
  15573. _reset(): void;
  15574. /**
  15575. * Copy the properties of particle to another one.
  15576. * @param other the particle to copy the information to.
  15577. */
  15578. copyTo(other: Particle): void;
  15579. }
  15580. }
  15581. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  15582. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15583. import { Effect } from "babylonjs/Materials/effect";
  15584. import { Particle } from "babylonjs/Particles/particle";
  15585. /**
  15586. * Particle emitter represents a volume emitting particles.
  15587. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  15588. */
  15589. export interface IParticleEmitterType {
  15590. /**
  15591. * Called by the particle System when the direction is computed for the created particle.
  15592. * @param worldMatrix is the world matrix of the particle system
  15593. * @param directionToUpdate is the direction vector to update with the result
  15594. * @param particle is the particle we are computed the direction for
  15595. */
  15596. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15597. /**
  15598. * Called by the particle System when the position is computed for the created particle.
  15599. * @param worldMatrix is the world matrix of the particle system
  15600. * @param positionToUpdate is the position vector to update with the result
  15601. * @param particle is the particle we are computed the position for
  15602. */
  15603. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15604. /**
  15605. * Clones the current emitter and returns a copy of it
  15606. * @returns the new emitter
  15607. */
  15608. clone(): IParticleEmitterType;
  15609. /**
  15610. * Called by the GPUParticleSystem to setup the update shader
  15611. * @param effect defines the update shader
  15612. */
  15613. applyToShader(effect: Effect): void;
  15614. /**
  15615. * Returns a string to use to update the GPU particles update shader
  15616. * @returns the effect defines string
  15617. */
  15618. getEffectDefines(): string;
  15619. /**
  15620. * Returns a string representing the class name
  15621. * @returns a string containing the class name
  15622. */
  15623. getClassName(): string;
  15624. /**
  15625. * Serializes the particle system to a JSON object.
  15626. * @returns the JSON object
  15627. */
  15628. serialize(): any;
  15629. /**
  15630. * Parse properties from a JSON object
  15631. * @param serializationObject defines the JSON object
  15632. */
  15633. parse(serializationObject: any): void;
  15634. }
  15635. }
  15636. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  15637. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15638. import { Effect } from "babylonjs/Materials/effect";
  15639. import { Particle } from "babylonjs/Particles/particle";
  15640. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15641. /**
  15642. * Particle emitter emitting particles from the inside of a box.
  15643. * It emits the particles randomly between 2 given directions.
  15644. */
  15645. export class BoxParticleEmitter implements IParticleEmitterType {
  15646. /**
  15647. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15648. */
  15649. direction1: Vector3;
  15650. /**
  15651. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  15652. */
  15653. direction2: Vector3;
  15654. /**
  15655. * 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.
  15656. */
  15657. minEmitBox: Vector3;
  15658. /**
  15659. * 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.
  15660. */
  15661. maxEmitBox: Vector3;
  15662. /**
  15663. * Creates a new instance BoxParticleEmitter
  15664. */
  15665. constructor();
  15666. /**
  15667. * Called by the particle System when the direction is computed for the created particle.
  15668. * @param worldMatrix is the world matrix of the particle system
  15669. * @param directionToUpdate is the direction vector to update with the result
  15670. * @param particle is the particle we are computed the direction for
  15671. */
  15672. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15673. /**
  15674. * Called by the particle System when the position is computed for the created particle.
  15675. * @param worldMatrix is the world matrix of the particle system
  15676. * @param positionToUpdate is the position vector to update with the result
  15677. * @param particle is the particle we are computed the position for
  15678. */
  15679. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15680. /**
  15681. * Clones the current emitter and returns a copy of it
  15682. * @returns the new emitter
  15683. */
  15684. clone(): BoxParticleEmitter;
  15685. /**
  15686. * Called by the GPUParticleSystem to setup the update shader
  15687. * @param effect defines the update shader
  15688. */
  15689. applyToShader(effect: Effect): void;
  15690. /**
  15691. * Returns a string to use to update the GPU particles update shader
  15692. * @returns a string containng the defines string
  15693. */
  15694. getEffectDefines(): string;
  15695. /**
  15696. * Returns the string "BoxParticleEmitter"
  15697. * @returns a string containing the class name
  15698. */
  15699. getClassName(): string;
  15700. /**
  15701. * Serializes the particle system to a JSON object.
  15702. * @returns the JSON object
  15703. */
  15704. serialize(): any;
  15705. /**
  15706. * Parse properties from a JSON object
  15707. * @param serializationObject defines the JSON object
  15708. */
  15709. parse(serializationObject: any): void;
  15710. }
  15711. }
  15712. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  15713. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15714. import { Effect } from "babylonjs/Materials/effect";
  15715. import { Particle } from "babylonjs/Particles/particle";
  15716. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15717. /**
  15718. * Particle emitter emitting particles from the inside of a cone.
  15719. * It emits the particles alongside the cone volume from the base to the particle.
  15720. * The emission direction might be randomized.
  15721. */
  15722. export class ConeParticleEmitter implements IParticleEmitterType {
  15723. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15724. directionRandomizer: number;
  15725. private _radius;
  15726. private _angle;
  15727. private _height;
  15728. /**
  15729. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  15730. */
  15731. radiusRange: number;
  15732. /**
  15733. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  15734. */
  15735. heightRange: number;
  15736. /**
  15737. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  15738. */
  15739. emitFromSpawnPointOnly: boolean;
  15740. /**
  15741. * Gets or sets the radius of the emission cone
  15742. */
  15743. radius: number;
  15744. /**
  15745. * Gets or sets the angle of the emission cone
  15746. */
  15747. angle: number;
  15748. private _buildHeight;
  15749. /**
  15750. * Creates a new instance ConeParticleEmitter
  15751. * @param radius the radius of the emission cone (1 by default)
  15752. * @param angle the cone base angle (PI by default)
  15753. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  15754. */
  15755. constructor(radius?: number, angle?: number,
  15756. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  15757. directionRandomizer?: number);
  15758. /**
  15759. * Called by the particle System when the direction is computed for the created particle.
  15760. * @param worldMatrix is the world matrix of the particle system
  15761. * @param directionToUpdate is the direction vector to update with the result
  15762. * @param particle is the particle we are computed the direction for
  15763. */
  15764. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15765. /**
  15766. * Called by the particle System when the position is computed for the created particle.
  15767. * @param worldMatrix is the world matrix of the particle system
  15768. * @param positionToUpdate is the position vector to update with the result
  15769. * @param particle is the particle we are computed the position for
  15770. */
  15771. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15772. /**
  15773. * Clones the current emitter and returns a copy of it
  15774. * @returns the new emitter
  15775. */
  15776. clone(): ConeParticleEmitter;
  15777. /**
  15778. * Called by the GPUParticleSystem to setup the update shader
  15779. * @param effect defines the update shader
  15780. */
  15781. applyToShader(effect: Effect): void;
  15782. /**
  15783. * Returns a string to use to update the GPU particles update shader
  15784. * @returns a string containng the defines string
  15785. */
  15786. getEffectDefines(): string;
  15787. /**
  15788. * Returns the string "ConeParticleEmitter"
  15789. * @returns a string containing the class name
  15790. */
  15791. getClassName(): string;
  15792. /**
  15793. * Serializes the particle system to a JSON object.
  15794. * @returns the JSON object
  15795. */
  15796. serialize(): any;
  15797. /**
  15798. * Parse properties from a JSON object
  15799. * @param serializationObject defines the JSON object
  15800. */
  15801. parse(serializationObject: any): void;
  15802. }
  15803. }
  15804. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  15805. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15806. import { Effect } from "babylonjs/Materials/effect";
  15807. import { Particle } from "babylonjs/Particles/particle";
  15808. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15809. /**
  15810. * Particle emitter emitting particles from the inside of a cylinder.
  15811. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  15812. */
  15813. export class CylinderParticleEmitter implements IParticleEmitterType {
  15814. /**
  15815. * The radius of the emission cylinder.
  15816. */
  15817. radius: number;
  15818. /**
  15819. * The height of the emission cylinder.
  15820. */
  15821. height: number;
  15822. /**
  15823. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15824. */
  15825. radiusRange: number;
  15826. /**
  15827. * How much to randomize the particle direction [0-1].
  15828. */
  15829. directionRandomizer: number;
  15830. /**
  15831. * Creates a new instance CylinderParticleEmitter
  15832. * @param radius the radius of the emission cylinder (1 by default)
  15833. * @param height the height of the emission cylinder (1 by default)
  15834. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15835. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15836. */
  15837. constructor(
  15838. /**
  15839. * The radius of the emission cylinder.
  15840. */
  15841. radius?: number,
  15842. /**
  15843. * The height of the emission cylinder.
  15844. */
  15845. height?: number,
  15846. /**
  15847. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15848. */
  15849. radiusRange?: number,
  15850. /**
  15851. * How much to randomize the particle direction [0-1].
  15852. */
  15853. directionRandomizer?: number);
  15854. /**
  15855. * Called by the particle System when the direction is computed for the created particle.
  15856. * @param worldMatrix is the world matrix of the particle system
  15857. * @param directionToUpdate is the direction vector to update with the result
  15858. * @param particle is the particle we are computed the direction for
  15859. */
  15860. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  15861. /**
  15862. * Called by the particle System when the position is computed for the created particle.
  15863. * @param worldMatrix is the world matrix of the particle system
  15864. * @param positionToUpdate is the position vector to update with the result
  15865. * @param particle is the particle we are computed the position for
  15866. */
  15867. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  15868. /**
  15869. * Clones the current emitter and returns a copy of it
  15870. * @returns the new emitter
  15871. */
  15872. clone(): CylinderParticleEmitter;
  15873. /**
  15874. * Called by the GPUParticleSystem to setup the update shader
  15875. * @param effect defines the update shader
  15876. */
  15877. applyToShader(effect: Effect): void;
  15878. /**
  15879. * Returns a string to use to update the GPU particles update shader
  15880. * @returns a string containng the defines string
  15881. */
  15882. getEffectDefines(): string;
  15883. /**
  15884. * Returns the string "CylinderParticleEmitter"
  15885. * @returns a string containing the class name
  15886. */
  15887. getClassName(): string;
  15888. /**
  15889. * Serializes the particle system to a JSON object.
  15890. * @returns the JSON object
  15891. */
  15892. serialize(): any;
  15893. /**
  15894. * Parse properties from a JSON object
  15895. * @param serializationObject defines the JSON object
  15896. */
  15897. parse(serializationObject: any): void;
  15898. }
  15899. /**
  15900. * Particle emitter emitting particles from the inside of a cylinder.
  15901. * It emits the particles randomly between two vectors.
  15902. */
  15903. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  15904. /**
  15905. * The min limit of the emission direction.
  15906. */
  15907. direction1: Vector3;
  15908. /**
  15909. * The max limit of the emission direction.
  15910. */
  15911. direction2: Vector3;
  15912. /**
  15913. * Creates a new instance CylinderDirectedParticleEmitter
  15914. * @param radius the radius of the emission cylinder (1 by default)
  15915. * @param height the height of the emission cylinder (1 by default)
  15916. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15917. * @param direction1 the min limit of the emission direction (up vector by default)
  15918. * @param direction2 the max limit of the emission direction (up vector by default)
  15919. */
  15920. constructor(radius?: number, height?: number, radiusRange?: number,
  15921. /**
  15922. * The min limit of the emission direction.
  15923. */
  15924. direction1?: Vector3,
  15925. /**
  15926. * The max limit of the emission direction.
  15927. */
  15928. direction2?: Vector3);
  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. * Clones the current emitter and returns a copy of it
  15938. * @returns the new emitter
  15939. */
  15940. clone(): CylinderDirectedParticleEmitter;
  15941. /**
  15942. * Called by the GPUParticleSystem to setup the update shader
  15943. * @param effect defines the update shader
  15944. */
  15945. applyToShader(effect: Effect): void;
  15946. /**
  15947. * Returns a string to use to update the GPU particles update shader
  15948. * @returns a string containng the defines string
  15949. */
  15950. getEffectDefines(): string;
  15951. /**
  15952. * Returns the string "CylinderDirectedParticleEmitter"
  15953. * @returns a string containing the class name
  15954. */
  15955. getClassName(): string;
  15956. /**
  15957. * Serializes the particle system to a JSON object.
  15958. * @returns the JSON object
  15959. */
  15960. serialize(): any;
  15961. /**
  15962. * Parse properties from a JSON object
  15963. * @param serializationObject defines the JSON object
  15964. */
  15965. parse(serializationObject: any): void;
  15966. }
  15967. }
  15968. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  15969. import { Vector3, Matrix } from "babylonjs/Maths/math";
  15970. import { Effect } from "babylonjs/Materials/effect";
  15971. import { Particle } from "babylonjs/Particles/particle";
  15972. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  15973. /**
  15974. * Particle emitter emitting particles from the inside of a hemisphere.
  15975. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  15976. */
  15977. export class HemisphericParticleEmitter implements IParticleEmitterType {
  15978. /**
  15979. * The radius of the emission hemisphere.
  15980. */
  15981. radius: number;
  15982. /**
  15983. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  15984. */
  15985. radiusRange: number;
  15986. /**
  15987. * How much to randomize the particle direction [0-1].
  15988. */
  15989. directionRandomizer: number;
  15990. /**
  15991. * Creates a new instance HemisphericParticleEmitter
  15992. * @param radius the radius of the emission hemisphere (1 by default)
  15993. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15994. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  15995. */
  15996. constructor(
  15997. /**
  15998. * The radius of the emission hemisphere.
  15999. */
  16000. radius?: number,
  16001. /**
  16002. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16003. */
  16004. radiusRange?: number,
  16005. /**
  16006. * How much to randomize the particle direction [0-1].
  16007. */
  16008. directionRandomizer?: number);
  16009. /**
  16010. * Called by the particle System when the direction is computed for the created particle.
  16011. * @param worldMatrix is the world matrix of the particle system
  16012. * @param directionToUpdate is the direction vector to update with the result
  16013. * @param particle is the particle we are computed the direction for
  16014. */
  16015. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16016. /**
  16017. * Called by the particle System when the position is computed for the created particle.
  16018. * @param worldMatrix is the world matrix of the particle system
  16019. * @param positionToUpdate is the position vector to update with the result
  16020. * @param particle is the particle we are computed the position for
  16021. */
  16022. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16023. /**
  16024. * Clones the current emitter and returns a copy of it
  16025. * @returns the new emitter
  16026. */
  16027. clone(): HemisphericParticleEmitter;
  16028. /**
  16029. * Called by the GPUParticleSystem to setup the update shader
  16030. * @param effect defines the update shader
  16031. */
  16032. applyToShader(effect: Effect): void;
  16033. /**
  16034. * Returns a string to use to update the GPU particles update shader
  16035. * @returns a string containng the defines string
  16036. */
  16037. getEffectDefines(): string;
  16038. /**
  16039. * Returns the string "HemisphericParticleEmitter"
  16040. * @returns a string containing the class name
  16041. */
  16042. getClassName(): string;
  16043. /**
  16044. * Serializes the particle system to a JSON object.
  16045. * @returns the JSON object
  16046. */
  16047. serialize(): any;
  16048. /**
  16049. * Parse properties from a JSON object
  16050. * @param serializationObject defines the JSON object
  16051. */
  16052. parse(serializationObject: any): void;
  16053. }
  16054. }
  16055. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  16056. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16057. import { Effect } from "babylonjs/Materials/effect";
  16058. import { Particle } from "babylonjs/Particles/particle";
  16059. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16060. /**
  16061. * Particle emitter emitting particles from a point.
  16062. * It emits the particles randomly between 2 given directions.
  16063. */
  16064. export class PointParticleEmitter implements IParticleEmitterType {
  16065. /**
  16066. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16067. */
  16068. direction1: Vector3;
  16069. /**
  16070. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  16071. */
  16072. direction2: Vector3;
  16073. /**
  16074. * Creates a new instance PointParticleEmitter
  16075. */
  16076. constructor();
  16077. /**
  16078. * Called by the particle System when the direction is computed for the created particle.
  16079. * @param worldMatrix is the world matrix of the particle system
  16080. * @param directionToUpdate is the direction vector to update with the result
  16081. * @param particle is the particle we are computed the direction for
  16082. */
  16083. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16084. /**
  16085. * Called by the particle System when the position is computed for the created particle.
  16086. * @param worldMatrix is the world matrix of the particle system
  16087. * @param positionToUpdate is the position vector to update with the result
  16088. * @param particle is the particle we are computed the position for
  16089. */
  16090. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16091. /**
  16092. * Clones the current emitter and returns a copy of it
  16093. * @returns the new emitter
  16094. */
  16095. clone(): PointParticleEmitter;
  16096. /**
  16097. * Called by the GPUParticleSystem to setup the update shader
  16098. * @param effect defines the update shader
  16099. */
  16100. applyToShader(effect: Effect): void;
  16101. /**
  16102. * Returns a string to use to update the GPU particles update shader
  16103. * @returns a string containng the defines string
  16104. */
  16105. getEffectDefines(): string;
  16106. /**
  16107. * Returns the string "PointParticleEmitter"
  16108. * @returns a string containing the class name
  16109. */
  16110. getClassName(): string;
  16111. /**
  16112. * Serializes the particle system to a JSON object.
  16113. * @returns the JSON object
  16114. */
  16115. serialize(): any;
  16116. /**
  16117. * Parse properties from a JSON object
  16118. * @param serializationObject defines the JSON object
  16119. */
  16120. parse(serializationObject: any): void;
  16121. }
  16122. }
  16123. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  16124. import { Vector3, Matrix } from "babylonjs/Maths/math";
  16125. import { Effect } from "babylonjs/Materials/effect";
  16126. import { Particle } from "babylonjs/Particles/particle";
  16127. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16128. /**
  16129. * Particle emitter emitting particles from the inside of a sphere.
  16130. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  16131. */
  16132. export class SphereParticleEmitter implements IParticleEmitterType {
  16133. /**
  16134. * The radius of the emission sphere.
  16135. */
  16136. radius: number;
  16137. /**
  16138. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16139. */
  16140. radiusRange: number;
  16141. /**
  16142. * How much to randomize the particle direction [0-1].
  16143. */
  16144. directionRandomizer: number;
  16145. /**
  16146. * Creates a new instance SphereParticleEmitter
  16147. * @param radius the radius of the emission sphere (1 by default)
  16148. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16149. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  16150. */
  16151. constructor(
  16152. /**
  16153. * The radius of the emission sphere.
  16154. */
  16155. radius?: number,
  16156. /**
  16157. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  16158. */
  16159. radiusRange?: number,
  16160. /**
  16161. * How much to randomize the particle direction [0-1].
  16162. */
  16163. directionRandomizer?: number);
  16164. /**
  16165. * Called by the particle System when the direction is computed for the created particle.
  16166. * @param worldMatrix is the world matrix of the particle system
  16167. * @param directionToUpdate is the direction vector to update with the result
  16168. * @param particle is the particle we are computed the direction for
  16169. */
  16170. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16171. /**
  16172. * Called by the particle System when the position is computed for the created particle.
  16173. * @param worldMatrix is the world matrix of the particle system
  16174. * @param positionToUpdate is the position vector to update with the result
  16175. * @param particle is the particle we are computed the position for
  16176. */
  16177. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  16178. /**
  16179. * Clones the current emitter and returns a copy of it
  16180. * @returns the new emitter
  16181. */
  16182. clone(): SphereParticleEmitter;
  16183. /**
  16184. * Called by the GPUParticleSystem to setup the update shader
  16185. * @param effect defines the update shader
  16186. */
  16187. applyToShader(effect: Effect): void;
  16188. /**
  16189. * Returns a string to use to update the GPU particles update shader
  16190. * @returns a string containng the defines string
  16191. */
  16192. getEffectDefines(): string;
  16193. /**
  16194. * Returns the string "SphereParticleEmitter"
  16195. * @returns a string containing the class name
  16196. */
  16197. getClassName(): string;
  16198. /**
  16199. * Serializes the particle system to a JSON object.
  16200. * @returns the JSON object
  16201. */
  16202. serialize(): any;
  16203. /**
  16204. * Parse properties from a JSON object
  16205. * @param serializationObject defines the JSON object
  16206. */
  16207. parse(serializationObject: any): void;
  16208. }
  16209. /**
  16210. * Particle emitter emitting particles from the inside of a sphere.
  16211. * It emits the particles randomly between two vectors.
  16212. */
  16213. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  16214. /**
  16215. * The min limit of the emission direction.
  16216. */
  16217. direction1: Vector3;
  16218. /**
  16219. * The max limit of the emission direction.
  16220. */
  16221. direction2: Vector3;
  16222. /**
  16223. * Creates a new instance SphereDirectedParticleEmitter
  16224. * @param radius the radius of the emission sphere (1 by default)
  16225. * @param direction1 the min limit of the emission direction (up vector by default)
  16226. * @param direction2 the max limit of the emission direction (up vector by default)
  16227. */
  16228. constructor(radius?: number,
  16229. /**
  16230. * The min limit of the emission direction.
  16231. */
  16232. direction1?: Vector3,
  16233. /**
  16234. * The max limit of the emission direction.
  16235. */
  16236. direction2?: Vector3);
  16237. /**
  16238. * Called by the particle System when the direction is computed for the created particle.
  16239. * @param worldMatrix is the world matrix of the particle system
  16240. * @param directionToUpdate is the direction vector to update with the result
  16241. * @param particle is the particle we are computed the direction for
  16242. */
  16243. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  16244. /**
  16245. * Clones the current emitter and returns a copy of it
  16246. * @returns the new emitter
  16247. */
  16248. clone(): SphereDirectedParticleEmitter;
  16249. /**
  16250. * Called by the GPUParticleSystem to setup the update shader
  16251. * @param effect defines the update shader
  16252. */
  16253. applyToShader(effect: Effect): void;
  16254. /**
  16255. * Returns a string to use to update the GPU particles update shader
  16256. * @returns a string containng the defines string
  16257. */
  16258. getEffectDefines(): string;
  16259. /**
  16260. * Returns the string "SphereDirectedParticleEmitter"
  16261. * @returns a string containing the class name
  16262. */
  16263. getClassName(): string;
  16264. /**
  16265. * Serializes the particle system to a JSON object.
  16266. * @returns the JSON object
  16267. */
  16268. serialize(): any;
  16269. /**
  16270. * Parse properties from a JSON object
  16271. * @param serializationObject defines the JSON object
  16272. */
  16273. parse(serializationObject: any): void;
  16274. }
  16275. }
  16276. declare module "babylonjs/Particles/EmitterTypes/index" {
  16277. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  16278. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  16279. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  16280. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  16281. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  16282. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  16283. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  16284. }
  16285. declare module "babylonjs/Particles/IParticleSystem" {
  16286. import { Nullable } from "babylonjs/types";
  16287. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  16288. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16289. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16290. import { Texture } from "babylonjs/Materials/Textures/texture";
  16291. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  16292. import { Scene } from "babylonjs/scene";
  16293. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/tools";
  16294. import { Animation } from "babylonjs/Animations/animation";
  16295. /**
  16296. * Interface representing a particle system in Babylon.js.
  16297. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  16298. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  16299. */
  16300. export interface IParticleSystem {
  16301. /**
  16302. * List of animations used by the particle system.
  16303. */
  16304. animations: Animation[];
  16305. /**
  16306. * The id of the Particle system.
  16307. */
  16308. id: string;
  16309. /**
  16310. * The name of the Particle system.
  16311. */
  16312. name: string;
  16313. /**
  16314. * The emitter represents the Mesh or position we are attaching the particle system to.
  16315. */
  16316. emitter: Nullable<AbstractMesh | Vector3>;
  16317. /**
  16318. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  16319. */
  16320. isBillboardBased: boolean;
  16321. /**
  16322. * The rendering group used by the Particle system to chose when to render.
  16323. */
  16324. renderingGroupId: number;
  16325. /**
  16326. * The layer mask we are rendering the particles through.
  16327. */
  16328. layerMask: number;
  16329. /**
  16330. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  16331. */
  16332. updateSpeed: number;
  16333. /**
  16334. * The amount of time the particle system is running (depends of the overall update speed).
  16335. */
  16336. targetStopDuration: number;
  16337. /**
  16338. * The texture used to render each particle. (this can be a spritesheet)
  16339. */
  16340. particleTexture: Nullable<Texture>;
  16341. /**
  16342. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  16343. */
  16344. blendMode: number;
  16345. /**
  16346. * Minimum life time of emitting particles.
  16347. */
  16348. minLifeTime: number;
  16349. /**
  16350. * Maximum life time of emitting particles.
  16351. */
  16352. maxLifeTime: number;
  16353. /**
  16354. * Minimum Size of emitting particles.
  16355. */
  16356. minSize: number;
  16357. /**
  16358. * Maximum Size of emitting particles.
  16359. */
  16360. maxSize: number;
  16361. /**
  16362. * Minimum scale of emitting particles on X axis.
  16363. */
  16364. minScaleX: number;
  16365. /**
  16366. * Maximum scale of emitting particles on X axis.
  16367. */
  16368. maxScaleX: number;
  16369. /**
  16370. * Minimum scale of emitting particles on Y axis.
  16371. */
  16372. minScaleY: number;
  16373. /**
  16374. * Maximum scale of emitting particles on Y axis.
  16375. */
  16376. maxScaleY: number;
  16377. /**
  16378. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16379. */
  16380. color1: Color4;
  16381. /**
  16382. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  16383. */
  16384. color2: Color4;
  16385. /**
  16386. * Color the particle will have at the end of its lifetime.
  16387. */
  16388. colorDead: Color4;
  16389. /**
  16390. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  16391. */
  16392. emitRate: number;
  16393. /**
  16394. * You can use gravity if you want to give an orientation to your particles.
  16395. */
  16396. gravity: Vector3;
  16397. /**
  16398. * Minimum power of emitting particles.
  16399. */
  16400. minEmitPower: number;
  16401. /**
  16402. * Maximum power of emitting particles.
  16403. */
  16404. maxEmitPower: number;
  16405. /**
  16406. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  16407. */
  16408. minAngularSpeed: number;
  16409. /**
  16410. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  16411. */
  16412. maxAngularSpeed: number;
  16413. /**
  16414. * Gets or sets the minimal initial rotation in radians.
  16415. */
  16416. minInitialRotation: number;
  16417. /**
  16418. * Gets or sets the maximal initial rotation in radians.
  16419. */
  16420. maxInitialRotation: number;
  16421. /**
  16422. * The particle emitter type defines the emitter used by the particle system.
  16423. * It can be for example box, sphere, or cone...
  16424. */
  16425. particleEmitterType: Nullable<IParticleEmitterType>;
  16426. /**
  16427. * Defines the delay in milliseconds before starting the system (0 by default)
  16428. */
  16429. startDelay: number;
  16430. /**
  16431. * 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
  16432. */
  16433. preWarmCycles: number;
  16434. /**
  16435. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  16436. */
  16437. preWarmStepOffset: number;
  16438. /**
  16439. * 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)
  16440. */
  16441. spriteCellChangeSpeed: number;
  16442. /**
  16443. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  16444. */
  16445. startSpriteCellID: number;
  16446. /**
  16447. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  16448. */
  16449. endSpriteCellID: number;
  16450. /**
  16451. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  16452. */
  16453. spriteCellWidth: number;
  16454. /**
  16455. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  16456. */
  16457. spriteCellHeight: number;
  16458. /**
  16459. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  16460. */
  16461. spriteRandomStartCell: boolean;
  16462. /**
  16463. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  16464. */
  16465. isAnimationSheetEnabled: boolean;
  16466. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  16467. translationPivot: Vector2;
  16468. /**
  16469. * Gets or sets a texture used to add random noise to particle positions
  16470. */
  16471. noiseTexture: Nullable<BaseTexture>;
  16472. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  16473. noiseStrength: Vector3;
  16474. /**
  16475. * Gets or sets the billboard mode to use when isBillboardBased = true.
  16476. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  16477. */
  16478. billboardMode: number;
  16479. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  16480. limitVelocityDamping: number;
  16481. /**
  16482. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  16483. */
  16484. beginAnimationOnStart: boolean;
  16485. /**
  16486. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  16487. */
  16488. beginAnimationFrom: number;
  16489. /**
  16490. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  16491. */
  16492. beginAnimationTo: number;
  16493. /**
  16494. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  16495. */
  16496. beginAnimationLoop: boolean;
  16497. /**
  16498. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  16499. */
  16500. disposeOnStop: boolean;
  16501. /**
  16502. * Gets the maximum number of particles active at the same time.
  16503. * @returns The max number of active particles.
  16504. */
  16505. getCapacity(): number;
  16506. /**
  16507. * Gets if the system has been started. (Note: this will still be true after stop is called)
  16508. * @returns True if it has been started, otherwise false.
  16509. */
  16510. isStarted(): boolean;
  16511. /**
  16512. * Animates the particle system for this frame.
  16513. */
  16514. animate(): void;
  16515. /**
  16516. * Renders the particle system in its current state.
  16517. * @returns the current number of particles
  16518. */
  16519. render(): number;
  16520. /**
  16521. * Dispose the particle system and frees its associated resources.
  16522. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  16523. */
  16524. dispose(disposeTexture?: boolean): void;
  16525. /**
  16526. * Clones the particle system.
  16527. * @param name The name of the cloned object
  16528. * @param newEmitter The new emitter to use
  16529. * @returns the cloned particle system
  16530. */
  16531. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  16532. /**
  16533. * Serializes the particle system to a JSON object.
  16534. * @returns the JSON object
  16535. */
  16536. serialize(): any;
  16537. /**
  16538. * Rebuild the particle system
  16539. */
  16540. rebuild(): void;
  16541. /**
  16542. * Starts the particle system and begins to emit
  16543. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  16544. */
  16545. start(delay?: number): void;
  16546. /**
  16547. * Stops the particle system.
  16548. */
  16549. stop(): void;
  16550. /**
  16551. * Remove all active particles
  16552. */
  16553. reset(): void;
  16554. /**
  16555. * Is this system ready to be used/rendered
  16556. * @return true if the system is ready
  16557. */
  16558. isReady(): boolean;
  16559. /**
  16560. * Adds a new color gradient
  16561. * @param gradient defines the gradient to use (between 0 and 1)
  16562. * @param color1 defines the color to affect to the specified gradient
  16563. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  16564. * @returns the current particle system
  16565. */
  16566. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  16567. /**
  16568. * Remove a specific color gradient
  16569. * @param gradient defines the gradient to remove
  16570. * @returns the current particle system
  16571. */
  16572. removeColorGradient(gradient: number): IParticleSystem;
  16573. /**
  16574. * Adds a new size gradient
  16575. * @param gradient defines the gradient to use (between 0 and 1)
  16576. * @param factor defines the size factor to affect to the specified gradient
  16577. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16578. * @returns the current particle system
  16579. */
  16580. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16581. /**
  16582. * Remove a specific size gradient
  16583. * @param gradient defines the gradient to remove
  16584. * @returns the current particle system
  16585. */
  16586. removeSizeGradient(gradient: number): IParticleSystem;
  16587. /**
  16588. * Gets the current list of color gradients.
  16589. * You must use addColorGradient and removeColorGradient to udpate this list
  16590. * @returns the list of color gradients
  16591. */
  16592. getColorGradients(): Nullable<Array<ColorGradient>>;
  16593. /**
  16594. * Gets the current list of size gradients.
  16595. * You must use addSizeGradient and removeSizeGradient to udpate this list
  16596. * @returns the list of size gradients
  16597. */
  16598. getSizeGradients(): Nullable<Array<FactorGradient>>;
  16599. /**
  16600. * Gets the current list of angular speed gradients.
  16601. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  16602. * @returns the list of angular speed gradients
  16603. */
  16604. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  16605. /**
  16606. * Adds a new angular speed gradient
  16607. * @param gradient defines the gradient to use (between 0 and 1)
  16608. * @param factor defines the angular speed to affect to the specified gradient
  16609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16610. * @returns the current particle system
  16611. */
  16612. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16613. /**
  16614. * Remove a specific angular speed gradient
  16615. * @param gradient defines the gradient to remove
  16616. * @returns the current particle system
  16617. */
  16618. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  16619. /**
  16620. * Gets the current list of velocity gradients.
  16621. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  16622. * @returns the list of velocity gradients
  16623. */
  16624. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  16625. /**
  16626. * Adds a new velocity gradient
  16627. * @param gradient defines the gradient to use (between 0 and 1)
  16628. * @param factor defines the velocity to affect to the specified gradient
  16629. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16630. * @returns the current particle system
  16631. */
  16632. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16633. /**
  16634. * Remove a specific velocity gradient
  16635. * @param gradient defines the gradient to remove
  16636. * @returns the current particle system
  16637. */
  16638. removeVelocityGradient(gradient: number): IParticleSystem;
  16639. /**
  16640. * Gets the current list of limit velocity gradients.
  16641. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  16642. * @returns the list of limit velocity gradients
  16643. */
  16644. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  16645. /**
  16646. * Adds a new limit velocity gradient
  16647. * @param gradient defines the gradient to use (between 0 and 1)
  16648. * @param factor defines the limit velocity to affect to the specified gradient
  16649. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16650. * @returns the current particle system
  16651. */
  16652. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16653. /**
  16654. * Remove a specific limit velocity gradient
  16655. * @param gradient defines the gradient to remove
  16656. * @returns the current particle system
  16657. */
  16658. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  16659. /**
  16660. * Adds a new drag gradient
  16661. * @param gradient defines the gradient to use (between 0 and 1)
  16662. * @param factor defines the drag to affect to the specified gradient
  16663. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16664. * @returns the current particle system
  16665. */
  16666. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16667. /**
  16668. * Remove a specific drag gradient
  16669. * @param gradient defines the gradient to remove
  16670. * @returns the current particle system
  16671. */
  16672. removeDragGradient(gradient: number): IParticleSystem;
  16673. /**
  16674. * Gets the current list of drag gradients.
  16675. * You must use addDragGradient and removeDragGradient to udpate this list
  16676. * @returns the list of drag gradients
  16677. */
  16678. getDragGradients(): Nullable<Array<FactorGradient>>;
  16679. /**
  16680. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  16681. * @param gradient defines the gradient to use (between 0 and 1)
  16682. * @param factor defines the emit rate to affect to the specified gradient
  16683. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16684. * @returns the current particle system
  16685. */
  16686. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16687. /**
  16688. * Remove a specific emit rate gradient
  16689. * @param gradient defines the gradient to remove
  16690. * @returns the current particle system
  16691. */
  16692. removeEmitRateGradient(gradient: number): IParticleSystem;
  16693. /**
  16694. * Gets the current list of emit rate gradients.
  16695. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  16696. * @returns the list of emit rate gradients
  16697. */
  16698. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  16699. /**
  16700. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  16701. * @param gradient defines the gradient to use (between 0 and 1)
  16702. * @param factor defines the start size to affect to the specified gradient
  16703. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16704. * @returns the current particle system
  16705. */
  16706. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16707. /**
  16708. * Remove a specific start size gradient
  16709. * @param gradient defines the gradient to remove
  16710. * @returns the current particle system
  16711. */
  16712. removeStartSizeGradient(gradient: number): IParticleSystem;
  16713. /**
  16714. * Gets the current list of start size gradients.
  16715. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  16716. * @returns the list of start size gradients
  16717. */
  16718. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  16719. /**
  16720. * Adds a new life time gradient
  16721. * @param gradient defines the gradient to use (between 0 and 1)
  16722. * @param factor defines the life time factor to affect to the specified gradient
  16723. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  16724. * @returns the current particle system
  16725. */
  16726. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  16727. /**
  16728. * Remove a specific life time gradient
  16729. * @param gradient defines the gradient to remove
  16730. * @returns the current particle system
  16731. */
  16732. removeLifeTimeGradient(gradient: number): IParticleSystem;
  16733. /**
  16734. * Gets the current list of life time gradients.
  16735. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  16736. * @returns the list of life time gradients
  16737. */
  16738. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  16739. /**
  16740. * Gets the current list of color gradients.
  16741. * You must use addColorGradient and removeColorGradient to udpate this list
  16742. * @returns the list of color gradients
  16743. */
  16744. getColorGradients(): Nullable<Array<ColorGradient>>;
  16745. /**
  16746. * Adds a new ramp gradient used to remap particle colors
  16747. * @param gradient defines the gradient to use (between 0 and 1)
  16748. * @param color defines the color to affect to the specified gradient
  16749. * @returns the current particle system
  16750. */
  16751. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  16752. /**
  16753. * Gets the current list of ramp gradients.
  16754. * You must use addRampGradient and removeRampGradient to udpate this list
  16755. * @returns the list of ramp gradients
  16756. */
  16757. getRampGradients(): Nullable<Array<Color3Gradient>>;
  16758. /** Gets or sets a boolean indicating that ramp gradients must be used
  16759. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  16760. */
  16761. useRampGradients: boolean;
  16762. /**
  16763. * Adds a new color remap gradient
  16764. * @param gradient defines the gradient to use (between 0 and 1)
  16765. * @param min defines the color remap minimal range
  16766. * @param max defines the color remap maximal range
  16767. * @returns the current particle system
  16768. */
  16769. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16770. /**
  16771. * Gets the current list of color remap gradients.
  16772. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  16773. * @returns the list of color remap gradients
  16774. */
  16775. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  16776. /**
  16777. * Adds a new alpha remap gradient
  16778. * @param gradient defines the gradient to use (between 0 and 1)
  16779. * @param min defines the alpha remap minimal range
  16780. * @param max defines the alpha remap maximal range
  16781. * @returns the current particle system
  16782. */
  16783. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  16784. /**
  16785. * Gets the current list of alpha remap gradients.
  16786. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  16787. * @returns the list of alpha remap gradients
  16788. */
  16789. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  16790. /**
  16791. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  16792. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16793. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16794. * @returns the emitter
  16795. */
  16796. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  16797. /**
  16798. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  16799. * @param radius The radius of the hemisphere to emit from
  16800. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16801. * @returns the emitter
  16802. */
  16803. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  16804. /**
  16805. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  16806. * @param radius The radius of the sphere to emit from
  16807. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  16808. * @returns the emitter
  16809. */
  16810. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  16811. /**
  16812. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  16813. * @param radius The radius of the sphere to emit from
  16814. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  16815. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  16816. * @returns the emitter
  16817. */
  16818. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16819. /**
  16820. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  16821. * @param radius The radius of the emission cylinder
  16822. * @param height The height of the emission cylinder
  16823. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  16824. * @param directionRandomizer How much to randomize the particle direction [0-1]
  16825. * @returns the emitter
  16826. */
  16827. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  16828. /**
  16829. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  16830. * @param radius The radius of the cylinder to emit from
  16831. * @param height The height of the emission cylinder
  16832. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  16833. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  16834. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  16835. * @returns the emitter
  16836. */
  16837. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  16838. /**
  16839. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  16840. * @param radius The radius of the cone to emit from
  16841. * @param angle The base angle of the cone
  16842. * @returns the emitter
  16843. */
  16844. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  16845. /**
  16846. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  16847. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  16848. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  16849. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16850. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  16851. * @returns the emitter
  16852. */
  16853. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  16854. /**
  16855. * Get hosting scene
  16856. * @returns the scene
  16857. */
  16858. getScene(): Scene;
  16859. }
  16860. }
  16861. declare module "babylonjs/Meshes/instancedMesh" {
  16862. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16863. import { Vector3 } from "babylonjs/Maths/math";
  16864. import { Camera } from "babylonjs/Cameras/camera";
  16865. import { Node } from "babylonjs/node";
  16866. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16867. import { Mesh } from "babylonjs/Meshes/mesh";
  16868. import { Material } from "babylonjs/Materials/material";
  16869. import { Skeleton } from "babylonjs/Bones/skeleton";
  16870. /**
  16871. * Creates an instance based on a source mesh.
  16872. */
  16873. export class InstancedMesh extends AbstractMesh {
  16874. private _sourceMesh;
  16875. private _currentLOD;
  16876. /** @hidden */
  16877. _indexInSourceMeshInstanceArray: number;
  16878. constructor(name: string, source: Mesh);
  16879. /**
  16880. * Returns the string "InstancedMesh".
  16881. */
  16882. getClassName(): string;
  16883. /**
  16884. * If the source mesh receives shadows
  16885. */
  16886. readonly receiveShadows: boolean;
  16887. /**
  16888. * The material of the source mesh
  16889. */
  16890. readonly material: Nullable<Material>;
  16891. /**
  16892. * Visibility of the source mesh
  16893. */
  16894. readonly visibility: number;
  16895. /**
  16896. * Skeleton of the source mesh
  16897. */
  16898. readonly skeleton: Nullable<Skeleton>;
  16899. /**
  16900. * Rendering ground id of the source mesh
  16901. */
  16902. renderingGroupId: number;
  16903. /**
  16904. * Returns the total number of vertices (integer).
  16905. */
  16906. getTotalVertices(): number;
  16907. /**
  16908. * Returns a positive integer : the total number of indices in this mesh geometry.
  16909. * @returns the numner of indices or zero if the mesh has no geometry.
  16910. */
  16911. getTotalIndices(): number;
  16912. /**
  16913. * The source mesh of the instance
  16914. */
  16915. readonly sourceMesh: Mesh;
  16916. /**
  16917. * Is this node ready to be used/rendered
  16918. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16919. * @return {boolean} is it ready
  16920. */
  16921. isReady(completeCheck?: boolean): boolean;
  16922. /**
  16923. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16924. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16925. * @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.
  16926. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16927. */
  16928. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16929. /**
  16930. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16931. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16932. * The `data` are either a numeric array either a Float32Array.
  16933. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16934. * 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).
  16935. * Note that a new underlying VertexBuffer object is created each call.
  16936. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16937. *
  16938. * Possible `kind` values :
  16939. * - VertexBuffer.PositionKind
  16940. * - VertexBuffer.UVKind
  16941. * - VertexBuffer.UV2Kind
  16942. * - VertexBuffer.UV3Kind
  16943. * - VertexBuffer.UV4Kind
  16944. * - VertexBuffer.UV5Kind
  16945. * - VertexBuffer.UV6Kind
  16946. * - VertexBuffer.ColorKind
  16947. * - VertexBuffer.MatricesIndicesKind
  16948. * - VertexBuffer.MatricesIndicesExtraKind
  16949. * - VertexBuffer.MatricesWeightsKind
  16950. * - VertexBuffer.MatricesWeightsExtraKind
  16951. *
  16952. * Returns the Mesh.
  16953. */
  16954. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  16955. /**
  16956. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16957. * If the mesh has no geometry, it is simply returned as it is.
  16958. * The `data` are either a numeric array either a Float32Array.
  16959. * No new underlying VertexBuffer object is created.
  16960. * 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.
  16961. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16962. *
  16963. * Possible `kind` values :
  16964. * - VertexBuffer.PositionKind
  16965. * - VertexBuffer.UVKind
  16966. * - VertexBuffer.UV2Kind
  16967. * - VertexBuffer.UV3Kind
  16968. * - VertexBuffer.UV4Kind
  16969. * - VertexBuffer.UV5Kind
  16970. * - VertexBuffer.UV6Kind
  16971. * - VertexBuffer.ColorKind
  16972. * - VertexBuffer.MatricesIndicesKind
  16973. * - VertexBuffer.MatricesIndicesExtraKind
  16974. * - VertexBuffer.MatricesWeightsKind
  16975. * - VertexBuffer.MatricesWeightsExtraKind
  16976. *
  16977. * Returns the Mesh.
  16978. */
  16979. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16980. /**
  16981. * Sets the mesh indices.
  16982. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16983. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16984. * This method creates a new index buffer each call.
  16985. * Returns the Mesh.
  16986. */
  16987. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16988. /**
  16989. * Boolean : True if the mesh owns the requested kind of data.
  16990. */
  16991. isVerticesDataPresent(kind: string): boolean;
  16992. /**
  16993. * Returns an array of indices (IndicesArray).
  16994. */
  16995. getIndices(): Nullable<IndicesArray>;
  16996. readonly _positions: Nullable<Vector3[]>;
  16997. /**
  16998. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16999. * This means the mesh underlying bounding box and sphere are recomputed.
  17000. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  17001. * @returns the current mesh
  17002. */
  17003. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  17004. /** @hidden */
  17005. _preActivate(): InstancedMesh;
  17006. /** @hidden */
  17007. _activate(renderId: number): boolean;
  17008. /**
  17009. * Returns the current associated LOD AbstractMesh.
  17010. */
  17011. getLOD(camera: Camera): AbstractMesh;
  17012. /** @hidden */
  17013. _syncSubMeshes(): InstancedMesh;
  17014. /** @hidden */
  17015. _generatePointsArray(): boolean;
  17016. /**
  17017. * Creates a new InstancedMesh from the current mesh.
  17018. * - name (string) : the cloned mesh name
  17019. * - newParent (optional Node) : the optional Node to parent the clone to.
  17020. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  17021. *
  17022. * Returns the clone.
  17023. */
  17024. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  17025. /**
  17026. * Disposes the InstancedMesh.
  17027. * Returns nothing.
  17028. */
  17029. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  17030. }
  17031. }
  17032. declare module "babylonjs/Materials/shaderMaterial" {
  17033. import { Scene } from "babylonjs/scene";
  17034. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  17035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17036. import { Mesh } from "babylonjs/Meshes/mesh";
  17037. import { BaseSubMesh } from "babylonjs/Meshes/subMesh";
  17038. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  17039. import { Texture } from "babylonjs/Materials/Textures/texture";
  17040. import { Material } from "babylonjs/Materials/material";
  17041. /**
  17042. * Defines the options associated with the creation of a shader material.
  17043. */
  17044. export interface IShaderMaterialOptions {
  17045. /**
  17046. * Does the material work in alpha blend mode
  17047. */
  17048. needAlphaBlending: boolean;
  17049. /**
  17050. * Does the material work in alpha test mode
  17051. */
  17052. needAlphaTesting: boolean;
  17053. /**
  17054. * The list of attribute names used in the shader
  17055. */
  17056. attributes: string[];
  17057. /**
  17058. * The list of unifrom names used in the shader
  17059. */
  17060. uniforms: string[];
  17061. /**
  17062. * The list of UBO names used in the shader
  17063. */
  17064. uniformBuffers: string[];
  17065. /**
  17066. * The list of sampler names used in the shader
  17067. */
  17068. samplers: string[];
  17069. /**
  17070. * The list of defines used in the shader
  17071. */
  17072. defines: string[];
  17073. }
  17074. /**
  17075. * 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.
  17076. *
  17077. * This returned material effects how the mesh will look based on the code in the shaders.
  17078. *
  17079. * @see http://doc.babylonjs.com/how_to/shader_material
  17080. */
  17081. export class ShaderMaterial extends Material {
  17082. private _shaderPath;
  17083. private _options;
  17084. private _textures;
  17085. private _textureArrays;
  17086. private _floats;
  17087. private _ints;
  17088. private _floatsArrays;
  17089. private _colors3;
  17090. private _colors3Arrays;
  17091. private _colors4;
  17092. private _vectors2;
  17093. private _vectors3;
  17094. private _vectors4;
  17095. private _matrices;
  17096. private _matrices3x3;
  17097. private _matrices2x2;
  17098. private _vectors2Arrays;
  17099. private _vectors3Arrays;
  17100. private _cachedWorldViewMatrix;
  17101. private _renderId;
  17102. /**
  17103. * Instantiate a new shader material.
  17104. * 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.
  17105. * This returned material effects how the mesh will look based on the code in the shaders.
  17106. * @see http://doc.babylonjs.com/how_to/shader_material
  17107. * @param name Define the name of the material in the scene
  17108. * @param scene Define the scene the material belongs to
  17109. * @param shaderPath Defines the route to the shader code in one of three ways:
  17110. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17111. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  17112. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17113. * @param options Define the options used to create the shader
  17114. */
  17115. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17116. /**
  17117. * Gets the options used to compile the shader.
  17118. * They can be modified to trigger a new compilation
  17119. */
  17120. readonly options: IShaderMaterialOptions;
  17121. /**
  17122. * Gets the current class name of the material e.g. "ShaderMaterial"
  17123. * Mainly use in serialization.
  17124. * @returns the class name
  17125. */
  17126. getClassName(): string;
  17127. /**
  17128. * Specifies if the material will require alpha blending
  17129. * @returns a boolean specifying if alpha blending is needed
  17130. */
  17131. needAlphaBlending(): boolean;
  17132. /**
  17133. * Specifies if this material should be rendered in alpha test mode
  17134. * @returns a boolean specifying if an alpha test is needed.
  17135. */
  17136. needAlphaTesting(): boolean;
  17137. private _checkUniform;
  17138. /**
  17139. * Set a texture in the shader.
  17140. * @param name Define the name of the uniform samplers as defined in the shader
  17141. * @param texture Define the texture to bind to this sampler
  17142. * @return the material itself allowing "fluent" like uniform updates
  17143. */
  17144. setTexture(name: string, texture: Texture): ShaderMaterial;
  17145. /**
  17146. * Set a texture array in the shader.
  17147. * @param name Define the name of the uniform sampler array as defined in the shader
  17148. * @param textures Define the list of textures to bind to this sampler
  17149. * @return the material itself allowing "fluent" like uniform updates
  17150. */
  17151. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  17152. /**
  17153. * Set a float in the shader.
  17154. * @param name Define the name of the uniform as defined in the shader
  17155. * @param value Define the value to give to the uniform
  17156. * @return the material itself allowing "fluent" like uniform updates
  17157. */
  17158. setFloat(name: string, value: number): ShaderMaterial;
  17159. /**
  17160. * Set a int in the shader.
  17161. * @param name Define the name of the uniform as defined in the shader
  17162. * @param value Define the value to give to the uniform
  17163. * @return the material itself allowing "fluent" like uniform updates
  17164. */
  17165. setInt(name: string, value: number): ShaderMaterial;
  17166. /**
  17167. * Set an array of floats in the shader.
  17168. * @param name Define the name of the uniform as defined in the shader
  17169. * @param value Define the value to give to the uniform
  17170. * @return the material itself allowing "fluent" like uniform updates
  17171. */
  17172. setFloats(name: string, value: number[]): ShaderMaterial;
  17173. /**
  17174. * Set a vec3 in the shader from a Color3.
  17175. * @param name Define the name of the uniform as defined in the shader
  17176. * @param value Define the value to give to the uniform
  17177. * @return the material itself allowing "fluent" like uniform updates
  17178. */
  17179. setColor3(name: string, value: Color3): ShaderMaterial;
  17180. /**
  17181. * Set a vec3 array in the shader from a Color3 array.
  17182. * @param name Define the name of the uniform as defined in the shader
  17183. * @param value Define the value to give to the uniform
  17184. * @return the material itself allowing "fluent" like uniform updates
  17185. */
  17186. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17187. /**
  17188. * Set a vec4 in the shader from a Color4.
  17189. * @param name Define the name of the uniform as defined in the shader
  17190. * @param value Define the value to give to the uniform
  17191. * @return the material itself allowing "fluent" like uniform updates
  17192. */
  17193. setColor4(name: string, value: Color4): ShaderMaterial;
  17194. /**
  17195. * Set a vec2 in the shader from a Vector2.
  17196. * @param name Define the name of the uniform as defined in the shader
  17197. * @param value Define the value to give to the uniform
  17198. * @return the material itself allowing "fluent" like uniform updates
  17199. */
  17200. setVector2(name: string, value: Vector2): ShaderMaterial;
  17201. /**
  17202. * Set a vec3 in the shader from a Vector3.
  17203. * @param name Define the name of the uniform as defined in the shader
  17204. * @param value Define the value to give to the uniform
  17205. * @return the material itself allowing "fluent" like uniform updates
  17206. */
  17207. setVector3(name: string, value: Vector3): ShaderMaterial;
  17208. /**
  17209. * Set a vec4 in the shader from a Vector4.
  17210. * @param name Define the name of the uniform as defined in the shader
  17211. * @param value Define the value to give to the uniform
  17212. * @return the material itself allowing "fluent" like uniform updates
  17213. */
  17214. setVector4(name: string, value: Vector4): ShaderMaterial;
  17215. /**
  17216. * Set a mat4 in the shader from a Matrix.
  17217. * @param name Define the name of the uniform as defined in the shader
  17218. * @param value Define the value to give to the uniform
  17219. * @return the material itself allowing "fluent" like uniform updates
  17220. */
  17221. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17222. /**
  17223. * Set a mat3 in the shader from a Float32Array.
  17224. * @param name Define the name of the uniform as defined in the shader
  17225. * @param value Define the value to give to the uniform
  17226. * @return the material itself allowing "fluent" like uniform updates
  17227. */
  17228. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  17229. /**
  17230. * Set a mat2 in the shader from a Float32Array.
  17231. * @param name Define the name of the uniform as defined in the shader
  17232. * @param value Define the value to give to the uniform
  17233. * @return the material itself allowing "fluent" like uniform updates
  17234. */
  17235. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  17236. /**
  17237. * Set a vec2 array in the shader from a number array.
  17238. * @param name Define the name of the uniform as defined in the shader
  17239. * @param value Define the value to give to the uniform
  17240. * @return the material itself allowing "fluent" like uniform updates
  17241. */
  17242. setArray2(name: string, value: number[]): ShaderMaterial;
  17243. /**
  17244. * Set a vec3 array in the shader from a number array.
  17245. * @param name Define the name of the uniform as defined in the shader
  17246. * @param value Define the value to give to the uniform
  17247. * @return the material itself allowing "fluent" like uniform updates
  17248. */
  17249. setArray3(name: string, value: number[]): ShaderMaterial;
  17250. private _checkCache;
  17251. /**
  17252. * Specifies that the submesh is ready to be used
  17253. * @param mesh defines the mesh to check
  17254. * @param subMesh defines which submesh to check
  17255. * @param useInstances specifies that instances should be used
  17256. * @returns a boolean indicating that the submesh is ready or not
  17257. */
  17258. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  17259. /**
  17260. * Checks if the material is ready to render the requested mesh
  17261. * @param mesh Define the mesh to render
  17262. * @param useInstances Define whether or not the material is used with instances
  17263. * @returns true if ready, otherwise false
  17264. */
  17265. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17266. /**
  17267. * Binds the world matrix to the material
  17268. * @param world defines the world transformation matrix
  17269. */
  17270. bindOnlyWorldMatrix(world: Matrix): void;
  17271. /**
  17272. * Binds the material to the mesh
  17273. * @param world defines the world transformation matrix
  17274. * @param mesh defines the mesh to bind the material to
  17275. */
  17276. bind(world: Matrix, mesh?: Mesh): void;
  17277. /**
  17278. * Gets the active textures from the material
  17279. * @returns an array of textures
  17280. */
  17281. getActiveTextures(): BaseTexture[];
  17282. /**
  17283. * Specifies if the material uses a texture
  17284. * @param texture defines the texture to check against the material
  17285. * @returns a boolean specifying if the material uses the texture
  17286. */
  17287. hasTexture(texture: BaseTexture): boolean;
  17288. /**
  17289. * Makes a duplicate of the material, and gives it a new name
  17290. * @param name defines the new name for the duplicated material
  17291. * @returns the cloned material
  17292. */
  17293. clone(name: string): ShaderMaterial;
  17294. /**
  17295. * Disposes the material
  17296. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17297. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17298. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17299. */
  17300. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17301. /**
  17302. * Serializes this material in a JSON representation
  17303. * @returns the serialized material object
  17304. */
  17305. serialize(): any;
  17306. /**
  17307. * Creates a shader material from parsed shader material data
  17308. * @param source defines the JSON represnetation of the material
  17309. * @param scene defines the hosting scene
  17310. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17311. * @returns a new material
  17312. */
  17313. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17314. }
  17315. }
  17316. declare module "babylonjs/Shaders/color.fragment" {
  17317. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17318. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17319. /** @hidden */
  17320. export var colorPixelShader: {
  17321. name: string;
  17322. shader: string;
  17323. };
  17324. }
  17325. declare module "babylonjs/Shaders/color.vertex" {
  17326. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17329. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17330. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17331. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17332. /** @hidden */
  17333. export var colorVertexShader: {
  17334. name: string;
  17335. shader: string;
  17336. };
  17337. }
  17338. declare module "babylonjs/Meshes/linesMesh" {
  17339. import { Nullable } from "babylonjs/types";
  17340. import { Scene } from "babylonjs/scene";
  17341. import { Color3 } from "babylonjs/Maths/math";
  17342. import { Node } from "babylonjs/node";
  17343. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17344. import { Mesh } from "babylonjs/Meshes/mesh";
  17345. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17346. import { Effect } from "babylonjs/Materials/effect";
  17347. import { Material } from "babylonjs/Materials/material";
  17348. import "babylonjs/Shaders/color.fragment";
  17349. import "babylonjs/Shaders/color.vertex";
  17350. /**
  17351. * Line mesh
  17352. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17353. */
  17354. export class LinesMesh extends Mesh {
  17355. /**
  17356. * If vertex color should be applied to the mesh
  17357. */
  17358. useVertexColor?: boolean | undefined;
  17359. /**
  17360. * If vertex alpha should be applied to the mesh
  17361. */
  17362. useVertexAlpha?: boolean | undefined;
  17363. /**
  17364. * Color of the line (Default: White)
  17365. */
  17366. color: Color3;
  17367. /**
  17368. * Alpha of the line (Default: 1)
  17369. */
  17370. alpha: number;
  17371. /**
  17372. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17373. * This margin is expressed in world space coordinates, so its value may vary.
  17374. * Default value is 0.1
  17375. */
  17376. intersectionThreshold: number;
  17377. private _colorShader;
  17378. /**
  17379. * Creates a new LinesMesh
  17380. * @param name defines the name
  17381. * @param scene defines the hosting scene
  17382. * @param parent defines the parent mesh if any
  17383. * @param source defines the optional source LinesMesh used to clone data from
  17384. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17385. * When false, achieved by calling a clone(), also passing False.
  17386. * This will make creation of children, recursive.
  17387. * @param useVertexColor defines if this LinesMesh supports vertex color
  17388. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17389. */
  17390. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  17391. /**
  17392. * If vertex color should be applied to the mesh
  17393. */
  17394. useVertexColor?: boolean | undefined,
  17395. /**
  17396. * If vertex alpha should be applied to the mesh
  17397. */
  17398. useVertexAlpha?: boolean | undefined);
  17399. private _addClipPlaneDefine;
  17400. private _removeClipPlaneDefine;
  17401. isReady(): boolean;
  17402. /**
  17403. * Returns the string "LineMesh"
  17404. */
  17405. getClassName(): string;
  17406. /**
  17407. * @hidden
  17408. */
  17409. /**
  17410. * @hidden
  17411. */
  17412. material: Material;
  17413. /**
  17414. * @hidden
  17415. */
  17416. readonly checkCollisions: boolean;
  17417. /** @hidden */
  17418. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  17419. /** @hidden */
  17420. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  17421. /**
  17422. * Disposes of the line mesh
  17423. * @param doNotRecurse If children should be disposed
  17424. */
  17425. dispose(doNotRecurse?: boolean): void;
  17426. /**
  17427. * Returns a new LineMesh object cloned from the current one.
  17428. */
  17429. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  17430. /**
  17431. * Creates a new InstancedLinesMesh object from the mesh model.
  17432. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  17433. * @param name defines the name of the new instance
  17434. * @returns a new InstancedLinesMesh
  17435. */
  17436. createInstance(name: string): InstancedLinesMesh;
  17437. }
  17438. /**
  17439. * Creates an instance based on a source LinesMesh
  17440. */
  17441. export class InstancedLinesMesh extends InstancedMesh {
  17442. /**
  17443. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17444. * This margin is expressed in world space coordinates, so its value may vary.
  17445. * Initilized with the intersectionThreshold value of the source LinesMesh
  17446. */
  17447. intersectionThreshold: number;
  17448. constructor(name: string, source: LinesMesh);
  17449. /**
  17450. * Returns the string "InstancedLinesMesh".
  17451. */
  17452. getClassName(): string;
  17453. }
  17454. }
  17455. declare module "babylonjs/Shaders/line.fragment" {
  17456. /** @hidden */
  17457. export var linePixelShader: {
  17458. name: string;
  17459. shader: string;
  17460. };
  17461. }
  17462. declare module "babylonjs/Shaders/line.vertex" {
  17463. /** @hidden */
  17464. export var lineVertexShader: {
  17465. name: string;
  17466. shader: string;
  17467. };
  17468. }
  17469. declare module "babylonjs/Rendering/edgesRenderer" {
  17470. import { Nullable } from "babylonjs/types";
  17471. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17472. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17473. import { Vector3 } from "babylonjs/Maths/math";
  17474. import { IDisposable } from "babylonjs/scene";
  17475. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17476. import "babylonjs/Shaders/line.fragment";
  17477. import "babylonjs/Shaders/line.vertex";
  17478. module "babylonjs/Meshes/abstractMesh" {
  17479. interface AbstractMesh {
  17480. /**
  17481. * Disables the mesh edge rendering mode
  17482. * @returns the currentAbstractMesh
  17483. */
  17484. disableEdgesRendering(): AbstractMesh;
  17485. /**
  17486. * Enables the edge rendering mode on the mesh.
  17487. * This mode makes the mesh edges visible
  17488. * @param epsilon defines the maximal distance between two angles to detect a face
  17489. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17490. * @returns the currentAbstractMesh
  17491. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17492. */
  17493. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17494. /**
  17495. * Gets the edgesRenderer associated with the mesh
  17496. */
  17497. edgesRenderer: Nullable<EdgesRenderer>;
  17498. }
  17499. }
  17500. module "babylonjs/Meshes/linesMesh" {
  17501. interface LinesMesh {
  17502. /**
  17503. * Enables the edge rendering mode on the mesh.
  17504. * This mode makes the mesh edges visible
  17505. * @param epsilon defines the maximal distance between two angles to detect a face
  17506. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17507. * @returns the currentAbstractMesh
  17508. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17509. */
  17510. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17511. }
  17512. }
  17513. module "babylonjs/Meshes/linesMesh" {
  17514. interface InstancedLinesMesh {
  17515. /**
  17516. * Enables the edge rendering mode on the mesh.
  17517. * This mode makes the mesh edges visible
  17518. * @param epsilon defines the maximal distance between two angles to detect a face
  17519. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17520. * @returns the current InstancedLinesMesh
  17521. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17522. */
  17523. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17524. }
  17525. }
  17526. /**
  17527. * Defines the minimum contract an Edges renderer should follow.
  17528. */
  17529. export interface IEdgesRenderer extends IDisposable {
  17530. /**
  17531. * Gets or sets a boolean indicating if the edgesRenderer is active
  17532. */
  17533. isEnabled: boolean;
  17534. /**
  17535. * Renders the edges of the attached mesh,
  17536. */
  17537. render(): void;
  17538. /**
  17539. * Checks wether or not the edges renderer is ready to render.
  17540. * @return true if ready, otherwise false.
  17541. */
  17542. isReady(): boolean;
  17543. }
  17544. /**
  17545. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17546. */
  17547. export class EdgesRenderer implements IEdgesRenderer {
  17548. /**
  17549. * Define the size of the edges with an orthographic camera
  17550. */
  17551. edgesWidthScalerForOrthographic: number;
  17552. /**
  17553. * Define the size of the edges with a perspective camera
  17554. */
  17555. edgesWidthScalerForPerspective: number;
  17556. protected _source: AbstractMesh;
  17557. protected _linesPositions: number[];
  17558. protected _linesNormals: number[];
  17559. protected _linesIndices: number[];
  17560. protected _epsilon: number;
  17561. protected _indicesCount: number;
  17562. protected _lineShader: ShaderMaterial;
  17563. protected _ib: WebGLBuffer;
  17564. protected _buffers: {
  17565. [key: string]: Nullable<VertexBuffer>;
  17566. };
  17567. protected _checkVerticesInsteadOfIndices: boolean;
  17568. private _meshRebuildObserver;
  17569. private _meshDisposeObserver;
  17570. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17571. isEnabled: boolean;
  17572. /**
  17573. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17574. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17575. * @param source Mesh used to create edges
  17576. * @param epsilon sum of angles in adjacency to check for edge
  17577. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  17578. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17579. */
  17580. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  17581. protected _prepareRessources(): void;
  17582. /** @hidden */
  17583. _rebuild(): void;
  17584. /**
  17585. * Releases the required resources for the edges renderer
  17586. */
  17587. dispose(): void;
  17588. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17589. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17590. /**
  17591. * Checks if the pair of p0 and p1 is en edge
  17592. * @param faceIndex
  17593. * @param edge
  17594. * @param faceNormals
  17595. * @param p0
  17596. * @param p1
  17597. * @private
  17598. */
  17599. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17600. /**
  17601. * push line into the position, normal and index buffer
  17602. * @protected
  17603. */
  17604. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17605. /**
  17606. * Generates lines edges from adjacencjes
  17607. * @private
  17608. */
  17609. _generateEdgesLines(): void;
  17610. /**
  17611. * Checks wether or not the edges renderer is ready to render.
  17612. * @return true if ready, otherwise false.
  17613. */
  17614. isReady(): boolean;
  17615. /**
  17616. * Renders the edges of the attached mesh,
  17617. */
  17618. render(): void;
  17619. }
  17620. /**
  17621. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17622. */
  17623. export class LineEdgesRenderer extends EdgesRenderer {
  17624. /**
  17625. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17626. * @param source LineMesh used to generate edges
  17627. * @param epsilon not important (specified angle for edge detection)
  17628. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17629. */
  17630. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17631. /**
  17632. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17633. */
  17634. _generateEdgesLines(): void;
  17635. }
  17636. }
  17637. declare module "babylonjs/Rendering/renderingGroup" {
  17638. import { SmartArray } from "babylonjs/Misc/smartArray";
  17639. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17640. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17641. import { Nullable } from "babylonjs/types";
  17642. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17643. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17644. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17645. import { Material } from "babylonjs/Materials/material";
  17646. import { Scene } from "babylonjs/scene";
  17647. /**
  17648. * This represents the object necessary to create a rendering group.
  17649. * This is exclusively used and created by the rendering manager.
  17650. * To modify the behavior, you use the available helpers in your scene or meshes.
  17651. * @hidden
  17652. */
  17653. export class RenderingGroup {
  17654. index: number;
  17655. private _scene;
  17656. private _opaqueSubMeshes;
  17657. private _transparentSubMeshes;
  17658. private _alphaTestSubMeshes;
  17659. private _depthOnlySubMeshes;
  17660. private _particleSystems;
  17661. private _spriteManagers;
  17662. private _opaqueSortCompareFn;
  17663. private _alphaTestSortCompareFn;
  17664. private _transparentSortCompareFn;
  17665. private _renderOpaque;
  17666. private _renderAlphaTest;
  17667. private _renderTransparent;
  17668. /** @hidden */
  17669. _edgesRenderers: SmartArray<IEdgesRenderer>;
  17670. onBeforeTransparentRendering: () => void;
  17671. /**
  17672. * Set the opaque sort comparison function.
  17673. * If null the sub meshes will be render in the order they were created
  17674. */
  17675. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17676. /**
  17677. * Set the alpha test sort comparison function.
  17678. * If null the sub meshes will be render in the order they were created
  17679. */
  17680. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17681. /**
  17682. * Set the transparent sort comparison function.
  17683. * If null the sub meshes will be render in the order they were created
  17684. */
  17685. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  17686. /**
  17687. * Creates a new rendering group.
  17688. * @param index The rendering group index
  17689. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17690. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17691. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17692. */
  17693. 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>);
  17694. /**
  17695. * Render all the sub meshes contained in the group.
  17696. * @param customRenderFunction Used to override the default render behaviour of the group.
  17697. * @returns true if rendered some submeshes.
  17698. */
  17699. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17700. /**
  17701. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17702. * @param subMeshes The submeshes to render
  17703. */
  17704. private renderOpaqueSorted;
  17705. /**
  17706. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17707. * @param subMeshes The submeshes to render
  17708. */
  17709. private renderAlphaTestSorted;
  17710. /**
  17711. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17712. * @param subMeshes The submeshes to render
  17713. */
  17714. private renderTransparentSorted;
  17715. /**
  17716. * Renders the submeshes in a specified order.
  17717. * @param subMeshes The submeshes to sort before render
  17718. * @param sortCompareFn The comparison function use to sort
  17719. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17720. * @param transparent Specifies to activate blending if true
  17721. */
  17722. private static renderSorted;
  17723. /**
  17724. * Renders the submeshes in the order they were dispatched (no sort applied).
  17725. * @param subMeshes The submeshes to render
  17726. */
  17727. private static renderUnsorted;
  17728. /**
  17729. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17730. * are rendered back to front if in the same alpha index.
  17731. *
  17732. * @param a The first submesh
  17733. * @param b The second submesh
  17734. * @returns The result of the comparison
  17735. */
  17736. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17737. /**
  17738. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17739. * are rendered back to front.
  17740. *
  17741. * @param a The first submesh
  17742. * @param b The second submesh
  17743. * @returns The result of the comparison
  17744. */
  17745. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17746. /**
  17747. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17748. * are rendered front to back (prevent overdraw).
  17749. *
  17750. * @param a The first submesh
  17751. * @param b The second submesh
  17752. * @returns The result of the comparison
  17753. */
  17754. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17755. /**
  17756. * Resets the different lists of submeshes to prepare a new frame.
  17757. */
  17758. prepare(): void;
  17759. dispose(): void;
  17760. /**
  17761. * Inserts the submesh in its correct queue depending on its material.
  17762. * @param subMesh The submesh to dispatch
  17763. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17764. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17765. */
  17766. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17767. dispatchSprites(spriteManager: ISpriteManager): void;
  17768. dispatchParticles(particleSystem: IParticleSystem): void;
  17769. private _renderParticles;
  17770. private _renderSprites;
  17771. }
  17772. }
  17773. declare module "babylonjs/Rendering/renderingManager" {
  17774. import { Nullable } from "babylonjs/types";
  17775. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17776. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17777. import { SmartArray } from "babylonjs/Misc/smartArray";
  17778. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17779. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17780. import { Material } from "babylonjs/Materials/material";
  17781. import { Scene } from "babylonjs/scene";
  17782. import { Camera } from "babylonjs/Cameras/camera";
  17783. /**
  17784. * Interface describing the different options available in the rendering manager
  17785. * regarding Auto Clear between groups.
  17786. */
  17787. export interface IRenderingManagerAutoClearSetup {
  17788. /**
  17789. * Defines whether or not autoclear is enable.
  17790. */
  17791. autoClear: boolean;
  17792. /**
  17793. * Defines whether or not to autoclear the depth buffer.
  17794. */
  17795. depth: boolean;
  17796. /**
  17797. * Defines whether or not to autoclear the stencil buffer.
  17798. */
  17799. stencil: boolean;
  17800. }
  17801. /**
  17802. * This class is used by the onRenderingGroupObservable
  17803. */
  17804. export class RenderingGroupInfo {
  17805. /**
  17806. * The Scene that being rendered
  17807. */
  17808. scene: Scene;
  17809. /**
  17810. * The camera currently used for the rendering pass
  17811. */
  17812. camera: Nullable<Camera>;
  17813. /**
  17814. * The ID of the renderingGroup being processed
  17815. */
  17816. renderingGroupId: number;
  17817. }
  17818. /**
  17819. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17820. * It is enable to manage the different groups as well as the different necessary sort functions.
  17821. * This should not be used directly aside of the few static configurations
  17822. */
  17823. export class RenderingManager {
  17824. /**
  17825. * The max id used for rendering groups (not included)
  17826. */
  17827. static MAX_RENDERINGGROUPS: number;
  17828. /**
  17829. * The min id used for rendering groups (included)
  17830. */
  17831. static MIN_RENDERINGGROUPS: number;
  17832. /**
  17833. * Used to globally prevent autoclearing scenes.
  17834. */
  17835. static AUTOCLEAR: boolean;
  17836. /**
  17837. * @hidden
  17838. */
  17839. _useSceneAutoClearSetup: boolean;
  17840. private _scene;
  17841. private _renderingGroups;
  17842. private _depthStencilBufferAlreadyCleaned;
  17843. private _autoClearDepthStencil;
  17844. private _customOpaqueSortCompareFn;
  17845. private _customAlphaTestSortCompareFn;
  17846. private _customTransparentSortCompareFn;
  17847. private _renderingGroupInfo;
  17848. /**
  17849. * Instantiates a new rendering group for a particular scene
  17850. * @param scene Defines the scene the groups belongs to
  17851. */
  17852. constructor(scene: Scene);
  17853. private _clearDepthStencilBuffer;
  17854. /**
  17855. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17856. * @hidden
  17857. */
  17858. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17859. /**
  17860. * Resets the different information of the group to prepare a new frame
  17861. * @hidden
  17862. */
  17863. reset(): void;
  17864. /**
  17865. * Dispose and release the group and its associated resources.
  17866. * @hidden
  17867. */
  17868. dispose(): void;
  17869. /**
  17870. * Clear the info related to rendering groups preventing retention points during dispose.
  17871. */
  17872. freeRenderingGroups(): void;
  17873. private _prepareRenderingGroup;
  17874. /**
  17875. * Add a sprite manager to the rendering manager in order to render it this frame.
  17876. * @param spriteManager Define the sprite manager to render
  17877. */
  17878. dispatchSprites(spriteManager: ISpriteManager): void;
  17879. /**
  17880. * Add a particle system to the rendering manager in order to render it this frame.
  17881. * @param particleSystem Define the particle system to render
  17882. */
  17883. dispatchParticles(particleSystem: IParticleSystem): void;
  17884. /**
  17885. * Add a submesh to the manager in order to render it this frame
  17886. * @param subMesh The submesh to dispatch
  17887. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17888. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17889. */
  17890. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17891. /**
  17892. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17893. * This allowed control for front to back rendering or reversly depending of the special needs.
  17894. *
  17895. * @param renderingGroupId The rendering group id corresponding to its index
  17896. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17897. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17898. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17899. */
  17900. 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;
  17901. /**
  17902. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17903. *
  17904. * @param renderingGroupId The rendering group id corresponding to its index
  17905. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17906. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17907. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17908. */
  17909. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17910. /**
  17911. * Gets the current auto clear configuration for one rendering group of the rendering
  17912. * manager.
  17913. * @param index the rendering group index to get the information for
  17914. * @returns The auto clear setup for the requested rendering group
  17915. */
  17916. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17917. }
  17918. }
  17919. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  17920. import { Observable } from "babylonjs/Misc/observable";
  17921. import { SmartArray } from "babylonjs/Misc/smartArray";
  17922. import { Nullable } from "babylonjs/types";
  17923. import { Camera } from "babylonjs/Cameras/camera";
  17924. import { Scene } from "babylonjs/scene";
  17925. import { Matrix, Vector3, Color4 } from "babylonjs/Maths/math";
  17926. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  17927. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17928. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17929. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  17930. import { Texture } from "babylonjs/Materials/Textures/texture";
  17931. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17932. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  17933. import { Engine } from "babylonjs/Engines/engine";
  17934. /**
  17935. * This Helps creating a texture that will be created from a camera in your scene.
  17936. * It is basically a dynamic texture that could be used to create special effects for instance.
  17937. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  17938. */
  17939. export class RenderTargetTexture extends Texture {
  17940. isCube: boolean;
  17941. /**
  17942. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  17943. */
  17944. static readonly REFRESHRATE_RENDER_ONCE: number;
  17945. /**
  17946. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  17947. */
  17948. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  17949. /**
  17950. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  17951. * the central point of your effect and can save a lot of performances.
  17952. */
  17953. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  17954. /**
  17955. * Use this predicate to dynamically define the list of mesh you want to render.
  17956. * If set, the renderList property will be overwritten.
  17957. */
  17958. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  17959. private _renderList;
  17960. /**
  17961. * Use this list to define the list of mesh you want to render.
  17962. */
  17963. renderList: Nullable<Array<AbstractMesh>>;
  17964. private _hookArray;
  17965. /**
  17966. * Define if particles should be rendered in your texture.
  17967. */
  17968. renderParticles: boolean;
  17969. /**
  17970. * Define if sprites should be rendered in your texture.
  17971. */
  17972. renderSprites: boolean;
  17973. /**
  17974. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  17975. */
  17976. coordinatesMode: number;
  17977. /**
  17978. * Define the camera used to render the texture.
  17979. */
  17980. activeCamera: Nullable<Camera>;
  17981. /**
  17982. * Override the render function of the texture with your own one.
  17983. */
  17984. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  17985. /**
  17986. * Define if camera post processes should be use while rendering the texture.
  17987. */
  17988. useCameraPostProcesses: boolean;
  17989. /**
  17990. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  17991. */
  17992. ignoreCameraViewport: boolean;
  17993. private _postProcessManager;
  17994. private _postProcesses;
  17995. private _resizeObserver;
  17996. /**
  17997. * An event triggered when the texture is unbind.
  17998. */
  17999. onBeforeBindObservable: Observable<RenderTargetTexture>;
  18000. /**
  18001. * An event triggered when the texture is unbind.
  18002. */
  18003. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  18004. private _onAfterUnbindObserver;
  18005. /**
  18006. * Set a after unbind callback in the texture.
  18007. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  18008. */
  18009. onAfterUnbind: () => void;
  18010. /**
  18011. * An event triggered before rendering the texture
  18012. */
  18013. onBeforeRenderObservable: Observable<number>;
  18014. private _onBeforeRenderObserver;
  18015. /**
  18016. * Set a before render callback in the texture.
  18017. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  18018. */
  18019. onBeforeRender: (faceIndex: number) => void;
  18020. /**
  18021. * An event triggered after rendering the texture
  18022. */
  18023. onAfterRenderObservable: Observable<number>;
  18024. private _onAfterRenderObserver;
  18025. /**
  18026. * Set a after render callback in the texture.
  18027. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  18028. */
  18029. onAfterRender: (faceIndex: number) => void;
  18030. /**
  18031. * An event triggered after the texture clear
  18032. */
  18033. onClearObservable: Observable<import("babylonjs/Engines/engine").Engine>;
  18034. private _onClearObserver;
  18035. /**
  18036. * Set a clear callback in the texture.
  18037. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  18038. */
  18039. onClear: (Engine: Engine) => void;
  18040. /**
  18041. * Define the clear color of the Render Target if it should be different from the scene.
  18042. */
  18043. clearColor: Color4;
  18044. protected _size: number | {
  18045. width: number;
  18046. height: number;
  18047. };
  18048. protected _initialSizeParameter: number | {
  18049. width: number;
  18050. height: number;
  18051. } | {
  18052. ratio: number;
  18053. };
  18054. protected _sizeRatio: Nullable<number>;
  18055. /** @hidden */
  18056. _generateMipMaps: boolean;
  18057. protected _renderingManager: RenderingManager;
  18058. /** @hidden */
  18059. _waitingRenderList: string[];
  18060. protected _doNotChangeAspectRatio: boolean;
  18061. protected _currentRefreshId: number;
  18062. protected _refreshRate: number;
  18063. protected _textureMatrix: Matrix;
  18064. protected _samples: number;
  18065. protected _renderTargetOptions: RenderTargetCreationOptions;
  18066. /**
  18067. * Gets render target creation options that were used.
  18068. */
  18069. readonly renderTargetOptions: RenderTargetCreationOptions;
  18070. protected _engine: Engine;
  18071. protected _onRatioRescale(): void;
  18072. /**
  18073. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  18074. * It must define where the camera used to render the texture is set
  18075. */
  18076. boundingBoxPosition: Vector3;
  18077. private _boundingBoxSize;
  18078. /**
  18079. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  18080. * When defined, the cubemap will switch to local mode
  18081. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  18082. * @example https://www.babylonjs-playground.com/#RNASML
  18083. */
  18084. boundingBoxSize: Vector3;
  18085. /**
  18086. * In case the RTT has been created with a depth texture, get the associated
  18087. * depth texture.
  18088. * Otherwise, return null.
  18089. */
  18090. depthStencilTexture: Nullable<InternalTexture>;
  18091. /**
  18092. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  18093. * or used a shadow, depth texture...
  18094. * @param name The friendly name of the texture
  18095. * @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)
  18096. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  18097. * @param generateMipMaps True if mip maps need to be generated after render.
  18098. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  18099. * @param type The type of the buffer in the RTT (int, half float, float...)
  18100. * @param isCube True if a cube texture needs to be created
  18101. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  18102. * @param generateDepthBuffer True to generate a depth buffer
  18103. * @param generateStencilBuffer True to generate a stencil buffer
  18104. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  18105. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  18106. * @param delayAllocation if the texture allocation should be delayed (default: false)
  18107. */
  18108. constructor(name: string, size: number | {
  18109. width: number;
  18110. height: number;
  18111. } | {
  18112. ratio: number;
  18113. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  18114. /**
  18115. * Creates a depth stencil texture.
  18116. * This is only available in WebGL 2 or with the depth texture extension available.
  18117. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  18118. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  18119. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  18120. */
  18121. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  18122. private _processSizeParameter;
  18123. /**
  18124. * Define the number of samples to use in case of MSAA.
  18125. * It defaults to one meaning no MSAA has been enabled.
  18126. */
  18127. samples: number;
  18128. /**
  18129. * Resets the refresh counter of the texture and start bak from scratch.
  18130. * Could be useful to regenerate the texture if it is setup to render only once.
  18131. */
  18132. resetRefreshCounter(): void;
  18133. /**
  18134. * Define the refresh rate of the texture or the rendering frequency.
  18135. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  18136. */
  18137. refreshRate: number;
  18138. /**
  18139. * Adds a post process to the render target rendering passes.
  18140. * @param postProcess define the post process to add
  18141. */
  18142. addPostProcess(postProcess: PostProcess): void;
  18143. /**
  18144. * Clear all the post processes attached to the render target
  18145. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  18146. */
  18147. clearPostProcesses(dispose?: boolean): void;
  18148. /**
  18149. * Remove one of the post process from the list of attached post processes to the texture
  18150. * @param postProcess define the post process to remove from the list
  18151. */
  18152. removePostProcess(postProcess: PostProcess): void;
  18153. /** @hidden */
  18154. _shouldRender(): boolean;
  18155. /**
  18156. * Gets the actual render size of the texture.
  18157. * @returns the width of the render size
  18158. */
  18159. getRenderSize(): number;
  18160. /**
  18161. * Gets the actual render width of the texture.
  18162. * @returns the width of the render size
  18163. */
  18164. getRenderWidth(): number;
  18165. /**
  18166. * Gets the actual render height of the texture.
  18167. * @returns the height of the render size
  18168. */
  18169. getRenderHeight(): number;
  18170. /**
  18171. * Get if the texture can be rescaled or not.
  18172. */
  18173. readonly canRescale: boolean;
  18174. /**
  18175. * Resize the texture using a ratio.
  18176. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  18177. */
  18178. scale(ratio: number): void;
  18179. /**
  18180. * Get the texture reflection matrix used to rotate/transform the reflection.
  18181. * @returns the reflection matrix
  18182. */
  18183. getReflectionTextureMatrix(): Matrix;
  18184. /**
  18185. * Resize the texture to a new desired size.
  18186. * Be carrefull as it will recreate all the data in the new texture.
  18187. * @param size Define the new size. It can be:
  18188. * - a number for squared texture,
  18189. * - an object containing { width: number, height: number }
  18190. * - or an object containing a ratio { ratio: number }
  18191. */
  18192. resize(size: number | {
  18193. width: number;
  18194. height: number;
  18195. } | {
  18196. ratio: number;
  18197. }): void;
  18198. /**
  18199. * Renders all the objects from the render list into the texture.
  18200. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  18201. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  18202. */
  18203. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  18204. private _bestReflectionRenderTargetDimension;
  18205. /**
  18206. * @hidden
  18207. * @param faceIndex face index to bind to if this is a cubetexture
  18208. */
  18209. _bindFrameBuffer(faceIndex?: number): void;
  18210. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  18211. private renderToTarget;
  18212. /**
  18213. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  18214. * This allowed control for front to back rendering or reversly depending of the special needs.
  18215. *
  18216. * @param renderingGroupId The rendering group id corresponding to its index
  18217. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  18218. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  18219. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  18220. */
  18221. 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;
  18222. /**
  18223. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  18224. *
  18225. * @param renderingGroupId The rendering group id corresponding to its index
  18226. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  18227. */
  18228. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  18229. /**
  18230. * Clones the texture.
  18231. * @returns the cloned texture
  18232. */
  18233. clone(): RenderTargetTexture;
  18234. /**
  18235. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18236. * @returns The JSON representation of the texture
  18237. */
  18238. serialize(): any;
  18239. /**
  18240. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  18241. */
  18242. disposeFramebufferObjects(): void;
  18243. /**
  18244. * Dispose the texture and release its associated resources.
  18245. */
  18246. dispose(): void;
  18247. /** @hidden */
  18248. _rebuild(): void;
  18249. /**
  18250. * Clear the info related to rendering groups preventing retention point in material dispose.
  18251. */
  18252. freeRenderingGroups(): void;
  18253. /**
  18254. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  18255. * @returns the view count
  18256. */
  18257. getViewCount(): number;
  18258. }
  18259. }
  18260. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  18261. import { Scene } from "babylonjs/scene";
  18262. import { Plane } from "babylonjs/Maths/math";
  18263. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  18264. /**
  18265. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18266. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18267. * You can then easily use it as a reflectionTexture on a flat surface.
  18268. * In case the surface is not a plane, please consider relying on reflection probes.
  18269. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18270. */
  18271. export class MirrorTexture extends RenderTargetTexture {
  18272. private scene;
  18273. /**
  18274. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  18275. * 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.
  18276. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18277. */
  18278. mirrorPlane: Plane;
  18279. /**
  18280. * Define the blur ratio used to blur the reflection if needed.
  18281. */
  18282. blurRatio: number;
  18283. /**
  18284. * Define the adaptive blur kernel used to blur the reflection if needed.
  18285. * This will autocompute the closest best match for the `blurKernel`
  18286. */
  18287. adaptiveBlurKernel: number;
  18288. /**
  18289. * Define the blur kernel used to blur the reflection if needed.
  18290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18291. */
  18292. blurKernel: number;
  18293. /**
  18294. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  18295. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18296. */
  18297. blurKernelX: number;
  18298. /**
  18299. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  18300. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  18301. */
  18302. blurKernelY: number;
  18303. private _autoComputeBlurKernel;
  18304. protected _onRatioRescale(): void;
  18305. private _updateGammaSpace;
  18306. private _imageProcessingConfigChangeObserver;
  18307. private _transformMatrix;
  18308. private _mirrorMatrix;
  18309. private _savedViewMatrix;
  18310. private _blurX;
  18311. private _blurY;
  18312. private _adaptiveBlurKernel;
  18313. private _blurKernelX;
  18314. private _blurKernelY;
  18315. private _blurRatio;
  18316. /**
  18317. * Instantiates a Mirror Texture.
  18318. * Mirror texture can be used to simulate the view from a mirror in a scene.
  18319. * It will dynamically be rendered every frame to adapt to the camera point of view.
  18320. * You can then easily use it as a reflectionTexture on a flat surface.
  18321. * In case the surface is not a plane, please consider relying on reflection probes.
  18322. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  18323. * @param name
  18324. * @param size
  18325. * @param scene
  18326. * @param generateMipMaps
  18327. * @param type
  18328. * @param samplingMode
  18329. * @param generateDepthBuffer
  18330. */
  18331. constructor(name: string, size: number | {
  18332. width: number;
  18333. height: number;
  18334. } | {
  18335. ratio: number;
  18336. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  18337. private _preparePostProcesses;
  18338. /**
  18339. * Clone the mirror texture.
  18340. * @returns the cloned texture
  18341. */
  18342. clone(): MirrorTexture;
  18343. /**
  18344. * Serialize the texture to a JSON representation you could use in Parse later on
  18345. * @returns the serialized JSON representation
  18346. */
  18347. serialize(): any;
  18348. /**
  18349. * Dispose the texture and release its associated resources.
  18350. */
  18351. dispose(): void;
  18352. }
  18353. }
  18354. declare module "babylonjs/Materials/Textures/texture" {
  18355. import { Observable } from "babylonjs/Misc/observable";
  18356. import { Nullable } from "babylonjs/types";
  18357. import { Scene } from "babylonjs/scene";
  18358. import { Matrix } from "babylonjs/Maths/math";
  18359. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  18360. import { IInspectable } from "babylonjs/Misc/iInspectable";
  18361. /**
  18362. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18363. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18364. */
  18365. export class Texture extends BaseTexture {
  18366. /** @hidden */
  18367. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => import("babylonjs/Materials/Textures/cubeTexture").CubeTexture;
  18368. /** @hidden */
  18369. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/mirrorTexture").MirrorTexture;
  18370. /** @hidden */
  18371. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture;
  18372. /** nearest is mag = nearest and min = nearest and mip = linear */
  18373. static readonly NEAREST_SAMPLINGMODE: number;
  18374. /** nearest is mag = nearest and min = nearest and mip = linear */
  18375. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  18376. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18377. static readonly BILINEAR_SAMPLINGMODE: number;
  18378. /** Bilinear is mag = linear and min = linear and mip = nearest */
  18379. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  18380. /** Trilinear is mag = linear and min = linear and mip = linear */
  18381. static readonly TRILINEAR_SAMPLINGMODE: number;
  18382. /** Trilinear is mag = linear and min = linear and mip = linear */
  18383. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  18384. /** mag = nearest and min = nearest and mip = nearest */
  18385. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  18386. /** mag = nearest and min = linear and mip = nearest */
  18387. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  18388. /** mag = nearest and min = linear and mip = linear */
  18389. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  18390. /** mag = nearest and min = linear and mip = none */
  18391. static readonly NEAREST_LINEAR: number;
  18392. /** mag = nearest and min = nearest and mip = none */
  18393. static readonly NEAREST_NEAREST: number;
  18394. /** mag = linear and min = nearest and mip = nearest */
  18395. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  18396. /** mag = linear and min = nearest and mip = linear */
  18397. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  18398. /** mag = linear and min = linear and mip = none */
  18399. static readonly LINEAR_LINEAR: number;
  18400. /** mag = linear and min = nearest and mip = none */
  18401. static readonly LINEAR_NEAREST: number;
  18402. /** Explicit coordinates mode */
  18403. static readonly EXPLICIT_MODE: number;
  18404. /** Spherical coordinates mode */
  18405. static readonly SPHERICAL_MODE: number;
  18406. /** Planar coordinates mode */
  18407. static readonly PLANAR_MODE: number;
  18408. /** Cubic coordinates mode */
  18409. static readonly CUBIC_MODE: number;
  18410. /** Projection coordinates mode */
  18411. static readonly PROJECTION_MODE: number;
  18412. /** Inverse Cubic coordinates mode */
  18413. static readonly SKYBOX_MODE: number;
  18414. /** Inverse Cubic coordinates mode */
  18415. static readonly INVCUBIC_MODE: number;
  18416. /** Equirectangular coordinates mode */
  18417. static readonly EQUIRECTANGULAR_MODE: number;
  18418. /** Equirectangular Fixed coordinates mode */
  18419. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  18420. /** Equirectangular Fixed Mirrored coordinates mode */
  18421. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  18422. /** Texture is not repeating outside of 0..1 UVs */
  18423. static readonly CLAMP_ADDRESSMODE: number;
  18424. /** Texture is repeating outside of 0..1 UVs */
  18425. static readonly WRAP_ADDRESSMODE: number;
  18426. /** Texture is repeating and mirrored */
  18427. static readonly MIRROR_ADDRESSMODE: number;
  18428. /**
  18429. * 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
  18430. */
  18431. static UseSerializedUrlIfAny: boolean;
  18432. /**
  18433. * Define the url of the texture.
  18434. */
  18435. url: Nullable<string>;
  18436. /**
  18437. * Define an offset on the texture to offset the u coordinates of the UVs
  18438. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18439. */
  18440. uOffset: number;
  18441. /**
  18442. * Define an offset on the texture to offset the v coordinates of the UVs
  18443. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  18444. */
  18445. vOffset: number;
  18446. /**
  18447. * Define an offset on the texture to scale the u coordinates of the UVs
  18448. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18449. */
  18450. uScale: number;
  18451. /**
  18452. * Define an offset on the texture to scale the v coordinates of the UVs
  18453. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  18454. */
  18455. vScale: number;
  18456. /**
  18457. * Define an offset on the texture to rotate around the u coordinates of the UVs
  18458. * @see http://doc.babylonjs.com/how_to/more_materials
  18459. */
  18460. uAng: number;
  18461. /**
  18462. * Define an offset on the texture to rotate around the v coordinates of the UVs
  18463. * @see http://doc.babylonjs.com/how_to/more_materials
  18464. */
  18465. vAng: number;
  18466. /**
  18467. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  18468. * @see http://doc.babylonjs.com/how_to/more_materials
  18469. */
  18470. wAng: number;
  18471. /**
  18472. * Defines the center of rotation (U)
  18473. */
  18474. uRotationCenter: number;
  18475. /**
  18476. * Defines the center of rotation (V)
  18477. */
  18478. vRotationCenter: number;
  18479. /**
  18480. * Defines the center of rotation (W)
  18481. */
  18482. wRotationCenter: number;
  18483. /**
  18484. * Are mip maps generated for this texture or not.
  18485. */
  18486. readonly noMipmap: boolean;
  18487. /**
  18488. * List of inspectable custom properties (used by the Inspector)
  18489. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  18490. */
  18491. inspectableCustomProperties: Nullable<IInspectable[]>;
  18492. private _noMipmap;
  18493. /** @hidden */
  18494. _invertY: boolean;
  18495. private _rowGenerationMatrix;
  18496. private _cachedTextureMatrix;
  18497. private _projectionModeMatrix;
  18498. private _t0;
  18499. private _t1;
  18500. private _t2;
  18501. private _cachedUOffset;
  18502. private _cachedVOffset;
  18503. private _cachedUScale;
  18504. private _cachedVScale;
  18505. private _cachedUAng;
  18506. private _cachedVAng;
  18507. private _cachedWAng;
  18508. private _cachedProjectionMatrixId;
  18509. private _cachedCoordinatesMode;
  18510. /** @hidden */
  18511. protected _initialSamplingMode: number;
  18512. /** @hidden */
  18513. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  18514. private _deleteBuffer;
  18515. protected _format: Nullable<number>;
  18516. private _delayedOnLoad;
  18517. private _delayedOnError;
  18518. /**
  18519. * Observable triggered once the texture has been loaded.
  18520. */
  18521. onLoadObservable: Observable<Texture>;
  18522. protected _isBlocking: boolean;
  18523. /**
  18524. * Is the texture preventing material to render while loading.
  18525. * If false, a default texture will be used instead of the loading one during the preparation step.
  18526. */
  18527. isBlocking: boolean;
  18528. /**
  18529. * Get the current sampling mode associated with the texture.
  18530. */
  18531. readonly samplingMode: number;
  18532. /**
  18533. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  18534. */
  18535. readonly invertY: boolean;
  18536. /**
  18537. * Instantiates a new texture.
  18538. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  18539. * @see http://doc.babylonjs.com/babylon101/materials#texture
  18540. * @param url define the url of the picture to load as a texture
  18541. * @param scene define the scene the texture will belong to
  18542. * @param noMipmap define if the texture will require mip maps or not
  18543. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18544. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18545. * @param onLoad define a callback triggered when the texture has been loaded
  18546. * @param onError define a callback triggered when an error occurred during the loading session
  18547. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18548. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18549. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18550. */
  18551. 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);
  18552. /**
  18553. * Update the url (and optional buffer) of this texture if url was null during construction.
  18554. * @param url the url of the texture
  18555. * @param buffer the buffer of the texture (defaults to null)
  18556. * @param onLoad callback called when the texture is loaded (defaults to null)
  18557. */
  18558. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  18559. /**
  18560. * Finish the loading sequence of a texture flagged as delayed load.
  18561. * @hidden
  18562. */
  18563. delayLoad(): void;
  18564. private _prepareRowForTextureGeneration;
  18565. /**
  18566. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  18567. * @returns the transform matrix of the texture.
  18568. */
  18569. getTextureMatrix(): Matrix;
  18570. /**
  18571. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  18572. * @returns The reflection texture transform
  18573. */
  18574. getReflectionTextureMatrix(): Matrix;
  18575. /**
  18576. * Clones the texture.
  18577. * @returns the cloned texture
  18578. */
  18579. clone(): Texture;
  18580. /**
  18581. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  18582. * @returns The JSON representation of the texture
  18583. */
  18584. serialize(): any;
  18585. /**
  18586. * Get the current class name of the texture useful for serialization or dynamic coding.
  18587. * @returns "Texture"
  18588. */
  18589. getClassName(): string;
  18590. /**
  18591. * Dispose the texture and release its associated resources.
  18592. */
  18593. dispose(): void;
  18594. /**
  18595. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  18596. * @param parsedTexture Define the JSON representation of the texture
  18597. * @param scene Define the scene the parsed texture should be instantiated in
  18598. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  18599. * @returns The parsed texture if successful
  18600. */
  18601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  18602. /**
  18603. * Creates a texture from its base 64 representation.
  18604. * @param data Define the base64 payload without the data: prefix
  18605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18606. * @param scene Define the scene the texture should belong to
  18607. * @param noMipmap Forces the texture to not create mip map information if true
  18608. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18609. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18610. * @param onLoad define a callback triggered when the texture has been loaded
  18611. * @param onError define a callback triggered when an error occurred during the loading session
  18612. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18613. * @returns the created texture
  18614. */
  18615. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  18616. /**
  18617. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  18618. * @param data Define the base64 payload without the data: prefix
  18619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  18620. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  18621. * @param scene Define the scene the texture should belong to
  18622. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  18623. * @param noMipmap Forces the texture to not create mip map information if true
  18624. * @param invertY define if the texture needs to be inverted on the y axis during loading
  18625. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  18626. * @param onLoad define a callback triggered when the texture has been loaded
  18627. * @param onError define a callback triggered when an error occurred during the loading session
  18628. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  18629. * @returns the created texture
  18630. */
  18631. 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;
  18632. }
  18633. }
  18634. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  18635. import { Nullable } from "babylonjs/types";
  18636. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  18637. import { Scene } from "babylonjs/scene";
  18638. module "babylonjs/Engines/engine" {
  18639. interface Engine {
  18640. /**
  18641. * Creates a raw texture
  18642. * @param data defines the data to store in the texture
  18643. * @param width defines the width of the texture
  18644. * @param height defines the height of the texture
  18645. * @param format defines the format of the data
  18646. * @param generateMipMaps defines if the engine should generate the mip levels
  18647. * @param invertY defines if data must be stored with Y axis inverted
  18648. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  18649. * @param compression defines the compression used (null by default)
  18650. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18651. * @returns the raw texture inside an InternalTexture
  18652. */
  18653. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  18654. /**
  18655. * Update a raw texture
  18656. * @param texture defines the texture to update
  18657. * @param data defines the data to store in the texture
  18658. * @param format defines the format of the data
  18659. * @param invertY defines if data must be stored with Y axis inverted
  18660. */
  18661. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18662. /**
  18663. * Update a raw texture
  18664. * @param texture defines the texture to update
  18665. * @param data defines the data to store in the texture
  18666. * @param format defines the format of the data
  18667. * @param invertY defines if data must be stored with Y axis inverted
  18668. * @param compression defines the compression used (null by default)
  18669. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18670. */
  18671. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  18672. /**
  18673. * Creates a new raw cube texture
  18674. * @param data defines the array of data to use to create each face
  18675. * @param size defines the size of the textures
  18676. * @param format defines the format of the data
  18677. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18678. * @param generateMipMaps defines if the engine should generate the mip levels
  18679. * @param invertY defines if data must be stored with Y axis inverted
  18680. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18681. * @param compression defines the compression used (null by default)
  18682. * @returns the cube texture as an InternalTexture
  18683. */
  18684. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  18685. /**
  18686. * Update a raw cube texture
  18687. * @param texture defines the texture to udpdate
  18688. * @param data defines the data to store
  18689. * @param format defines the data format
  18690. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18691. * @param invertY defines if data must be stored with Y axis inverted
  18692. */
  18693. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  18694. /**
  18695. * Update a raw cube texture
  18696. * @param texture defines the texture to udpdate
  18697. * @param data defines the data to store
  18698. * @param format defines the data format
  18699. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18700. * @param invertY defines if data must be stored with Y axis inverted
  18701. * @param compression defines the compression used (null by default)
  18702. */
  18703. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  18704. /**
  18705. * Update a raw cube texture
  18706. * @param texture defines the texture to udpdate
  18707. * @param data defines the data to store
  18708. * @param format defines the data format
  18709. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  18710. * @param invertY defines if data must be stored with Y axis inverted
  18711. * @param compression defines the compression used (null by default)
  18712. * @param level defines which level of the texture to update
  18713. */
  18714. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  18715. /**
  18716. * Creates a new raw cube texture from a specified url
  18717. * @param url defines the url where the data is located
  18718. * @param scene defines the current scene
  18719. * @param size defines the size of the textures
  18720. * @param format defines the format of the data
  18721. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18722. * @param noMipmap defines if the engine should avoid generating the mip levels
  18723. * @param callback defines a callback used to extract texture data from loaded data
  18724. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18725. * @param onLoad defines a callback called when texture is loaded
  18726. * @param onError defines a callback called if there is an error
  18727. * @returns the cube texture as an InternalTexture
  18728. */
  18729. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  18730. /**
  18731. * Creates a new raw cube texture from a specified url
  18732. * @param url defines the url where the data is located
  18733. * @param scene defines the current scene
  18734. * @param size defines the size of the textures
  18735. * @param format defines the format of the data
  18736. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  18737. * @param noMipmap defines if the engine should avoid generating the mip levels
  18738. * @param callback defines a callback used to extract texture data from loaded data
  18739. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  18740. * @param onLoad defines a callback called when texture is loaded
  18741. * @param onError defines a callback called if there is an error
  18742. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18743. * @param invertY defines if data must be stored with Y axis inverted
  18744. * @returns the cube texture as an InternalTexture
  18745. */
  18746. 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;
  18747. /**
  18748. * Creates a new raw 3D texture
  18749. * @param data defines the data used to create the texture
  18750. * @param width defines the width of the texture
  18751. * @param height defines the height of the texture
  18752. * @param depth defines the depth of the texture
  18753. * @param format defines the format of the texture
  18754. * @param generateMipMaps defines if the engine must generate mip levels
  18755. * @param invertY defines if data must be stored with Y axis inverted
  18756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  18757. * @param compression defines the compressed used (can be null)
  18758. * @param textureType defines the compressed used (can be null)
  18759. * @returns a new raw 3D texture (stored in an InternalTexture)
  18760. */
  18761. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  18762. /**
  18763. * Update a raw 3D texture
  18764. * @param texture defines the texture to update
  18765. * @param data defines the data to store
  18766. * @param format defines the data format
  18767. * @param invertY defines if data must be stored with Y axis inverted
  18768. */
  18769. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  18770. /**
  18771. * Update a raw 3D texture
  18772. * @param texture defines the texture to update
  18773. * @param data defines the data to store
  18774. * @param format defines the data format
  18775. * @param invertY defines if data must be stored with Y axis inverted
  18776. * @param compression defines the used compression (can be null)
  18777. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  18778. */
  18779. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  18780. }
  18781. }
  18782. }
  18783. declare module "babylonjs/Materials/Textures/rawTexture" {
  18784. import { Scene } from "babylonjs/scene";
  18785. import { Texture } from "babylonjs/Materials/Textures/texture";
  18786. import "babylonjs/Engines/Extensions/engine.rawTexture";
  18787. /**
  18788. * Raw texture can help creating a texture directly from an array of data.
  18789. * This can be super useful if you either get the data from an uncompressed source or
  18790. * if you wish to create your texture pixel by pixel.
  18791. */
  18792. export class RawTexture extends Texture {
  18793. /**
  18794. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18795. */
  18796. format: number;
  18797. private _engine;
  18798. /**
  18799. * Instantiates a new RawTexture.
  18800. * Raw texture can help creating a texture directly from an array of data.
  18801. * This can be super useful if you either get the data from an uncompressed source or
  18802. * if you wish to create your texture pixel by pixel.
  18803. * @param data define the array of data to use to create the texture
  18804. * @param width define the width of the texture
  18805. * @param height define the height of the texture
  18806. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18807. * @param scene define the scene the texture belongs to
  18808. * @param generateMipMaps define whether mip maps should be generated or not
  18809. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18810. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18811. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18812. */
  18813. constructor(data: ArrayBufferView, width: number, height: number,
  18814. /**
  18815. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  18816. */
  18817. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  18818. /**
  18819. * Updates the texture underlying data.
  18820. * @param data Define the new data of the texture
  18821. */
  18822. update(data: ArrayBufferView): void;
  18823. /**
  18824. * Creates a luminance texture from some data.
  18825. * @param data Define the texture data
  18826. * @param width Define the width of the texture
  18827. * @param height Define the height of the texture
  18828. * @param scene Define the scene the texture belongs to
  18829. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18830. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18831. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18832. * @returns the luminance texture
  18833. */
  18834. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18835. /**
  18836. * Creates a luminance alpha texture from some data.
  18837. * @param data Define the texture data
  18838. * @param width Define the width of the texture
  18839. * @param height Define the height of the texture
  18840. * @param scene Define the scene the texture belongs to
  18841. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18842. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18843. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18844. * @returns the luminance alpha texture
  18845. */
  18846. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18847. /**
  18848. * Creates an alpha texture from some data.
  18849. * @param data Define the texture data
  18850. * @param width Define the width of the texture
  18851. * @param height Define the height of the texture
  18852. * @param scene Define the scene the texture belongs to
  18853. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18854. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18855. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18856. * @returns the alpha texture
  18857. */
  18858. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  18859. /**
  18860. * Creates a RGB texture from some data.
  18861. * @param data Define the texture data
  18862. * @param width Define the width of the texture
  18863. * @param height Define the height of the texture
  18864. * @param scene Define the scene the texture belongs to
  18865. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18866. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18867. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18868. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18869. * @returns the RGB alpha texture
  18870. */
  18871. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18872. /**
  18873. * Creates a RGBA texture from some data.
  18874. * @param data Define the texture data
  18875. * @param width Define the width of the texture
  18876. * @param height Define the height of the texture
  18877. * @param scene Define the scene the texture belongs to
  18878. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18879. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18880. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18881. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18882. * @returns the RGBA texture
  18883. */
  18884. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18885. /**
  18886. * Creates a R texture from some data.
  18887. * @param data Define the texture data
  18888. * @param width Define the width of the texture
  18889. * @param height Define the height of the texture
  18890. * @param scene Define the scene the texture belongs to
  18891. * @param generateMipMaps Define whether or not to create mip maps for the texture
  18892. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  18893. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  18894. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  18895. * @returns the R texture
  18896. */
  18897. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  18898. }
  18899. }
  18900. declare module "babylonjs/Animations/runtimeAnimation" {
  18901. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  18902. import { Animatable } from "babylonjs/Animations/animatable";
  18903. import { Scene } from "babylonjs/scene";
  18904. /**
  18905. * Defines a runtime animation
  18906. */
  18907. export class RuntimeAnimation {
  18908. private _events;
  18909. /**
  18910. * The current frame of the runtime animation
  18911. */
  18912. private _currentFrame;
  18913. /**
  18914. * The animation used by the runtime animation
  18915. */
  18916. private _animation;
  18917. /**
  18918. * The target of the runtime animation
  18919. */
  18920. private _target;
  18921. /**
  18922. * The initiating animatable
  18923. */
  18924. private _host;
  18925. /**
  18926. * The original value of the runtime animation
  18927. */
  18928. private _originalValue;
  18929. /**
  18930. * The original blend value of the runtime animation
  18931. */
  18932. private _originalBlendValue;
  18933. /**
  18934. * The offsets cache of the runtime animation
  18935. */
  18936. private _offsetsCache;
  18937. /**
  18938. * The high limits cache of the runtime animation
  18939. */
  18940. private _highLimitsCache;
  18941. /**
  18942. * Specifies if the runtime animation has been stopped
  18943. */
  18944. private _stopped;
  18945. /**
  18946. * The blending factor of the runtime animation
  18947. */
  18948. private _blendingFactor;
  18949. /**
  18950. * The BabylonJS scene
  18951. */
  18952. private _scene;
  18953. /**
  18954. * The current value of the runtime animation
  18955. */
  18956. private _currentValue;
  18957. /** @hidden */
  18958. _animationState: _IAnimationState;
  18959. /**
  18960. * The active target of the runtime animation
  18961. */
  18962. private _activeTargets;
  18963. private _currentActiveTarget;
  18964. private _directTarget;
  18965. /**
  18966. * The target path of the runtime animation
  18967. */
  18968. private _targetPath;
  18969. /**
  18970. * The weight of the runtime animation
  18971. */
  18972. private _weight;
  18973. /**
  18974. * The ratio offset of the runtime animation
  18975. */
  18976. private _ratioOffset;
  18977. /**
  18978. * The previous delay of the runtime animation
  18979. */
  18980. private _previousDelay;
  18981. /**
  18982. * The previous ratio of the runtime animation
  18983. */
  18984. private _previousRatio;
  18985. private _enableBlending;
  18986. private _keys;
  18987. private _minFrame;
  18988. private _maxFrame;
  18989. private _minValue;
  18990. private _maxValue;
  18991. private _targetIsArray;
  18992. /**
  18993. * Gets the current frame of the runtime animation
  18994. */
  18995. readonly currentFrame: number;
  18996. /**
  18997. * Gets the weight of the runtime animation
  18998. */
  18999. readonly weight: number;
  19000. /**
  19001. * Gets the current value of the runtime animation
  19002. */
  19003. readonly currentValue: any;
  19004. /**
  19005. * Gets the target path of the runtime animation
  19006. */
  19007. readonly targetPath: string;
  19008. /**
  19009. * Gets the actual target of the runtime animation
  19010. */
  19011. readonly target: any;
  19012. /** @hidden */
  19013. _onLoop: () => void;
  19014. /**
  19015. * Create a new RuntimeAnimation object
  19016. * @param target defines the target of the animation
  19017. * @param animation defines the source animation object
  19018. * @param scene defines the hosting scene
  19019. * @param host defines the initiating Animatable
  19020. */
  19021. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  19022. private _preparePath;
  19023. /**
  19024. * Gets the animation from the runtime animation
  19025. */
  19026. readonly animation: Animation;
  19027. /**
  19028. * Resets the runtime animation to the beginning
  19029. * @param restoreOriginal defines whether to restore the target property to the original value
  19030. */
  19031. reset(restoreOriginal?: boolean): void;
  19032. /**
  19033. * Specifies if the runtime animation is stopped
  19034. * @returns Boolean specifying if the runtime animation is stopped
  19035. */
  19036. isStopped(): boolean;
  19037. /**
  19038. * Disposes of the runtime animation
  19039. */
  19040. dispose(): void;
  19041. /**
  19042. * Apply the interpolated value to the target
  19043. * @param currentValue defines the value computed by the animation
  19044. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  19045. */
  19046. setValue(currentValue: any, weight: number): void;
  19047. private _getOriginalValues;
  19048. private _setValue;
  19049. /**
  19050. * Gets the loop pmode of the runtime animation
  19051. * @returns Loop Mode
  19052. */
  19053. private _getCorrectLoopMode;
  19054. /**
  19055. * Move the current animation to a given frame
  19056. * @param frame defines the frame to move to
  19057. */
  19058. goToFrame(frame: number): void;
  19059. /**
  19060. * @hidden Internal use only
  19061. */
  19062. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  19063. /**
  19064. * Execute the current animation
  19065. * @param delay defines the delay to add to the current frame
  19066. * @param from defines the lower bound of the animation range
  19067. * @param to defines the upper bound of the animation range
  19068. * @param loop defines if the current animation must loop
  19069. * @param speedRatio defines the current speed ratio
  19070. * @param weight defines the weight of the animation (default is -1 so no weight)
  19071. * @param onLoop optional callback called when animation loops
  19072. * @returns a boolean indicating if the animation is running
  19073. */
  19074. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  19075. }
  19076. }
  19077. declare module "babylonjs/Animations/animatable" {
  19078. import { Animation } from "babylonjs/Animations/animation";
  19079. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  19080. import { Nullable } from "babylonjs/types";
  19081. import { Observable } from "babylonjs/Misc/observable";
  19082. import { Scene } from "babylonjs/scene";
  19083. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math";
  19084. import { Node } from "babylonjs/node";
  19085. /**
  19086. * Class used to store an actual running animation
  19087. */
  19088. export class Animatable {
  19089. /** defines the target object */
  19090. target: any;
  19091. /** defines the starting frame number (default is 0) */
  19092. fromFrame: number;
  19093. /** defines the ending frame number (default is 100) */
  19094. toFrame: number;
  19095. /** defines if the animation must loop (default is false) */
  19096. loopAnimation: boolean;
  19097. /** defines a callback to call when animation ends if it is not looping */
  19098. onAnimationEnd?: (() => void) | null | undefined;
  19099. /** defines a callback to call when animation loops */
  19100. onAnimationLoop?: (() => void) | null | undefined;
  19101. private _localDelayOffset;
  19102. private _pausedDelay;
  19103. private _runtimeAnimations;
  19104. private _paused;
  19105. private _scene;
  19106. private _speedRatio;
  19107. private _weight;
  19108. private _syncRoot;
  19109. /**
  19110. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  19111. * This will only apply for non looping animation (default is true)
  19112. */
  19113. disposeOnEnd: boolean;
  19114. /**
  19115. * Gets a boolean indicating if the animation has started
  19116. */
  19117. animationStarted: boolean;
  19118. /**
  19119. * Observer raised when the animation ends
  19120. */
  19121. onAnimationEndObservable: Observable<Animatable>;
  19122. /**
  19123. * Observer raised when the animation loops
  19124. */
  19125. onAnimationLoopObservable: Observable<Animatable>;
  19126. /**
  19127. * Gets the root Animatable used to synchronize and normalize animations
  19128. */
  19129. readonly syncRoot: Nullable<Animatable>;
  19130. /**
  19131. * Gets the current frame of the first RuntimeAnimation
  19132. * Used to synchronize Animatables
  19133. */
  19134. readonly masterFrame: number;
  19135. /**
  19136. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  19137. */
  19138. weight: number;
  19139. /**
  19140. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  19141. */
  19142. speedRatio: number;
  19143. /**
  19144. * Creates a new Animatable
  19145. * @param scene defines the hosting scene
  19146. * @param target defines the target object
  19147. * @param fromFrame defines the starting frame number (default is 0)
  19148. * @param toFrame defines the ending frame number (default is 100)
  19149. * @param loopAnimation defines if the animation must loop (default is false)
  19150. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  19151. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  19152. * @param animations defines a group of animation to add to the new Animatable
  19153. * @param onAnimationLoop defines a callback to call when animation loops
  19154. */
  19155. constructor(scene: Scene,
  19156. /** defines the target object */
  19157. target: any,
  19158. /** defines the starting frame number (default is 0) */
  19159. fromFrame?: number,
  19160. /** defines the ending frame number (default is 100) */
  19161. toFrame?: number,
  19162. /** defines if the animation must loop (default is false) */
  19163. loopAnimation?: boolean, speedRatio?: number,
  19164. /** defines a callback to call when animation ends if it is not looping */
  19165. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  19166. /** defines a callback to call when animation loops */
  19167. onAnimationLoop?: (() => void) | null | undefined);
  19168. /**
  19169. * Synchronize and normalize current Animatable with a source Animatable
  19170. * This is useful when using animation weights and when animations are not of the same length
  19171. * @param root defines the root Animatable to synchronize with
  19172. * @returns the current Animatable
  19173. */
  19174. syncWith(root: Animatable): Animatable;
  19175. /**
  19176. * Gets the list of runtime animations
  19177. * @returns an array of RuntimeAnimation
  19178. */
  19179. getAnimations(): RuntimeAnimation[];
  19180. /**
  19181. * Adds more animations to the current animatable
  19182. * @param target defines the target of the animations
  19183. * @param animations defines the new animations to add
  19184. */
  19185. appendAnimations(target: any, animations: Animation[]): void;
  19186. /**
  19187. * Gets the source animation for a specific property
  19188. * @param property defines the propertyu to look for
  19189. * @returns null or the source animation for the given property
  19190. */
  19191. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  19192. /**
  19193. * Gets the runtime animation for a specific property
  19194. * @param property defines the propertyu to look for
  19195. * @returns null or the runtime animation for the given property
  19196. */
  19197. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  19198. /**
  19199. * Resets the animatable to its original state
  19200. */
  19201. reset(): void;
  19202. /**
  19203. * Allows the animatable to blend with current running animations
  19204. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19205. * @param blendingSpeed defines the blending speed to use
  19206. */
  19207. enableBlending(blendingSpeed: number): void;
  19208. /**
  19209. * Disable animation blending
  19210. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19211. */
  19212. disableBlending(): void;
  19213. /**
  19214. * Jump directly to a given frame
  19215. * @param frame defines the frame to jump to
  19216. */
  19217. goToFrame(frame: number): void;
  19218. /**
  19219. * Pause the animation
  19220. */
  19221. pause(): void;
  19222. /**
  19223. * Restart the animation
  19224. */
  19225. restart(): void;
  19226. private _raiseOnAnimationEnd;
  19227. /**
  19228. * Stop and delete the current animation
  19229. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  19230. * @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)
  19231. */
  19232. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  19233. /**
  19234. * Wait asynchronously for the animation to end
  19235. * @returns a promise which will be fullfilled when the animation ends
  19236. */
  19237. waitAsync(): Promise<Animatable>;
  19238. /** @hidden */
  19239. _animate(delay: number): boolean;
  19240. }
  19241. module "babylonjs/scene" {
  19242. interface Scene {
  19243. /** @hidden */
  19244. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  19245. /** @hidden */
  19246. _processLateAnimationBindingsForMatrices(holder: {
  19247. totalWeight: number;
  19248. animations: RuntimeAnimation[];
  19249. originalValue: Matrix;
  19250. }): any;
  19251. /** @hidden */
  19252. _processLateAnimationBindingsForQuaternions(holder: {
  19253. totalWeight: number;
  19254. animations: RuntimeAnimation[];
  19255. originalValue: Quaternion;
  19256. }, refQuaternion: Quaternion): Quaternion;
  19257. /** @hidden */
  19258. _processLateAnimationBindings(): void;
  19259. /**
  19260. * Will start the animation sequence of a given target
  19261. * @param target defines the target
  19262. * @param from defines from which frame should animation start
  19263. * @param to defines until which frame should animation run.
  19264. * @param weight defines the weight to apply to the animation (1.0 by default)
  19265. * @param loop defines if the animation loops
  19266. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19267. * @param onAnimationEnd defines the function to be executed when the animation ends
  19268. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19269. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19270. * @param onAnimationLoop defines the callback to call when an animation loops
  19271. * @returns the animatable object created for this animation
  19272. */
  19273. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19274. /**
  19275. * Will start the animation sequence of a given target
  19276. * @param target defines the target
  19277. * @param from defines from which frame should animation start
  19278. * @param to defines until which frame should animation run.
  19279. * @param loop defines if the animation loops
  19280. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19281. * @param onAnimationEnd defines the function to be executed when the animation ends
  19282. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19283. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19284. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  19285. * @param onAnimationLoop defines the callback to call when an animation loops
  19286. * @returns the animatable object created for this animation
  19287. */
  19288. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  19289. /**
  19290. * Will start the animation sequence of a given target and its hierarchy
  19291. * @param target defines the target
  19292. * @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.
  19293. * @param from defines from which frame should animation start
  19294. * @param to defines until which frame should animation run.
  19295. * @param loop defines if the animation loops
  19296. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  19297. * @param onAnimationEnd defines the function to be executed when the animation ends
  19298. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  19299. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  19300. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  19301. * @param onAnimationLoop defines the callback to call when an animation loops
  19302. * @returns the list of created animatables
  19303. */
  19304. 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[];
  19305. /**
  19306. * Begin a new animation on a given node
  19307. * @param target defines the target where the animation will take place
  19308. * @param animations defines the list of animations to start
  19309. * @param from defines the initial value
  19310. * @param to defines the final value
  19311. * @param loop defines if you want animation to loop (off by default)
  19312. * @param speedRatio defines the speed ratio to apply to all animations
  19313. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19314. * @param onAnimationLoop defines the callback to call when an animation loops
  19315. * @returns the list of created animatables
  19316. */
  19317. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  19318. /**
  19319. * Begin a new animation on a given node and its hierarchy
  19320. * @param target defines the root node where the animation will take place
  19321. * @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.
  19322. * @param animations defines the list of animations to start
  19323. * @param from defines the initial value
  19324. * @param to defines the final value
  19325. * @param loop defines if you want animation to loop (off by default)
  19326. * @param speedRatio defines the speed ratio to apply to all animations
  19327. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  19328. * @param onAnimationLoop defines the callback to call when an animation loops
  19329. * @returns the list of animatables created for all nodes
  19330. */
  19331. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  19332. /**
  19333. * Gets the animatable associated with a specific target
  19334. * @param target defines the target of the animatable
  19335. * @returns the required animatable if found
  19336. */
  19337. getAnimatableByTarget(target: any): Nullable<Animatable>;
  19338. /**
  19339. * Gets all animatables associated with a given target
  19340. * @param target defines the target to look animatables for
  19341. * @returns an array of Animatables
  19342. */
  19343. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  19344. /**
  19345. * Will stop the animation of the given target
  19346. * @param target - the target
  19347. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  19348. * @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)
  19349. */
  19350. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  19351. /**
  19352. * Stops and removes all animations that have been applied to the scene
  19353. */
  19354. stopAllAnimations(): void;
  19355. }
  19356. }
  19357. module "babylonjs/Bones/bone" {
  19358. interface Bone {
  19359. /**
  19360. * Copy an animation range from another bone
  19361. * @param source defines the source bone
  19362. * @param rangeName defines the range name to copy
  19363. * @param frameOffset defines the frame offset
  19364. * @param rescaleAsRequired defines if rescaling must be applied if required
  19365. * @param skelDimensionsRatio defines the scaling ratio
  19366. * @returns true if operation was successful
  19367. */
  19368. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  19369. }
  19370. }
  19371. }
  19372. declare module "babylonjs/Bones/skeleton" {
  19373. import { Bone } from "babylonjs/Bones/bone";
  19374. import { IAnimatable } from "babylonjs/Misc/tools";
  19375. import { Observable } from "babylonjs/Misc/observable";
  19376. import { Vector3, Matrix } from "babylonjs/Maths/math";
  19377. import { Scene } from "babylonjs/scene";
  19378. import { Nullable } from "babylonjs/types";
  19379. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19380. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  19381. import { Animatable } from "babylonjs/Animations/animatable";
  19382. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19383. import { Animation } from "babylonjs/Animations/animation";
  19384. import { AnimationRange } from "babylonjs/Animations/animationRange";
  19385. import { IInspectable } from "babylonjs/Misc/iInspectable";
  19386. /**
  19387. * Class used to handle skinning animations
  19388. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  19389. */
  19390. export class Skeleton implements IAnimatable {
  19391. /** defines the skeleton name */
  19392. name: string;
  19393. /** defines the skeleton Id */
  19394. id: string;
  19395. /**
  19396. * Defines the list of child bones
  19397. */
  19398. bones: Bone[];
  19399. /**
  19400. * Defines an estimate of the dimension of the skeleton at rest
  19401. */
  19402. dimensionsAtRest: Vector3;
  19403. /**
  19404. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  19405. */
  19406. needInitialSkinMatrix: boolean;
  19407. /**
  19408. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  19409. */
  19410. overrideMesh: Nullable<AbstractMesh>;
  19411. /**
  19412. * Gets the list of animations attached to this skeleton
  19413. */
  19414. animations: Array<Animation>;
  19415. private _scene;
  19416. private _isDirty;
  19417. private _transformMatrices;
  19418. private _transformMatrixTexture;
  19419. private _meshesWithPoseMatrix;
  19420. private _animatables;
  19421. private _identity;
  19422. private _synchronizedWithMesh;
  19423. private _ranges;
  19424. private _lastAbsoluteTransformsUpdateId;
  19425. private _canUseTextureForBones;
  19426. private _uniqueId;
  19427. /** @hidden */
  19428. _numBonesWithLinkedTransformNode: number;
  19429. /**
  19430. * Specifies if the skeleton should be serialized
  19431. */
  19432. doNotSerialize: boolean;
  19433. private _useTextureToStoreBoneMatrices;
  19434. /**
  19435. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  19436. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  19437. */
  19438. useTextureToStoreBoneMatrices: boolean;
  19439. private _animationPropertiesOverride;
  19440. /**
  19441. * Gets or sets the animation properties override
  19442. */
  19443. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19444. /**
  19445. * List of inspectable custom properties (used by the Inspector)
  19446. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  19447. */
  19448. inspectableCustomProperties: IInspectable[];
  19449. /**
  19450. * An observable triggered before computing the skeleton's matrices
  19451. */
  19452. onBeforeComputeObservable: Observable<Skeleton>;
  19453. /**
  19454. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  19455. */
  19456. readonly isUsingTextureForMatrices: boolean;
  19457. /**
  19458. * Gets the unique ID of this skeleton
  19459. */
  19460. readonly uniqueId: number;
  19461. /**
  19462. * Creates a new skeleton
  19463. * @param name defines the skeleton name
  19464. * @param id defines the skeleton Id
  19465. * @param scene defines the hosting scene
  19466. */
  19467. constructor(
  19468. /** defines the skeleton name */
  19469. name: string,
  19470. /** defines the skeleton Id */
  19471. id: string, scene: Scene);
  19472. /**
  19473. * Gets the current object class name.
  19474. * @return the class name
  19475. */
  19476. getClassName(): string;
  19477. /**
  19478. * Returns an array containing the root bones
  19479. * @returns an array containing the root bones
  19480. */
  19481. getChildren(): Array<Bone>;
  19482. /**
  19483. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  19484. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  19485. * @returns a Float32Array containing matrices data
  19486. */
  19487. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  19488. /**
  19489. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  19490. * @returns a raw texture containing the data
  19491. */
  19492. getTransformMatrixTexture(): Nullable<RawTexture>;
  19493. /**
  19494. * Gets the current hosting scene
  19495. * @returns a scene object
  19496. */
  19497. getScene(): Scene;
  19498. /**
  19499. * Gets a string representing the current skeleton data
  19500. * @param fullDetails defines a boolean indicating if we want a verbose version
  19501. * @returns a string representing the current skeleton data
  19502. */
  19503. toString(fullDetails?: boolean): string;
  19504. /**
  19505. * Get bone's index searching by name
  19506. * @param name defines bone's name to search for
  19507. * @return the indice of the bone. Returns -1 if not found
  19508. */
  19509. getBoneIndexByName(name: string): number;
  19510. /**
  19511. * Creater a new animation range
  19512. * @param name defines the name of the range
  19513. * @param from defines the start key
  19514. * @param to defines the end key
  19515. */
  19516. createAnimationRange(name: string, from: number, to: number): void;
  19517. /**
  19518. * Delete a specific animation range
  19519. * @param name defines the name of the range
  19520. * @param deleteFrames defines if frames must be removed as well
  19521. */
  19522. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  19523. /**
  19524. * Gets a specific animation range
  19525. * @param name defines the name of the range to look for
  19526. * @returns the requested animation range or null if not found
  19527. */
  19528. getAnimationRange(name: string): Nullable<AnimationRange>;
  19529. /**
  19530. * Gets the list of all animation ranges defined on this skeleton
  19531. * @returns an array
  19532. */
  19533. getAnimationRanges(): Nullable<AnimationRange>[];
  19534. /**
  19535. * Copy animation range from a source skeleton.
  19536. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  19537. * @param source defines the source skeleton
  19538. * @param name defines the name of the range to copy
  19539. * @param rescaleAsRequired defines if rescaling must be applied if required
  19540. * @returns true if operation was successful
  19541. */
  19542. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  19543. /**
  19544. * Forces the skeleton to go to rest pose
  19545. */
  19546. returnToRest(): void;
  19547. private _getHighestAnimationFrame;
  19548. /**
  19549. * Begin a specific animation range
  19550. * @param name defines the name of the range to start
  19551. * @param loop defines if looping must be turned on (false by default)
  19552. * @param speedRatio defines the speed ratio to apply (1 by default)
  19553. * @param onAnimationEnd defines a callback which will be called when animation will end
  19554. * @returns a new animatable
  19555. */
  19556. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  19557. /** @hidden */
  19558. _markAsDirty(): void;
  19559. /** @hidden */
  19560. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19561. /** @hidden */
  19562. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  19563. private _computeTransformMatrices;
  19564. /**
  19565. * Build all resources required to render a skeleton
  19566. */
  19567. prepare(): void;
  19568. /**
  19569. * Gets the list of animatables currently running for this skeleton
  19570. * @returns an array of animatables
  19571. */
  19572. getAnimatables(): IAnimatable[];
  19573. /**
  19574. * Clone the current skeleton
  19575. * @param name defines the name of the new skeleton
  19576. * @param id defines the id of the new skeleton
  19577. * @returns the new skeleton
  19578. */
  19579. clone(name: string, id: string): Skeleton;
  19580. /**
  19581. * Enable animation blending for this skeleton
  19582. * @param blendingSpeed defines the blending speed to apply
  19583. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  19584. */
  19585. enableBlending(blendingSpeed?: number): void;
  19586. /**
  19587. * Releases all resources associated with the current skeleton
  19588. */
  19589. dispose(): void;
  19590. /**
  19591. * Serialize the skeleton in a JSON object
  19592. * @returns a JSON object
  19593. */
  19594. serialize(): any;
  19595. /**
  19596. * Creates a new skeleton from serialized data
  19597. * @param parsedSkeleton defines the serialized data
  19598. * @param scene defines the hosting scene
  19599. * @returns a new skeleton
  19600. */
  19601. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  19602. /**
  19603. * Compute all node absolute transforms
  19604. * @param forceUpdate defines if computation must be done even if cache is up to date
  19605. */
  19606. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  19607. /**
  19608. * Gets the root pose matrix
  19609. * @returns a matrix
  19610. */
  19611. getPoseMatrix(): Nullable<Matrix>;
  19612. /**
  19613. * Sorts bones per internal index
  19614. */
  19615. sortBones(): void;
  19616. private _sortBones;
  19617. }
  19618. }
  19619. declare module "babylonjs/Morph/morphTarget" {
  19620. import { IAnimatable } from "babylonjs/Misc/tools";
  19621. import { Observable } from "babylonjs/Misc/observable";
  19622. import { Nullable, FloatArray } from "babylonjs/types";
  19623. import { Scene } from "babylonjs/scene";
  19624. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19625. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  19626. /**
  19627. * Defines a target to use with MorphTargetManager
  19628. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19629. */
  19630. export class MorphTarget implements IAnimatable {
  19631. /** defines the name of the target */
  19632. name: string;
  19633. /**
  19634. * Gets or sets the list of animations
  19635. */
  19636. animations: import("babylonjs/Animations/animation").Animation[];
  19637. private _scene;
  19638. private _positions;
  19639. private _normals;
  19640. private _tangents;
  19641. private _influence;
  19642. /**
  19643. * Observable raised when the influence changes
  19644. */
  19645. onInfluenceChanged: Observable<boolean>;
  19646. /** @hidden */
  19647. _onDataLayoutChanged: Observable<void>;
  19648. /**
  19649. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  19650. */
  19651. influence: number;
  19652. /**
  19653. * Gets or sets the id of the morph Target
  19654. */
  19655. id: string;
  19656. private _animationPropertiesOverride;
  19657. /**
  19658. * Gets or sets the animation properties override
  19659. */
  19660. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  19661. /**
  19662. * Creates a new MorphTarget
  19663. * @param name defines the name of the target
  19664. * @param influence defines the influence to use
  19665. * @param scene defines the scene the morphtarget belongs to
  19666. */
  19667. constructor(
  19668. /** defines the name of the target */
  19669. name: string, influence?: number, scene?: Nullable<Scene>);
  19670. /**
  19671. * Gets a boolean defining if the target contains position data
  19672. */
  19673. readonly hasPositions: boolean;
  19674. /**
  19675. * Gets a boolean defining if the target contains normal data
  19676. */
  19677. readonly hasNormals: boolean;
  19678. /**
  19679. * Gets a boolean defining if the target contains tangent data
  19680. */
  19681. readonly hasTangents: boolean;
  19682. /**
  19683. * Affects position data to this target
  19684. * @param data defines the position data to use
  19685. */
  19686. setPositions(data: Nullable<FloatArray>): void;
  19687. /**
  19688. * Gets the position data stored in this target
  19689. * @returns a FloatArray containing the position data (or null if not present)
  19690. */
  19691. getPositions(): Nullable<FloatArray>;
  19692. /**
  19693. * Affects normal data to this target
  19694. * @param data defines the normal data to use
  19695. */
  19696. setNormals(data: Nullable<FloatArray>): void;
  19697. /**
  19698. * Gets the normal data stored in this target
  19699. * @returns a FloatArray containing the normal data (or null if not present)
  19700. */
  19701. getNormals(): Nullable<FloatArray>;
  19702. /**
  19703. * Affects tangent data to this target
  19704. * @param data defines the tangent data to use
  19705. */
  19706. setTangents(data: Nullable<FloatArray>): void;
  19707. /**
  19708. * Gets the tangent data stored in this target
  19709. * @returns a FloatArray containing the tangent data (or null if not present)
  19710. */
  19711. getTangents(): Nullable<FloatArray>;
  19712. /**
  19713. * Serializes the current target into a Serialization object
  19714. * @returns the serialized object
  19715. */
  19716. serialize(): any;
  19717. /**
  19718. * Returns the string "MorphTarget"
  19719. * @returns "MorphTarget"
  19720. */
  19721. getClassName(): string;
  19722. /**
  19723. * Creates a new target from serialized data
  19724. * @param serializationObject defines the serialized data to use
  19725. * @returns a new MorphTarget
  19726. */
  19727. static Parse(serializationObject: any): MorphTarget;
  19728. /**
  19729. * Creates a MorphTarget from mesh data
  19730. * @param mesh defines the source mesh
  19731. * @param name defines the name to use for the new target
  19732. * @param influence defines the influence to attach to the target
  19733. * @returns a new MorphTarget
  19734. */
  19735. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  19736. }
  19737. }
  19738. declare module "babylonjs/Morph/morphTargetManager" {
  19739. import { Nullable } from "babylonjs/types";
  19740. import { Scene } from "babylonjs/scene";
  19741. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  19742. /**
  19743. * This class is used to deform meshes using morphing between different targets
  19744. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  19745. */
  19746. export class MorphTargetManager {
  19747. private _targets;
  19748. private _targetInfluenceChangedObservers;
  19749. private _targetDataLayoutChangedObservers;
  19750. private _activeTargets;
  19751. private _scene;
  19752. private _influences;
  19753. private _supportsNormals;
  19754. private _supportsTangents;
  19755. private _vertexCount;
  19756. private _uniqueId;
  19757. private _tempInfluences;
  19758. /**
  19759. * Creates a new MorphTargetManager
  19760. * @param scene defines the current scene
  19761. */
  19762. constructor(scene?: Nullable<Scene>);
  19763. /**
  19764. * Gets the unique ID of this manager
  19765. */
  19766. readonly uniqueId: number;
  19767. /**
  19768. * Gets the number of vertices handled by this manager
  19769. */
  19770. readonly vertexCount: number;
  19771. /**
  19772. * Gets a boolean indicating if this manager supports morphing of normals
  19773. */
  19774. readonly supportsNormals: boolean;
  19775. /**
  19776. * Gets a boolean indicating if this manager supports morphing of tangents
  19777. */
  19778. readonly supportsTangents: boolean;
  19779. /**
  19780. * Gets the number of targets stored in this manager
  19781. */
  19782. readonly numTargets: number;
  19783. /**
  19784. * Gets the number of influencers (ie. the number of targets with influences > 0)
  19785. */
  19786. readonly numInfluencers: number;
  19787. /**
  19788. * Gets the list of influences (one per target)
  19789. */
  19790. readonly influences: Float32Array;
  19791. /**
  19792. * Gets the active target at specified index. An active target is a target with an influence > 0
  19793. * @param index defines the index to check
  19794. * @returns the requested target
  19795. */
  19796. getActiveTarget(index: number): MorphTarget;
  19797. /**
  19798. * Gets the target at specified index
  19799. * @param index defines the index to check
  19800. * @returns the requested target
  19801. */
  19802. getTarget(index: number): MorphTarget;
  19803. /**
  19804. * Add a new target to this manager
  19805. * @param target defines the target to add
  19806. */
  19807. addTarget(target: MorphTarget): void;
  19808. /**
  19809. * Removes a target from the manager
  19810. * @param target defines the target to remove
  19811. */
  19812. removeTarget(target: MorphTarget): void;
  19813. /**
  19814. * Serializes the current manager into a Serialization object
  19815. * @returns the serialized object
  19816. */
  19817. serialize(): any;
  19818. private _syncActiveTargets;
  19819. /**
  19820. * Syncrhonize the targets with all the meshes using this morph target manager
  19821. */
  19822. synchronize(): void;
  19823. /**
  19824. * Creates a new MorphTargetManager from serialized data
  19825. * @param serializationObject defines the serialized data
  19826. * @param scene defines the hosting scene
  19827. * @returns the new MorphTargetManager
  19828. */
  19829. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  19830. }
  19831. }
  19832. declare module "babylonjs/Meshes/groundMesh" {
  19833. import { Scene } from "babylonjs/scene";
  19834. import { Vector3 } from "babylonjs/Maths/math";
  19835. import { Mesh } from "babylonjs/Meshes/mesh";
  19836. /**
  19837. * Mesh representing the gorund
  19838. */
  19839. export class GroundMesh extends Mesh {
  19840. /** If octree should be generated */
  19841. generateOctree: boolean;
  19842. private _heightQuads;
  19843. /** @hidden */
  19844. _subdivisionsX: number;
  19845. /** @hidden */
  19846. _subdivisionsY: number;
  19847. /** @hidden */
  19848. _width: number;
  19849. /** @hidden */
  19850. _height: number;
  19851. /** @hidden */
  19852. _minX: number;
  19853. /** @hidden */
  19854. _maxX: number;
  19855. /** @hidden */
  19856. _minZ: number;
  19857. /** @hidden */
  19858. _maxZ: number;
  19859. constructor(name: string, scene: Scene);
  19860. /**
  19861. * "GroundMesh"
  19862. * @returns "GroundMesh"
  19863. */
  19864. getClassName(): string;
  19865. /**
  19866. * The minimum of x and y subdivisions
  19867. */
  19868. readonly subdivisions: number;
  19869. /**
  19870. * X subdivisions
  19871. */
  19872. readonly subdivisionsX: number;
  19873. /**
  19874. * Y subdivisions
  19875. */
  19876. readonly subdivisionsY: number;
  19877. /**
  19878. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  19879. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  19880. * @param chunksCount the number of subdivisions for x and y
  19881. * @param octreeBlocksSize (Default: 32)
  19882. */
  19883. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  19884. /**
  19885. * Returns a height (y) value in the Worl system :
  19886. * the ground altitude at the coordinates (x, z) expressed in the World system.
  19887. * @param x x coordinate
  19888. * @param z z coordinate
  19889. * @returns the ground y position if (x, z) are outside the ground surface.
  19890. */
  19891. getHeightAtCoordinates(x: number, z: number): number;
  19892. /**
  19893. * Returns a normalized vector (Vector3) orthogonal to the ground
  19894. * at the ground coordinates (x, z) expressed in the World system.
  19895. * @param x x coordinate
  19896. * @param z z coordinate
  19897. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  19898. */
  19899. getNormalAtCoordinates(x: number, z: number): Vector3;
  19900. /**
  19901. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  19902. * at the ground coordinates (x, z) expressed in the World system.
  19903. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  19904. * @param x x coordinate
  19905. * @param z z coordinate
  19906. * @param ref vector to store the result
  19907. * @returns the GroundMesh.
  19908. */
  19909. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  19910. /**
  19911. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  19912. * if the ground has been updated.
  19913. * This can be used in the render loop.
  19914. * @returns the GroundMesh.
  19915. */
  19916. updateCoordinateHeights(): GroundMesh;
  19917. private _getFacetAt;
  19918. private _initHeightQuads;
  19919. private _computeHeightQuads;
  19920. /**
  19921. * Serializes this ground mesh
  19922. * @param serializationObject object to write serialization to
  19923. */
  19924. serialize(serializationObject: any): void;
  19925. /**
  19926. * Parses a serialized ground mesh
  19927. * @param parsedMesh the serialized mesh
  19928. * @param scene the scene to create the ground mesh in
  19929. * @returns the created ground mesh
  19930. */
  19931. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  19932. }
  19933. }
  19934. declare module "babylonjs/Physics/physicsJoint" {
  19935. import { Vector3 } from "babylonjs/Maths/math";
  19936. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  19937. /**
  19938. * Interface for Physics-Joint data
  19939. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19940. */
  19941. export interface PhysicsJointData {
  19942. /**
  19943. * The main pivot of the joint
  19944. */
  19945. mainPivot?: Vector3;
  19946. /**
  19947. * The connected pivot of the joint
  19948. */
  19949. connectedPivot?: Vector3;
  19950. /**
  19951. * The main axis of the joint
  19952. */
  19953. mainAxis?: Vector3;
  19954. /**
  19955. * The connected axis of the joint
  19956. */
  19957. connectedAxis?: Vector3;
  19958. /**
  19959. * The collision of the joint
  19960. */
  19961. collision?: boolean;
  19962. /**
  19963. * Native Oimo/Cannon/Energy data
  19964. */
  19965. nativeParams?: any;
  19966. }
  19967. /**
  19968. * This is a holder class for the physics joint created by the physics plugin
  19969. * It holds a set of functions to control the underlying joint
  19970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  19971. */
  19972. export class PhysicsJoint {
  19973. /**
  19974. * The type of the physics joint
  19975. */
  19976. type: number;
  19977. /**
  19978. * The data for the physics joint
  19979. */
  19980. jointData: PhysicsJointData;
  19981. private _physicsJoint;
  19982. protected _physicsPlugin: IPhysicsEnginePlugin;
  19983. /**
  19984. * Initializes the physics joint
  19985. * @param type The type of the physics joint
  19986. * @param jointData The data for the physics joint
  19987. */
  19988. constructor(
  19989. /**
  19990. * The type of the physics joint
  19991. */
  19992. type: number,
  19993. /**
  19994. * The data for the physics joint
  19995. */
  19996. jointData: PhysicsJointData);
  19997. /**
  19998. * Gets the physics joint
  19999. */
  20000. /**
  20001. * Sets the physics joint
  20002. */
  20003. physicsJoint: any;
  20004. /**
  20005. * Sets the physics plugin
  20006. */
  20007. physicsPlugin: IPhysicsEnginePlugin;
  20008. /**
  20009. * Execute a function that is physics-plugin specific.
  20010. * @param {Function} func the function that will be executed.
  20011. * It accepts two parameters: the physics world and the physics joint
  20012. */
  20013. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  20014. /**
  20015. * Distance-Joint type
  20016. */
  20017. static DistanceJoint: number;
  20018. /**
  20019. * Hinge-Joint type
  20020. */
  20021. static HingeJoint: number;
  20022. /**
  20023. * Ball-and-Socket joint type
  20024. */
  20025. static BallAndSocketJoint: number;
  20026. /**
  20027. * Wheel-Joint type
  20028. */
  20029. static WheelJoint: number;
  20030. /**
  20031. * Slider-Joint type
  20032. */
  20033. static SliderJoint: number;
  20034. /**
  20035. * Prismatic-Joint type
  20036. */
  20037. static PrismaticJoint: number;
  20038. /**
  20039. * Universal-Joint type
  20040. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  20041. */
  20042. static UniversalJoint: number;
  20043. /**
  20044. * Hinge-Joint 2 type
  20045. */
  20046. static Hinge2Joint: number;
  20047. /**
  20048. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  20049. */
  20050. static PointToPointJoint: number;
  20051. /**
  20052. * Spring-Joint type
  20053. */
  20054. static SpringJoint: number;
  20055. /**
  20056. * Lock-Joint type
  20057. */
  20058. static LockJoint: number;
  20059. }
  20060. /**
  20061. * A class representing a physics distance joint
  20062. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20063. */
  20064. export class DistanceJoint extends PhysicsJoint {
  20065. /**
  20066. *
  20067. * @param jointData The data for the Distance-Joint
  20068. */
  20069. constructor(jointData: DistanceJointData);
  20070. /**
  20071. * Update the predefined distance.
  20072. * @param maxDistance The maximum preferred distance
  20073. * @param minDistance The minimum preferred distance
  20074. */
  20075. updateDistance(maxDistance: number, minDistance?: number): void;
  20076. }
  20077. /**
  20078. * Represents a Motor-Enabled Joint
  20079. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20080. */
  20081. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  20082. /**
  20083. * Initializes the Motor-Enabled Joint
  20084. * @param type The type of the joint
  20085. * @param jointData The physica joint data for the joint
  20086. */
  20087. constructor(type: number, jointData: PhysicsJointData);
  20088. /**
  20089. * Set the motor values.
  20090. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20091. * @param force the force to apply
  20092. * @param maxForce max force for this motor.
  20093. */
  20094. setMotor(force?: number, maxForce?: number): void;
  20095. /**
  20096. * Set the motor's limits.
  20097. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20098. * @param upperLimit The upper limit of the motor
  20099. * @param lowerLimit The lower limit of the motor
  20100. */
  20101. setLimit(upperLimit: number, lowerLimit?: number): void;
  20102. }
  20103. /**
  20104. * This class represents a single physics Hinge-Joint
  20105. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20106. */
  20107. export class HingeJoint extends MotorEnabledJoint {
  20108. /**
  20109. * Initializes the Hinge-Joint
  20110. * @param jointData The joint data for the Hinge-Joint
  20111. */
  20112. constructor(jointData: PhysicsJointData);
  20113. /**
  20114. * Set the motor values.
  20115. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20116. * @param {number} force the force to apply
  20117. * @param {number} maxForce max force for this motor.
  20118. */
  20119. setMotor(force?: number, maxForce?: number): void;
  20120. /**
  20121. * Set the motor's limits.
  20122. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20123. * @param upperLimit The upper limit of the motor
  20124. * @param lowerLimit The lower limit of the motor
  20125. */
  20126. setLimit(upperLimit: number, lowerLimit?: number): void;
  20127. }
  20128. /**
  20129. * This class represents a dual hinge physics joint (same as wheel joint)
  20130. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20131. */
  20132. export class Hinge2Joint extends MotorEnabledJoint {
  20133. /**
  20134. * Initializes the Hinge2-Joint
  20135. * @param jointData The joint data for the Hinge2-Joint
  20136. */
  20137. constructor(jointData: PhysicsJointData);
  20138. /**
  20139. * Set the motor values.
  20140. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20141. * @param {number} targetSpeed the speed the motor is to reach
  20142. * @param {number} maxForce max force for this motor.
  20143. * @param {motorIndex} the motor's index, 0 or 1.
  20144. */
  20145. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  20146. /**
  20147. * Set the motor limits.
  20148. * Attention, this function is plugin specific. Engines won't react 100% the same.
  20149. * @param {number} upperLimit the upper limit
  20150. * @param {number} lowerLimit lower limit
  20151. * @param {motorIndex} the motor's index, 0 or 1.
  20152. */
  20153. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20154. }
  20155. /**
  20156. * Interface for a motor enabled joint
  20157. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20158. */
  20159. export interface IMotorEnabledJoint {
  20160. /**
  20161. * Physics joint
  20162. */
  20163. physicsJoint: any;
  20164. /**
  20165. * Sets the motor of the motor-enabled joint
  20166. * @param force The force of the motor
  20167. * @param maxForce The maximum force of the motor
  20168. * @param motorIndex The index of the motor
  20169. */
  20170. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  20171. /**
  20172. * Sets the limit of the motor
  20173. * @param upperLimit The upper limit of the motor
  20174. * @param lowerLimit The lower limit of the motor
  20175. * @param motorIndex The index of the motor
  20176. */
  20177. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20178. }
  20179. /**
  20180. * Joint data for a Distance-Joint
  20181. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20182. */
  20183. export interface DistanceJointData extends PhysicsJointData {
  20184. /**
  20185. * Max distance the 2 joint objects can be apart
  20186. */
  20187. maxDistance: number;
  20188. }
  20189. /**
  20190. * Joint data from a spring joint
  20191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20192. */
  20193. export interface SpringJointData extends PhysicsJointData {
  20194. /**
  20195. * Length of the spring
  20196. */
  20197. length: number;
  20198. /**
  20199. * Stiffness of the spring
  20200. */
  20201. stiffness: number;
  20202. /**
  20203. * Damping of the spring
  20204. */
  20205. damping: number;
  20206. /** this callback will be called when applying the force to the impostors. */
  20207. forceApplicationCallback: () => void;
  20208. }
  20209. }
  20210. declare module "babylonjs/Physics/physicsRaycastResult" {
  20211. import { Vector3 } from "babylonjs/Maths/math";
  20212. /**
  20213. * Holds the data for the raycast result
  20214. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20215. */
  20216. export class PhysicsRaycastResult {
  20217. private _hasHit;
  20218. private _hitDistance;
  20219. private _hitNormalWorld;
  20220. private _hitPointWorld;
  20221. private _rayFromWorld;
  20222. private _rayToWorld;
  20223. /**
  20224. * Gets if there was a hit
  20225. */
  20226. readonly hasHit: boolean;
  20227. /**
  20228. * Gets the distance from the hit
  20229. */
  20230. readonly hitDistance: number;
  20231. /**
  20232. * Gets the hit normal/direction in the world
  20233. */
  20234. readonly hitNormalWorld: Vector3;
  20235. /**
  20236. * Gets the hit point in the world
  20237. */
  20238. readonly hitPointWorld: Vector3;
  20239. /**
  20240. * Gets the ray "start point" of the ray in the world
  20241. */
  20242. readonly rayFromWorld: Vector3;
  20243. /**
  20244. * Gets the ray "end point" of the ray in the world
  20245. */
  20246. readonly rayToWorld: Vector3;
  20247. /**
  20248. * Sets the hit data (normal & point in world space)
  20249. * @param hitNormalWorld defines the normal in world space
  20250. * @param hitPointWorld defines the point in world space
  20251. */
  20252. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  20253. /**
  20254. * Sets the distance from the start point to the hit point
  20255. * @param distance
  20256. */
  20257. setHitDistance(distance: number): void;
  20258. /**
  20259. * Calculates the distance manually
  20260. */
  20261. calculateHitDistance(): void;
  20262. /**
  20263. * Resets all the values to default
  20264. * @param from The from point on world space
  20265. * @param to The to point on world space
  20266. */
  20267. reset(from?: Vector3, to?: Vector3): void;
  20268. }
  20269. /**
  20270. * Interface for the size containing width and height
  20271. */
  20272. interface IXYZ {
  20273. /**
  20274. * X
  20275. */
  20276. x: number;
  20277. /**
  20278. * Y
  20279. */
  20280. y: number;
  20281. /**
  20282. * Z
  20283. */
  20284. z: number;
  20285. }
  20286. }
  20287. declare module "babylonjs/Physics/IPhysicsEngine" {
  20288. import { Nullable } from "babylonjs/types";
  20289. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  20290. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20291. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  20292. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  20293. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  20294. /**
  20295. * Interface used to describe a physics joint
  20296. */
  20297. export interface PhysicsImpostorJoint {
  20298. /** Defines the main impostor to which the joint is linked */
  20299. mainImpostor: PhysicsImpostor;
  20300. /** Defines the impostor that is connected to the main impostor using this joint */
  20301. connectedImpostor: PhysicsImpostor;
  20302. /** Defines the joint itself */
  20303. joint: PhysicsJoint;
  20304. }
  20305. /** @hidden */
  20306. export interface IPhysicsEnginePlugin {
  20307. world: any;
  20308. name: string;
  20309. setGravity(gravity: Vector3): void;
  20310. setTimeStep(timeStep: number): void;
  20311. getTimeStep(): number;
  20312. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  20313. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20314. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  20315. generatePhysicsBody(impostor: PhysicsImpostor): void;
  20316. removePhysicsBody(impostor: PhysicsImpostor): void;
  20317. generateJoint(joint: PhysicsImpostorJoint): void;
  20318. removeJoint(joint: PhysicsImpostorJoint): void;
  20319. isSupported(): boolean;
  20320. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  20321. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  20322. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20323. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  20324. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20325. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  20326. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  20327. getBodyMass(impostor: PhysicsImpostor): number;
  20328. getBodyFriction(impostor: PhysicsImpostor): number;
  20329. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  20330. getBodyRestitution(impostor: PhysicsImpostor): number;
  20331. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  20332. getBodyPressure?(impostor: PhysicsImpostor): number;
  20333. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  20334. getBodyStiffness?(impostor: PhysicsImpostor): number;
  20335. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  20336. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  20337. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  20338. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  20339. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  20340. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20341. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  20342. sleepBody(impostor: PhysicsImpostor): void;
  20343. wakeUpBody(impostor: PhysicsImpostor): void;
  20344. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20345. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  20346. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  20347. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  20348. getRadius(impostor: PhysicsImpostor): number;
  20349. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  20350. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  20351. dispose(): void;
  20352. }
  20353. /**
  20354. * Interface used to define a physics engine
  20355. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  20356. */
  20357. export interface IPhysicsEngine {
  20358. /**
  20359. * Gets the gravity vector used by the simulation
  20360. */
  20361. gravity: Vector3;
  20362. /**
  20363. * Sets the gravity vector used by the simulation
  20364. * @param gravity defines the gravity vector to use
  20365. */
  20366. setGravity(gravity: Vector3): void;
  20367. /**
  20368. * Set the time step of the physics engine.
  20369. * Default is 1/60.
  20370. * To slow it down, enter 1/600 for example.
  20371. * To speed it up, 1/30
  20372. * @param newTimeStep the new timestep to apply to this world.
  20373. */
  20374. setTimeStep(newTimeStep: number): void;
  20375. /**
  20376. * Get the time step of the physics engine.
  20377. * @returns the current time step
  20378. */
  20379. getTimeStep(): number;
  20380. /**
  20381. * Release all resources
  20382. */
  20383. dispose(): void;
  20384. /**
  20385. * Gets the name of the current physics plugin
  20386. * @returns the name of the plugin
  20387. */
  20388. getPhysicsPluginName(): string;
  20389. /**
  20390. * Adding a new impostor for the impostor tracking.
  20391. * This will be done by the impostor itself.
  20392. * @param impostor the impostor to add
  20393. */
  20394. addImpostor(impostor: PhysicsImpostor): void;
  20395. /**
  20396. * Remove an impostor from the engine.
  20397. * This impostor and its mesh will not longer be updated by the physics engine.
  20398. * @param impostor the impostor to remove
  20399. */
  20400. removeImpostor(impostor: PhysicsImpostor): void;
  20401. /**
  20402. * Add a joint to the physics engine
  20403. * @param mainImpostor defines the main impostor to which the joint is added.
  20404. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  20405. * @param joint defines the joint that will connect both impostors.
  20406. */
  20407. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20408. /**
  20409. * Removes a joint from the simulation
  20410. * @param mainImpostor defines the impostor used with the joint
  20411. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  20412. * @param joint defines the joint to remove
  20413. */
  20414. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  20415. /**
  20416. * Gets the current plugin used to run the simulation
  20417. * @returns current plugin
  20418. */
  20419. getPhysicsPlugin(): IPhysicsEnginePlugin;
  20420. /**
  20421. * Gets the list of physic impostors
  20422. * @returns an array of PhysicsImpostor
  20423. */
  20424. getImpostors(): Array<PhysicsImpostor>;
  20425. /**
  20426. * Gets the impostor for a physics enabled object
  20427. * @param object defines the object impersonated by the impostor
  20428. * @returns the PhysicsImpostor or null if not found
  20429. */
  20430. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20431. /**
  20432. * Gets the impostor for a physics body object
  20433. * @param body defines physics body used by the impostor
  20434. * @returns the PhysicsImpostor or null if not found
  20435. */
  20436. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  20437. /**
  20438. * Does a raycast in the physics world
  20439. * @param from when should the ray start?
  20440. * @param to when should the ray end?
  20441. * @returns PhysicsRaycastResult
  20442. */
  20443. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  20444. /**
  20445. * Called by the scene. No need to call it.
  20446. * @param delta defines the timespam between frames
  20447. */
  20448. _step(delta: number): void;
  20449. }
  20450. }
  20451. declare module "babylonjs/Physics/physicsImpostor" {
  20452. import { Nullable, IndicesArray } from "babylonjs/types";
  20453. import { Vector3, Matrix, Quaternion, Space } from "babylonjs/Maths/math";
  20454. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20455. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20456. import { Scene } from "babylonjs/scene";
  20457. import { Bone } from "babylonjs/Bones/bone";
  20458. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  20459. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  20460. /**
  20461. * The interface for the physics imposter parameters
  20462. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20463. */
  20464. export interface PhysicsImpostorParameters {
  20465. /**
  20466. * The mass of the physics imposter
  20467. */
  20468. mass: number;
  20469. /**
  20470. * The friction of the physics imposter
  20471. */
  20472. friction?: number;
  20473. /**
  20474. * The coefficient of restitution of the physics imposter
  20475. */
  20476. restitution?: number;
  20477. /**
  20478. * The native options of the physics imposter
  20479. */
  20480. nativeOptions?: any;
  20481. /**
  20482. * Specifies if the parent should be ignored
  20483. */
  20484. ignoreParent?: boolean;
  20485. /**
  20486. * Specifies if bi-directional transformations should be disabled
  20487. */
  20488. disableBidirectionalTransformation?: boolean;
  20489. /**
  20490. * The pressure inside the physics imposter, soft object only
  20491. */
  20492. pressure?: number;
  20493. /**
  20494. * The stiffness the physics imposter, soft object only
  20495. */
  20496. stiffness?: number;
  20497. /**
  20498. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  20499. */
  20500. velocityIterations?: number;
  20501. /**
  20502. * The number of iterations used in maintaining consistent vertex positions, soft object only
  20503. */
  20504. positionIterations?: number;
  20505. /**
  20506. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  20507. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  20508. * Add to fix multiple points
  20509. */
  20510. fixedPoints?: number;
  20511. /**
  20512. * The collision margin around a soft object
  20513. */
  20514. margin?: number;
  20515. /**
  20516. * The collision margin around a soft object
  20517. */
  20518. damping?: number;
  20519. /**
  20520. * The path for a rope based on an extrusion
  20521. */
  20522. path?: any;
  20523. /**
  20524. * The shape of an extrusion used for a rope based on an extrusion
  20525. */
  20526. shape?: any;
  20527. }
  20528. /**
  20529. * Interface for a physics-enabled object
  20530. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20531. */
  20532. export interface IPhysicsEnabledObject {
  20533. /**
  20534. * The position of the physics-enabled object
  20535. */
  20536. position: Vector3;
  20537. /**
  20538. * The rotation of the physics-enabled object
  20539. */
  20540. rotationQuaternion: Nullable<Quaternion>;
  20541. /**
  20542. * The scale of the physics-enabled object
  20543. */
  20544. scaling: Vector3;
  20545. /**
  20546. * The rotation of the physics-enabled object
  20547. */
  20548. rotation?: Vector3;
  20549. /**
  20550. * The parent of the physics-enabled object
  20551. */
  20552. parent?: any;
  20553. /**
  20554. * The bounding info of the physics-enabled object
  20555. * @returns The bounding info of the physics-enabled object
  20556. */
  20557. getBoundingInfo(): BoundingInfo;
  20558. /**
  20559. * Computes the world matrix
  20560. * @param force Specifies if the world matrix should be computed by force
  20561. * @returns A world matrix
  20562. */
  20563. computeWorldMatrix(force: boolean): Matrix;
  20564. /**
  20565. * Gets the world matrix
  20566. * @returns A world matrix
  20567. */
  20568. getWorldMatrix?(): Matrix;
  20569. /**
  20570. * Gets the child meshes
  20571. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  20572. * @returns An array of abstract meshes
  20573. */
  20574. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  20575. /**
  20576. * Gets the vertex data
  20577. * @param kind The type of vertex data
  20578. * @returns A nullable array of numbers, or a float32 array
  20579. */
  20580. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  20581. /**
  20582. * Gets the indices from the mesh
  20583. * @returns A nullable array of index arrays
  20584. */
  20585. getIndices?(): Nullable<IndicesArray>;
  20586. /**
  20587. * Gets the scene from the mesh
  20588. * @returns the indices array or null
  20589. */
  20590. getScene?(): Scene;
  20591. /**
  20592. * Gets the absolute position from the mesh
  20593. * @returns the absolute position
  20594. */
  20595. getAbsolutePosition(): Vector3;
  20596. /**
  20597. * Gets the absolute pivot point from the mesh
  20598. * @returns the absolute pivot point
  20599. */
  20600. getAbsolutePivotPoint(): Vector3;
  20601. /**
  20602. * Rotates the mesh
  20603. * @param axis The axis of rotation
  20604. * @param amount The amount of rotation
  20605. * @param space The space of the rotation
  20606. * @returns The rotation transform node
  20607. */
  20608. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  20609. /**
  20610. * Translates the mesh
  20611. * @param axis The axis of translation
  20612. * @param distance The distance of translation
  20613. * @param space The space of the translation
  20614. * @returns The transform node
  20615. */
  20616. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  20617. /**
  20618. * Sets the absolute position of the mesh
  20619. * @param absolutePosition The absolute position of the mesh
  20620. * @returns The transform node
  20621. */
  20622. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  20623. /**
  20624. * Gets the class name of the mesh
  20625. * @returns The class name
  20626. */
  20627. getClassName(): string;
  20628. }
  20629. /**
  20630. * Represents a physics imposter
  20631. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  20632. */
  20633. export class PhysicsImpostor {
  20634. /**
  20635. * The physics-enabled object used as the physics imposter
  20636. */
  20637. object: IPhysicsEnabledObject;
  20638. /**
  20639. * The type of the physics imposter
  20640. */
  20641. type: number;
  20642. private _options;
  20643. private _scene?;
  20644. /**
  20645. * The default object size of the imposter
  20646. */
  20647. static DEFAULT_OBJECT_SIZE: Vector3;
  20648. /**
  20649. * The identity quaternion of the imposter
  20650. */
  20651. static IDENTITY_QUATERNION: Quaternion;
  20652. /** @hidden */
  20653. _pluginData: any;
  20654. private _physicsEngine;
  20655. private _physicsBody;
  20656. private _bodyUpdateRequired;
  20657. private _onBeforePhysicsStepCallbacks;
  20658. private _onAfterPhysicsStepCallbacks;
  20659. /** @hidden */
  20660. _onPhysicsCollideCallbacks: Array<{
  20661. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  20662. otherImpostors: Array<PhysicsImpostor>;
  20663. }>;
  20664. private _deltaPosition;
  20665. private _deltaRotation;
  20666. private _deltaRotationConjugated;
  20667. /** hidden */
  20668. _isFromLine: boolean;
  20669. private _parent;
  20670. private _isDisposed;
  20671. private static _tmpVecs;
  20672. private static _tmpQuat;
  20673. /**
  20674. * Specifies if the physics imposter is disposed
  20675. */
  20676. readonly isDisposed: boolean;
  20677. /**
  20678. * Gets the mass of the physics imposter
  20679. */
  20680. mass: number;
  20681. /**
  20682. * Gets the coefficient of friction
  20683. */
  20684. /**
  20685. * Sets the coefficient of friction
  20686. */
  20687. friction: number;
  20688. /**
  20689. * Gets the coefficient of restitution
  20690. */
  20691. /**
  20692. * Sets the coefficient of restitution
  20693. */
  20694. restitution: number;
  20695. /**
  20696. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  20697. */
  20698. /**
  20699. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  20700. */
  20701. pressure: number;
  20702. /**
  20703. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20704. */
  20705. /**
  20706. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  20707. */
  20708. stiffness: number;
  20709. /**
  20710. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20711. */
  20712. /**
  20713. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  20714. */
  20715. velocityIterations: number;
  20716. /**
  20717. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20718. */
  20719. /**
  20720. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  20721. */
  20722. positionIterations: number;
  20723. /**
  20724. * The unique id of the physics imposter
  20725. * set by the physics engine when adding this impostor to the array
  20726. */
  20727. uniqueId: number;
  20728. /**
  20729. * @hidden
  20730. */
  20731. soft: boolean;
  20732. /**
  20733. * @hidden
  20734. */
  20735. segments: number;
  20736. private _joints;
  20737. /**
  20738. * Initializes the physics imposter
  20739. * @param object The physics-enabled object used as the physics imposter
  20740. * @param type The type of the physics imposter
  20741. * @param _options The options for the physics imposter
  20742. * @param _scene The Babylon scene
  20743. */
  20744. constructor(
  20745. /**
  20746. * The physics-enabled object used as the physics imposter
  20747. */
  20748. object: IPhysicsEnabledObject,
  20749. /**
  20750. * The type of the physics imposter
  20751. */
  20752. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  20753. /**
  20754. * This function will completly initialize this impostor.
  20755. * It will create a new body - but only if this mesh has no parent.
  20756. * If it has, this impostor will not be used other than to define the impostor
  20757. * of the child mesh.
  20758. * @hidden
  20759. */
  20760. _init(): void;
  20761. private _getPhysicsParent;
  20762. /**
  20763. * Should a new body be generated.
  20764. * @returns boolean specifying if body initialization is required
  20765. */
  20766. isBodyInitRequired(): boolean;
  20767. /**
  20768. * Sets the updated scaling
  20769. * @param updated Specifies if the scaling is updated
  20770. */
  20771. setScalingUpdated(): void;
  20772. /**
  20773. * Force a regeneration of this or the parent's impostor's body.
  20774. * Use under cautious - This will remove all joints already implemented.
  20775. */
  20776. forceUpdate(): void;
  20777. /**
  20778. * Gets the body that holds this impostor. Either its own, or its parent.
  20779. */
  20780. /**
  20781. * Set the physics body. Used mainly by the physics engine/plugin
  20782. */
  20783. physicsBody: any;
  20784. /**
  20785. * Get the parent of the physics imposter
  20786. * @returns Physics imposter or null
  20787. */
  20788. /**
  20789. * Sets the parent of the physics imposter
  20790. */
  20791. parent: Nullable<PhysicsImpostor>;
  20792. /**
  20793. * Resets the update flags
  20794. */
  20795. resetUpdateFlags(): void;
  20796. /**
  20797. * Gets the object extend size
  20798. * @returns the object extend size
  20799. */
  20800. getObjectExtendSize(): Vector3;
  20801. /**
  20802. * Gets the object center
  20803. * @returns The object center
  20804. */
  20805. getObjectCenter(): Vector3;
  20806. /**
  20807. * Get a specific parametes from the options parameter
  20808. * @param paramName The object parameter name
  20809. * @returns The object parameter
  20810. */
  20811. getParam(paramName: string): any;
  20812. /**
  20813. * Sets a specific parameter in the options given to the physics plugin
  20814. * @param paramName The parameter name
  20815. * @param value The value of the parameter
  20816. */
  20817. setParam(paramName: string, value: number): void;
  20818. /**
  20819. * Specifically change the body's mass option. Won't recreate the physics body object
  20820. * @param mass The mass of the physics imposter
  20821. */
  20822. setMass(mass: number): void;
  20823. /**
  20824. * Gets the linear velocity
  20825. * @returns linear velocity or null
  20826. */
  20827. getLinearVelocity(): Nullable<Vector3>;
  20828. /**
  20829. * Sets the linear velocity
  20830. * @param velocity linear velocity or null
  20831. */
  20832. setLinearVelocity(velocity: Nullable<Vector3>): void;
  20833. /**
  20834. * Gets the angular velocity
  20835. * @returns angular velocity or null
  20836. */
  20837. getAngularVelocity(): Nullable<Vector3>;
  20838. /**
  20839. * Sets the angular velocity
  20840. * @param velocity The velocity or null
  20841. */
  20842. setAngularVelocity(velocity: Nullable<Vector3>): void;
  20843. /**
  20844. * Execute a function with the physics plugin native code
  20845. * Provide a function the will have two variables - the world object and the physics body object
  20846. * @param func The function to execute with the physics plugin native code
  20847. */
  20848. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  20849. /**
  20850. * Register a function that will be executed before the physics world is stepping forward
  20851. * @param func The function to execute before the physics world is stepped forward
  20852. */
  20853. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20854. /**
  20855. * Unregister a function that will be executed before the physics world is stepping forward
  20856. * @param func The function to execute before the physics world is stepped forward
  20857. */
  20858. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20859. /**
  20860. * Register a function that will be executed after the physics step
  20861. * @param func The function to execute after physics step
  20862. */
  20863. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20864. /**
  20865. * Unregisters a function that will be executed after the physics step
  20866. * @param func The function to execute after physics step
  20867. */
  20868. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  20869. /**
  20870. * register a function that will be executed when this impostor collides against a different body
  20871. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  20872. * @param func Callback that is executed on collision
  20873. */
  20874. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  20875. /**
  20876. * Unregisters the physics imposter on contact
  20877. * @param collideAgainst The physics object to collide against
  20878. * @param func Callback to execute on collision
  20879. */
  20880. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  20881. private _tmpQuat;
  20882. private _tmpQuat2;
  20883. /**
  20884. * Get the parent rotation
  20885. * @returns The parent rotation
  20886. */
  20887. getParentsRotation(): Quaternion;
  20888. /**
  20889. * this function is executed by the physics engine.
  20890. */
  20891. beforeStep: () => void;
  20892. /**
  20893. * this function is executed by the physics engine
  20894. */
  20895. afterStep: () => void;
  20896. /**
  20897. * Legacy collision detection event support
  20898. */
  20899. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  20900. /**
  20901. * event and body object due to cannon's event-based architecture.
  20902. */
  20903. onCollide: (e: {
  20904. body: any;
  20905. }) => void;
  20906. /**
  20907. * Apply a force
  20908. * @param force The force to apply
  20909. * @param contactPoint The contact point for the force
  20910. * @returns The physics imposter
  20911. */
  20912. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20913. /**
  20914. * Apply an impulse
  20915. * @param force The impulse force
  20916. * @param contactPoint The contact point for the impulse force
  20917. * @returns The physics imposter
  20918. */
  20919. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  20920. /**
  20921. * A help function to create a joint
  20922. * @param otherImpostor A physics imposter used to create a joint
  20923. * @param jointType The type of joint
  20924. * @param jointData The data for the joint
  20925. * @returns The physics imposter
  20926. */
  20927. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  20928. /**
  20929. * Add a joint to this impostor with a different impostor
  20930. * @param otherImpostor A physics imposter used to add a joint
  20931. * @param joint The joint to add
  20932. * @returns The physics imposter
  20933. */
  20934. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  20935. /**
  20936. * Add an anchor to a cloth impostor
  20937. * @param otherImpostor rigid impostor to anchor to
  20938. * @param width ratio across width from 0 to 1
  20939. * @param height ratio up height from 0 to 1
  20940. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  20941. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  20942. * @returns impostor the soft imposter
  20943. */
  20944. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20945. /**
  20946. * Add a hook to a rope impostor
  20947. * @param otherImpostor rigid impostor to anchor to
  20948. * @param length ratio across rope from 0 to 1
  20949. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  20950. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  20951. * @returns impostor the rope imposter
  20952. */
  20953. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  20954. /**
  20955. * Will keep this body still, in a sleep mode.
  20956. * @returns the physics imposter
  20957. */
  20958. sleep(): PhysicsImpostor;
  20959. /**
  20960. * Wake the body up.
  20961. * @returns The physics imposter
  20962. */
  20963. wakeUp(): PhysicsImpostor;
  20964. /**
  20965. * Clones the physics imposter
  20966. * @param newObject The physics imposter clones to this physics-enabled object
  20967. * @returns A nullable physics imposter
  20968. */
  20969. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  20970. /**
  20971. * Disposes the physics imposter
  20972. */
  20973. dispose(): void;
  20974. /**
  20975. * Sets the delta position
  20976. * @param position The delta position amount
  20977. */
  20978. setDeltaPosition(position: Vector3): void;
  20979. /**
  20980. * Sets the delta rotation
  20981. * @param rotation The delta rotation amount
  20982. */
  20983. setDeltaRotation(rotation: Quaternion): void;
  20984. /**
  20985. * Gets the box size of the physics imposter and stores the result in the input parameter
  20986. * @param result Stores the box size
  20987. * @returns The physics imposter
  20988. */
  20989. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  20990. /**
  20991. * Gets the radius of the physics imposter
  20992. * @returns Radius of the physics imposter
  20993. */
  20994. getRadius(): number;
  20995. /**
  20996. * Sync a bone with this impostor
  20997. * @param bone The bone to sync to the impostor.
  20998. * @param boneMesh The mesh that the bone is influencing.
  20999. * @param jointPivot The pivot of the joint / bone in local space.
  21000. * @param distToJoint Optional distance from the impostor to the joint.
  21001. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21002. */
  21003. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  21004. /**
  21005. * Sync impostor to a bone
  21006. * @param bone The bone that the impostor will be synced to.
  21007. * @param boneMesh The mesh that the bone is influencing.
  21008. * @param jointPivot The pivot of the joint / bone in local space.
  21009. * @param distToJoint Optional distance from the impostor to the joint.
  21010. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  21011. * @param boneAxis Optional vector3 axis the bone is aligned with
  21012. */
  21013. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  21014. /**
  21015. * No-Imposter type
  21016. */
  21017. static NoImpostor: number;
  21018. /**
  21019. * Sphere-Imposter type
  21020. */
  21021. static SphereImpostor: number;
  21022. /**
  21023. * Box-Imposter type
  21024. */
  21025. static BoxImpostor: number;
  21026. /**
  21027. * Plane-Imposter type
  21028. */
  21029. static PlaneImpostor: number;
  21030. /**
  21031. * Mesh-imposter type
  21032. */
  21033. static MeshImpostor: number;
  21034. /**
  21035. * Cylinder-Imposter type
  21036. */
  21037. static CylinderImpostor: number;
  21038. /**
  21039. * Particle-Imposter type
  21040. */
  21041. static ParticleImpostor: number;
  21042. /**
  21043. * Heightmap-Imposter type
  21044. */
  21045. static HeightmapImpostor: number;
  21046. /**
  21047. * ConvexHull-Impostor type (Ammo.js plugin only)
  21048. */
  21049. static ConvexHullImpostor: number;
  21050. /**
  21051. * Rope-Imposter type
  21052. */
  21053. static RopeImpostor: number;
  21054. /**
  21055. * Cloth-Imposter type
  21056. */
  21057. static ClothImpostor: number;
  21058. /**
  21059. * Softbody-Imposter type
  21060. */
  21061. static SoftbodyImpostor: number;
  21062. }
  21063. }
  21064. declare module "babylonjs/Meshes/mesh" {
  21065. import { Observable } from "babylonjs/Misc/observable";
  21066. import { IAnimatable } from "babylonjs/Misc/tools";
  21067. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  21068. import { Camera } from "babylonjs/Cameras/camera";
  21069. import { Scene } from "babylonjs/scene";
  21070. import { Matrix, Vector3, Vector2, Color4, Plane, Vector4, Path3D } from "babylonjs/Maths/math";
  21071. import { Engine } from "babylonjs/Engines/engine";
  21072. import { Node } from "babylonjs/node";
  21073. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  21074. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  21075. import { Buffer } from "babylonjs/Meshes/buffer";
  21076. import { Geometry } from "babylonjs/Meshes/geometry";
  21077. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21078. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21079. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  21080. import { Effect } from "babylonjs/Materials/effect";
  21081. import { Material } from "babylonjs/Materials/material";
  21082. import { Skeleton } from "babylonjs/Bones/skeleton";
  21083. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  21084. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  21085. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  21086. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  21087. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  21088. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  21089. /**
  21090. * Class used to represent a specific level of detail of a mesh
  21091. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21092. */
  21093. export class MeshLODLevel {
  21094. /** Defines the distance where this level should star being displayed */
  21095. distance: number;
  21096. /** Defines the mesh to use to render this level */
  21097. mesh: Nullable<Mesh>;
  21098. /**
  21099. * Creates a new LOD level
  21100. * @param distance defines the distance where this level should star being displayed
  21101. * @param mesh defines the mesh to use to render this level
  21102. */
  21103. constructor(
  21104. /** Defines the distance where this level should star being displayed */
  21105. distance: number,
  21106. /** Defines the mesh to use to render this level */
  21107. mesh: Nullable<Mesh>);
  21108. }
  21109. /**
  21110. * @hidden
  21111. **/
  21112. export class _CreationDataStorage {
  21113. closePath?: boolean;
  21114. closeArray?: boolean;
  21115. idx: number[];
  21116. dashSize: number;
  21117. gapSize: number;
  21118. path3D: Path3D;
  21119. pathArray: Vector3[][];
  21120. arc: number;
  21121. radius: number;
  21122. cap: number;
  21123. tessellation: number;
  21124. }
  21125. /**
  21126. * @hidden
  21127. **/
  21128. class _InstanceDataStorage {
  21129. visibleInstances: any;
  21130. batchCache: _InstancesBatch;
  21131. instancesBufferSize: number;
  21132. instancesBuffer: Nullable<Buffer>;
  21133. instancesData: Float32Array;
  21134. overridenInstanceCount: number;
  21135. isFrozen: boolean;
  21136. previousBatch: _InstancesBatch;
  21137. hardwareInstancedRendering: boolean;
  21138. sideOrientation: number;
  21139. }
  21140. /**
  21141. * @hidden
  21142. **/
  21143. export class _InstancesBatch {
  21144. mustReturn: boolean;
  21145. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  21146. renderSelf: boolean[];
  21147. hardwareInstancedRendering: boolean[];
  21148. }
  21149. /**
  21150. * Class used to represent renderable models
  21151. */
  21152. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  21153. /**
  21154. * Mesh side orientation : usually the external or front surface
  21155. */
  21156. static readonly FRONTSIDE: number;
  21157. /**
  21158. * Mesh side orientation : usually the internal or back surface
  21159. */
  21160. static readonly BACKSIDE: number;
  21161. /**
  21162. * Mesh side orientation : both internal and external or front and back surfaces
  21163. */
  21164. static readonly DOUBLESIDE: number;
  21165. /**
  21166. * Mesh side orientation : by default, `FRONTSIDE`
  21167. */
  21168. static readonly DEFAULTSIDE: number;
  21169. /**
  21170. * Mesh cap setting : no cap
  21171. */
  21172. static readonly NO_CAP: number;
  21173. /**
  21174. * Mesh cap setting : one cap at the beginning of the mesh
  21175. */
  21176. static readonly CAP_START: number;
  21177. /**
  21178. * Mesh cap setting : one cap at the end of the mesh
  21179. */
  21180. static readonly CAP_END: number;
  21181. /**
  21182. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  21183. */
  21184. static readonly CAP_ALL: number;
  21185. /**
  21186. * Gets the default side orientation.
  21187. * @param orientation the orientation to value to attempt to get
  21188. * @returns the default orientation
  21189. * @hidden
  21190. */
  21191. static _GetDefaultSideOrientation(orientation?: number): number;
  21192. private _onBeforeRenderObservable;
  21193. private _onBeforeBindObservable;
  21194. private _onAfterRenderObservable;
  21195. private _onBeforeDrawObservable;
  21196. /**
  21197. * An event triggered before rendering the mesh
  21198. */
  21199. readonly onBeforeRenderObservable: Observable<Mesh>;
  21200. /**
  21201. * An event triggered before binding the mesh
  21202. */
  21203. readonly onBeforeBindObservable: Observable<Mesh>;
  21204. /**
  21205. * An event triggered after rendering the mesh
  21206. */
  21207. readonly onAfterRenderObservable: Observable<Mesh>;
  21208. /**
  21209. * An event triggered before drawing the mesh
  21210. */
  21211. readonly onBeforeDrawObservable: Observable<Mesh>;
  21212. private _onBeforeDrawObserver;
  21213. /**
  21214. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  21215. */
  21216. onBeforeDraw: () => void;
  21217. /**
  21218. * Gets the delay loading state of the mesh (when delay loading is turned on)
  21219. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  21220. */
  21221. delayLoadState: number;
  21222. /**
  21223. * Gets the list of instances created from this mesh
  21224. * it is not supposed to be modified manually.
  21225. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  21226. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21227. */
  21228. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  21229. /**
  21230. * Gets the file containing delay loading data for this mesh
  21231. */
  21232. delayLoadingFile: string;
  21233. /** @hidden */
  21234. _binaryInfo: any;
  21235. private _LODLevels;
  21236. /**
  21237. * User defined function used to change how LOD level selection is done
  21238. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  21239. */
  21240. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  21241. private _morphTargetManager;
  21242. /**
  21243. * Gets or sets the morph target manager
  21244. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  21245. */
  21246. morphTargetManager: Nullable<MorphTargetManager>;
  21247. /** @hidden */
  21248. _creationDataStorage: Nullable<_CreationDataStorage>;
  21249. /** @hidden */
  21250. _geometry: Nullable<Geometry>;
  21251. /** @hidden */
  21252. _delayInfo: Array<string>;
  21253. /** @hidden */
  21254. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  21255. /** @hidden */
  21256. _instanceDataStorage: _InstanceDataStorage;
  21257. private _effectiveMaterial;
  21258. /** @hidden */
  21259. _shouldGenerateFlatShading: boolean;
  21260. private _preActivateId;
  21261. /** @hidden */
  21262. _originalBuilderSideOrientation: number;
  21263. /**
  21264. * Use this property to change the original side orientation defined at construction time
  21265. */
  21266. overrideMaterialSideOrientation: Nullable<number>;
  21267. private _areNormalsFrozen;
  21268. private _sourcePositions;
  21269. private _sourceNormals;
  21270. private _source;
  21271. private meshMap;
  21272. /**
  21273. * Gets the source mesh (the one used to clone this one from)
  21274. */
  21275. readonly source: Nullable<Mesh>;
  21276. /**
  21277. * Gets or sets a boolean indicating that this mesh does not use index buffer
  21278. */
  21279. isUnIndexed: boolean;
  21280. /**
  21281. * @constructor
  21282. * @param name The value used by scene.getMeshByName() to do a lookup.
  21283. * @param scene The scene to add this mesh to.
  21284. * @param parent The parent of this mesh, if it has one
  21285. * @param source An optional Mesh from which geometry is shared, cloned.
  21286. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  21287. * When false, achieved by calling a clone(), also passing False.
  21288. * This will make creation of children, recursive.
  21289. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  21290. */
  21291. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  21292. /**
  21293. * Gets the class name
  21294. * @returns the string "Mesh".
  21295. */
  21296. getClassName(): string;
  21297. /** @hidden */
  21298. readonly _isMesh: boolean;
  21299. /**
  21300. * Returns a description of this mesh
  21301. * @param fullDetails define if full details about this mesh must be used
  21302. * @returns a descriptive string representing this mesh
  21303. */
  21304. toString(fullDetails?: boolean): string;
  21305. /** @hidden */
  21306. _unBindEffect(): void;
  21307. /**
  21308. * Gets a boolean indicating if this mesh has LOD
  21309. */
  21310. readonly hasLODLevels: boolean;
  21311. /**
  21312. * Gets the list of MeshLODLevel associated with the current mesh
  21313. * @returns an array of MeshLODLevel
  21314. */
  21315. getLODLevels(): MeshLODLevel[];
  21316. private _sortLODLevels;
  21317. /**
  21318. * Add a mesh as LOD level triggered at the given distance.
  21319. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21320. * @param distance The distance from the center of the object to show this level
  21321. * @param mesh The mesh to be added as LOD level (can be null)
  21322. * @return This mesh (for chaining)
  21323. */
  21324. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  21325. /**
  21326. * Returns the LOD level mesh at the passed distance or null if not found.
  21327. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21328. * @param distance The distance from the center of the object to show this level
  21329. * @returns a Mesh or `null`
  21330. */
  21331. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  21332. /**
  21333. * Remove a mesh from the LOD array
  21334. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21335. * @param mesh defines the mesh to be removed
  21336. * @return This mesh (for chaining)
  21337. */
  21338. removeLODLevel(mesh: Mesh): Mesh;
  21339. /**
  21340. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  21341. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  21342. * @param camera defines the camera to use to compute distance
  21343. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  21344. * @return This mesh (for chaining)
  21345. */
  21346. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  21347. /**
  21348. * Gets the mesh internal Geometry object
  21349. */
  21350. readonly geometry: Nullable<Geometry>;
  21351. /**
  21352. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  21353. * @returns the total number of vertices
  21354. */
  21355. getTotalVertices(): number;
  21356. /**
  21357. * Returns the content of an associated vertex buffer
  21358. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21359. * - VertexBuffer.PositionKind
  21360. * - VertexBuffer.UVKind
  21361. * - VertexBuffer.UV2Kind
  21362. * - VertexBuffer.UV3Kind
  21363. * - VertexBuffer.UV4Kind
  21364. * - VertexBuffer.UV5Kind
  21365. * - VertexBuffer.UV6Kind
  21366. * - VertexBuffer.ColorKind
  21367. * - VertexBuffer.MatricesIndicesKind
  21368. * - VertexBuffer.MatricesIndicesExtraKind
  21369. * - VertexBuffer.MatricesWeightsKind
  21370. * - VertexBuffer.MatricesWeightsExtraKind
  21371. * @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
  21372. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  21373. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  21374. */
  21375. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  21376. /**
  21377. * Returns the mesh VertexBuffer object from the requested `kind`
  21378. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21379. * - VertexBuffer.PositionKind
  21380. * - VertexBuffer.UVKind
  21381. * - VertexBuffer.UV2Kind
  21382. * - VertexBuffer.UV3Kind
  21383. * - VertexBuffer.UV4Kind
  21384. * - VertexBuffer.UV5Kind
  21385. * - VertexBuffer.UV6Kind
  21386. * - VertexBuffer.ColorKind
  21387. * - VertexBuffer.MatricesIndicesKind
  21388. * - VertexBuffer.MatricesIndicesExtraKind
  21389. * - VertexBuffer.MatricesWeightsKind
  21390. * - VertexBuffer.MatricesWeightsExtraKind
  21391. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  21392. */
  21393. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  21394. /**
  21395. * Tests if a specific vertex buffer is associated with this mesh
  21396. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21397. * - VertexBuffer.PositionKind
  21398. * - VertexBuffer.UVKind
  21399. * - VertexBuffer.UV2Kind
  21400. * - VertexBuffer.UV3Kind
  21401. * - VertexBuffer.UV4Kind
  21402. * - VertexBuffer.UV5Kind
  21403. * - VertexBuffer.UV6Kind
  21404. * - VertexBuffer.ColorKind
  21405. * - VertexBuffer.MatricesIndicesKind
  21406. * - VertexBuffer.MatricesIndicesExtraKind
  21407. * - VertexBuffer.MatricesWeightsKind
  21408. * - VertexBuffer.MatricesWeightsExtraKind
  21409. * @returns a boolean
  21410. */
  21411. isVerticesDataPresent(kind: string): boolean;
  21412. /**
  21413. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  21414. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  21415. * - VertexBuffer.PositionKind
  21416. * - VertexBuffer.UVKind
  21417. * - VertexBuffer.UV2Kind
  21418. * - VertexBuffer.UV3Kind
  21419. * - VertexBuffer.UV4Kind
  21420. * - VertexBuffer.UV5Kind
  21421. * - VertexBuffer.UV6Kind
  21422. * - VertexBuffer.ColorKind
  21423. * - VertexBuffer.MatricesIndicesKind
  21424. * - VertexBuffer.MatricesIndicesExtraKind
  21425. * - VertexBuffer.MatricesWeightsKind
  21426. * - VertexBuffer.MatricesWeightsExtraKind
  21427. * @returns a boolean
  21428. */
  21429. isVertexBufferUpdatable(kind: string): boolean;
  21430. /**
  21431. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  21432. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  21433. * - VertexBuffer.PositionKind
  21434. * - VertexBuffer.UVKind
  21435. * - VertexBuffer.UV2Kind
  21436. * - VertexBuffer.UV3Kind
  21437. * - VertexBuffer.UV4Kind
  21438. * - VertexBuffer.UV5Kind
  21439. * - VertexBuffer.UV6Kind
  21440. * - VertexBuffer.ColorKind
  21441. * - VertexBuffer.MatricesIndicesKind
  21442. * - VertexBuffer.MatricesIndicesExtraKind
  21443. * - VertexBuffer.MatricesWeightsKind
  21444. * - VertexBuffer.MatricesWeightsExtraKind
  21445. * @returns an array of strings
  21446. */
  21447. getVerticesDataKinds(): string[];
  21448. /**
  21449. * Returns a positive integer : the total number of indices in this mesh geometry.
  21450. * @returns the numner of indices or zero if the mesh has no geometry.
  21451. */
  21452. getTotalIndices(): number;
  21453. /**
  21454. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  21455. * @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.
  21456. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  21457. * @returns the indices array or an empty array if the mesh has no geometry
  21458. */
  21459. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  21460. readonly isBlocked: boolean;
  21461. /**
  21462. * Determine if the current mesh is ready to be rendered
  21463. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  21464. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  21465. * @returns true if all associated assets are ready (material, textures, shaders)
  21466. */
  21467. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  21468. /**
  21469. * 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.
  21470. */
  21471. readonly areNormalsFrozen: boolean;
  21472. /**
  21473. * 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.
  21474. * @returns the current mesh
  21475. */
  21476. freezeNormals(): Mesh;
  21477. /**
  21478. * 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
  21479. * @returns the current mesh
  21480. */
  21481. unfreezeNormals(): Mesh;
  21482. /**
  21483. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  21484. */
  21485. overridenInstanceCount: number;
  21486. /** @hidden */
  21487. _preActivate(): Mesh;
  21488. /** @hidden */
  21489. _preActivateForIntermediateRendering(renderId: number): Mesh;
  21490. /** @hidden */
  21491. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  21492. /**
  21493. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  21494. * This means the mesh underlying bounding box and sphere are recomputed.
  21495. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  21496. * @returns the current mesh
  21497. */
  21498. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  21499. /** @hidden */
  21500. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  21501. /**
  21502. * This function will subdivide the mesh into multiple submeshes
  21503. * @param count defines the expected number of submeshes
  21504. */
  21505. subdivide(count: number): void;
  21506. /**
  21507. * Copy a FloatArray into a specific associated vertex buffer
  21508. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21509. * - VertexBuffer.PositionKind
  21510. * - VertexBuffer.UVKind
  21511. * - VertexBuffer.UV2Kind
  21512. * - VertexBuffer.UV3Kind
  21513. * - VertexBuffer.UV4Kind
  21514. * - VertexBuffer.UV5Kind
  21515. * - VertexBuffer.UV6Kind
  21516. * - VertexBuffer.ColorKind
  21517. * - VertexBuffer.MatricesIndicesKind
  21518. * - VertexBuffer.MatricesIndicesExtraKind
  21519. * - VertexBuffer.MatricesWeightsKind
  21520. * - VertexBuffer.MatricesWeightsExtraKind
  21521. * @param data defines the data source
  21522. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21523. * @param stride defines the data stride size (can be null)
  21524. * @returns the current mesh
  21525. */
  21526. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  21527. /**
  21528. * Flags an associated vertex buffer as updatable
  21529. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  21530. * - VertexBuffer.PositionKind
  21531. * - VertexBuffer.UVKind
  21532. * - VertexBuffer.UV2Kind
  21533. * - VertexBuffer.UV3Kind
  21534. * - VertexBuffer.UV4Kind
  21535. * - VertexBuffer.UV5Kind
  21536. * - VertexBuffer.UV6Kind
  21537. * - VertexBuffer.ColorKind
  21538. * - VertexBuffer.MatricesIndicesKind
  21539. * - VertexBuffer.MatricesIndicesExtraKind
  21540. * - VertexBuffer.MatricesWeightsKind
  21541. * - VertexBuffer.MatricesWeightsExtraKind
  21542. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  21543. */
  21544. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  21545. /**
  21546. * Sets the mesh global Vertex Buffer
  21547. * @param buffer defines the buffer to use
  21548. * @returns the current mesh
  21549. */
  21550. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  21551. /**
  21552. * Update a specific associated vertex buffer
  21553. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  21554. * - VertexBuffer.PositionKind
  21555. * - VertexBuffer.UVKind
  21556. * - VertexBuffer.UV2Kind
  21557. * - VertexBuffer.UV3Kind
  21558. * - VertexBuffer.UV4Kind
  21559. * - VertexBuffer.UV5Kind
  21560. * - VertexBuffer.UV6Kind
  21561. * - VertexBuffer.ColorKind
  21562. * - VertexBuffer.MatricesIndicesKind
  21563. * - VertexBuffer.MatricesIndicesExtraKind
  21564. * - VertexBuffer.MatricesWeightsKind
  21565. * - VertexBuffer.MatricesWeightsExtraKind
  21566. * @param data defines the data source
  21567. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  21568. * @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)
  21569. * @returns the current mesh
  21570. */
  21571. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  21572. /**
  21573. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  21574. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  21575. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  21576. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  21577. * @returns the current mesh
  21578. */
  21579. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  21580. /**
  21581. * Creates a un-shared specific occurence of the geometry for the mesh.
  21582. * @returns the current mesh
  21583. */
  21584. makeGeometryUnique(): Mesh;
  21585. /**
  21586. * Set the index buffer of this mesh
  21587. * @param indices defines the source data
  21588. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  21589. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  21590. * @returns the current mesh
  21591. */
  21592. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  21593. /**
  21594. * Update the current index buffer
  21595. * @param indices defines the source data
  21596. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  21597. * @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)
  21598. * @returns the current mesh
  21599. */
  21600. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  21601. /**
  21602. * Invert the geometry to move from a right handed system to a left handed one.
  21603. * @returns the current mesh
  21604. */
  21605. toLeftHanded(): Mesh;
  21606. /** @hidden */
  21607. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  21608. /** @hidden */
  21609. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  21610. /**
  21611. * Registers for this mesh a javascript function called just before the rendering process
  21612. * @param func defines the function to call before rendering this mesh
  21613. * @returns the current mesh
  21614. */
  21615. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21616. /**
  21617. * Disposes a previously registered javascript function called before the rendering
  21618. * @param func defines the function to remove
  21619. * @returns the current mesh
  21620. */
  21621. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  21622. /**
  21623. * Registers for this mesh a javascript function called just after the rendering is complete
  21624. * @param func defines the function to call after rendering this mesh
  21625. * @returns the current mesh
  21626. */
  21627. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21628. /**
  21629. * Disposes a previously registered javascript function called after the rendering.
  21630. * @param func defines the function to remove
  21631. * @returns the current mesh
  21632. */
  21633. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  21634. /** @hidden */
  21635. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  21636. /** @hidden */
  21637. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  21638. /** @hidden */
  21639. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  21640. /** @hidden */
  21641. _freeze(): void;
  21642. /** @hidden */
  21643. _unFreeze(): void;
  21644. /**
  21645. * 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
  21646. * @param subMesh defines the subMesh to render
  21647. * @param enableAlphaMode defines if alpha mode can be changed
  21648. * @returns the current mesh
  21649. */
  21650. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  21651. private _onBeforeDraw;
  21652. /**
  21653. * Renormalize the mesh and patch it up if there are no weights
  21654. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  21655. * However in the case of zero weights then we set just a single influence to 1.
  21656. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  21657. */
  21658. cleanMatrixWeights(): void;
  21659. private normalizeSkinFourWeights;
  21660. private normalizeSkinWeightsAndExtra;
  21661. /**
  21662. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  21663. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  21664. * the user know there was an issue with importing the mesh
  21665. * @returns a validation object with skinned, valid and report string
  21666. */
  21667. validateSkinning(): {
  21668. skinned: boolean;
  21669. valid: boolean;
  21670. report: string;
  21671. };
  21672. /** @hidden */
  21673. _checkDelayState(): Mesh;
  21674. private _queueLoad;
  21675. /**
  21676. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  21677. * A mesh is in the frustum if its bounding box intersects the frustum
  21678. * @param frustumPlanes defines the frustum to test
  21679. * @returns true if the mesh is in the frustum planes
  21680. */
  21681. isInFrustum(frustumPlanes: Plane[]): boolean;
  21682. /**
  21683. * Sets the mesh material by the material or multiMaterial `id` property
  21684. * @param id is a string identifying the material or the multiMaterial
  21685. * @returns the current mesh
  21686. */
  21687. setMaterialByID(id: string): Mesh;
  21688. /**
  21689. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  21690. * @returns an array of IAnimatable
  21691. */
  21692. getAnimatables(): IAnimatable[];
  21693. /**
  21694. * Modifies the mesh geometry according to the passed transformation matrix.
  21695. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  21696. * The mesh normals are modified using the same transformation.
  21697. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21698. * @param transform defines the transform matrix to use
  21699. * @see http://doc.babylonjs.com/resources/baking_transformations
  21700. * @returns the current mesh
  21701. */
  21702. bakeTransformIntoVertices(transform: Matrix): Mesh;
  21703. /**
  21704. * Modifies the mesh geometry according to its own current World Matrix.
  21705. * The mesh World Matrix is then reset.
  21706. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  21707. * Note that, under the hood, this method sets a new VertexBuffer each call.
  21708. * @see http://doc.babylonjs.com/resources/baking_transformations
  21709. * @returns the current mesh
  21710. */
  21711. bakeCurrentTransformIntoVertices(): Mesh;
  21712. /** @hidden */
  21713. readonly _positions: Nullable<Vector3[]>;
  21714. /** @hidden */
  21715. _resetPointsArrayCache(): Mesh;
  21716. /** @hidden */
  21717. _generatePointsArray(): boolean;
  21718. /**
  21719. * Returns a new Mesh object generated from the current mesh properties.
  21720. * This method must not get confused with createInstance()
  21721. * @param name is a string, the name given to the new mesh
  21722. * @param newParent can be any Node object (default `null`)
  21723. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  21724. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  21725. * @returns a new mesh
  21726. */
  21727. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  21728. /**
  21729. * Releases resources associated with this mesh.
  21730. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  21731. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  21732. */
  21733. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  21734. /**
  21735. * Modifies the mesh geometry according to a displacement map.
  21736. * 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.
  21737. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21738. * @param url is a string, the URL from the image file is to be downloaded.
  21739. * @param minHeight is the lower limit of the displacement.
  21740. * @param maxHeight is the upper limit of the displacement.
  21741. * @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.
  21742. * @param uvOffset is an optional vector2 used to offset UV.
  21743. * @param uvScale is an optional vector2 used to scale UV.
  21744. * @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.
  21745. * @returns the Mesh.
  21746. */
  21747. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21748. /**
  21749. * Modifies the mesh geometry according to a displacementMap buffer.
  21750. * 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.
  21751. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  21752. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  21753. * @param heightMapWidth is the width of the buffer image.
  21754. * @param heightMapHeight is the height of the buffer image.
  21755. * @param minHeight is the lower limit of the displacement.
  21756. * @param maxHeight is the upper limit of the displacement.
  21757. * @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.
  21758. * @param uvOffset is an optional vector2 used to offset UV.
  21759. * @param uvScale is an optional vector2 used to scale UV.
  21760. * @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.
  21761. * @returns the Mesh.
  21762. */
  21763. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  21764. /**
  21765. * Modify the mesh to get a flat shading rendering.
  21766. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  21767. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  21768. * @returns current mesh
  21769. */
  21770. convertToFlatShadedMesh(): Mesh;
  21771. /**
  21772. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  21773. * In other words, more vertices, no more indices and a single bigger VBO.
  21774. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  21775. * @returns current mesh
  21776. */
  21777. convertToUnIndexedMesh(): Mesh;
  21778. /**
  21779. * Inverses facet orientations.
  21780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21781. * @param flipNormals will also inverts the normals
  21782. * @returns current mesh
  21783. */
  21784. flipFaces(flipNormals?: boolean): Mesh;
  21785. /**
  21786. * Increase the number of facets and hence vertices in a mesh
  21787. * Vertex normals are interpolated from existing vertex normals
  21788. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21789. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  21790. */
  21791. increaseVertices(numberPerEdge: number): void;
  21792. /**
  21793. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  21794. * This will undo any application of covertToFlatShadedMesh
  21795. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  21796. */
  21797. forceSharedVertices(): void;
  21798. /** @hidden */
  21799. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  21800. /** @hidden */
  21801. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  21802. /**
  21803. * Creates a new InstancedMesh object from the mesh model.
  21804. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  21805. * @param name defines the name of the new instance
  21806. * @returns a new InstancedMesh
  21807. */
  21808. createInstance(name: string): InstancedMesh;
  21809. /**
  21810. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  21811. * After this call, all the mesh instances have the same submeshes than the current mesh.
  21812. * @returns the current mesh
  21813. */
  21814. synchronizeInstances(): Mesh;
  21815. /**
  21816. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  21817. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  21818. * This should be used together with the simplification to avoid disappearing triangles.
  21819. * @param successCallback an optional success callback to be called after the optimization finished.
  21820. * @returns the current mesh
  21821. */
  21822. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  21823. /**
  21824. * Serialize current mesh
  21825. * @param serializationObject defines the object which will receive the serialization data
  21826. */
  21827. serialize(serializationObject: any): void;
  21828. /** @hidden */
  21829. _syncGeometryWithMorphTargetManager(): void;
  21830. /** @hidden */
  21831. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  21832. /**
  21833. * Returns a new Mesh object parsed from the source provided.
  21834. * @param parsedMesh is the source
  21835. * @param scene defines the hosting scene
  21836. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  21837. * @returns a new Mesh
  21838. */
  21839. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  21840. /**
  21841. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  21842. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21843. * @param name defines the name of the mesh to create
  21844. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  21845. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  21846. * @param closePath creates a seam between the first and the last points of each path of the path array
  21847. * @param offset is taken in account only if the `pathArray` is containing a single path
  21848. * @param scene defines the hosting scene
  21849. * @param updatable defines if the mesh must be flagged as updatable
  21850. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21851. * @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)
  21852. * @returns a new Mesh
  21853. */
  21854. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  21855. /**
  21856. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  21857. * @param name defines the name of the mesh to create
  21858. * @param radius sets the radius size (float) of the polygon (default 0.5)
  21859. * @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
  21860. * @param scene defines the hosting scene
  21861. * @param updatable defines if the mesh must be flagged as updatable
  21862. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21863. * @returns a new Mesh
  21864. */
  21865. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21866. /**
  21867. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  21868. * @param name defines the name of the mesh to create
  21869. * @param size sets the size (float) of each box side (default 1)
  21870. * @param scene defines the hosting scene
  21871. * @param updatable defines if the mesh must be flagged as updatable
  21872. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21873. * @returns a new Mesh
  21874. */
  21875. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  21876. /**
  21877. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  21878. * @param name defines the name of the mesh to create
  21879. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21880. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21881. * @param scene defines the hosting scene
  21882. * @param updatable defines if the mesh must be flagged as updatable
  21883. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21884. * @returns a new Mesh
  21885. */
  21886. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21887. /**
  21888. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  21889. * @param name defines the name of the mesh to create
  21890. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  21891. * @param diameter sets the diameter size (float) of the sphere (default 1)
  21892. * @param scene defines the hosting scene
  21893. * @returns a new Mesh
  21894. */
  21895. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  21896. /**
  21897. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  21898. * @param name defines the name of the mesh to create
  21899. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  21900. * @param diameterTop set the top cap diameter (floats, default 1)
  21901. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  21902. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  21903. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  21904. * @param scene defines the hosting scene
  21905. * @param updatable defines if the mesh must be flagged as updatable
  21906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21907. * @returns a new Mesh
  21908. */
  21909. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  21910. /**
  21911. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  21912. * @param name defines the name of the mesh to create
  21913. * @param diameter sets the diameter size (float) of the torus (default 1)
  21914. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  21915. * @param tessellation sets the number of torus sides (postive integer, default 16)
  21916. * @param scene defines the hosting scene
  21917. * @param updatable defines if the mesh must be flagged as updatable
  21918. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21919. * @returns a new Mesh
  21920. */
  21921. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21922. /**
  21923. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  21924. * @param name defines the name of the mesh to create
  21925. * @param radius sets the global radius size (float) of the torus knot (default 2)
  21926. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  21927. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  21928. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  21929. * @param p the number of windings on X axis (positive integers, default 2)
  21930. * @param q the number of windings on Y axis (positive integers, default 3)
  21931. * @param scene defines the hosting scene
  21932. * @param updatable defines if the mesh must be flagged as updatable
  21933. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21934. * @returns a new Mesh
  21935. */
  21936. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  21937. /**
  21938. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  21939. * @param name defines the name of the mesh to create
  21940. * @param points is an array successive Vector3
  21941. * @param scene defines the hosting scene
  21942. * @param updatable defines if the mesh must be flagged as updatable
  21943. * @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).
  21944. * @returns a new Mesh
  21945. */
  21946. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  21947. /**
  21948. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  21949. * @param name defines the name of the mesh to create
  21950. * @param points is an array successive Vector3
  21951. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  21952. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  21953. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  21954. * @param scene defines the hosting scene
  21955. * @param updatable defines if the mesh must be flagged as updatable
  21956. * @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)
  21957. * @returns a new Mesh
  21958. */
  21959. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  21960. /**
  21961. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  21962. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  21963. * 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.
  21964. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  21965. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  21966. * Remember you can only change the shape positions, not their number when updating a polygon.
  21967. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  21968. * @param name defines the name of the mesh to create
  21969. * @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
  21970. * @param scene defines the hosting scene
  21971. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21972. * @param updatable defines if the mesh must be flagged as updatable
  21973. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21974. * @param earcutInjection can be used to inject your own earcut reference
  21975. * @returns a new Mesh
  21976. */
  21977. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21978. /**
  21979. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  21980. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  21981. * @param name defines the name of the mesh to create
  21982. * @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
  21983. * @param depth defines the height of extrusion
  21984. * @param scene defines the hosting scene
  21985. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  21986. * @param updatable defines if the mesh must be flagged as updatable
  21987. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  21988. * @param earcutInjection can be used to inject your own earcut reference
  21989. * @returns a new Mesh
  21990. */
  21991. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  21992. /**
  21993. * Creates an extruded shape mesh.
  21994. * 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
  21995. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  21996. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  21997. * @param name defines the name of the mesh to create
  21998. * @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
  21999. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22000. * @param scale is the value to scale the shape
  22001. * @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
  22002. * @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
  22003. * @param scene defines the hosting scene
  22004. * @param updatable defines if the mesh must be flagged as updatable
  22005. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22006. * @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)
  22007. * @returns a new Mesh
  22008. */
  22009. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22010. /**
  22011. * Creates an custom extruded shape mesh.
  22012. * The custom extrusion is a parametric shape.
  22013. * It has no predefined shape. Its final shape will depend on the input parameters.
  22014. * Please consider using the same method from the MeshBuilder class instead
  22015. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  22016. * @param name defines the name of the mesh to create
  22017. * @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
  22018. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  22019. * @param scaleFunction is a custom Javascript function called on each path point
  22020. * @param rotationFunction is a custom Javascript function called on each path point
  22021. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  22022. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  22023. * @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
  22024. * @param scene defines the hosting scene
  22025. * @param updatable defines if the mesh must be flagged as updatable
  22026. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22027. * @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)
  22028. * @returns a new Mesh
  22029. */
  22030. 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;
  22031. /**
  22032. * Creates lathe mesh.
  22033. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  22034. * Please consider using the same method from the MeshBuilder class instead
  22035. * @param name defines the name of the mesh to create
  22036. * @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
  22037. * @param radius is the radius value of the lathe
  22038. * @param tessellation is the side number of the lathe.
  22039. * @param scene defines the hosting scene
  22040. * @param updatable defines if the mesh must be flagged as updatable
  22041. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22042. * @returns a new Mesh
  22043. */
  22044. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22045. /**
  22046. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  22047. * @param name defines the name of the mesh to create
  22048. * @param size sets the size (float) of both sides of the plane at once (default 1)
  22049. * @param scene defines the hosting scene
  22050. * @param updatable defines if the mesh must be flagged as updatable
  22051. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22052. * @returns a new Mesh
  22053. */
  22054. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  22055. /**
  22056. * Creates a ground mesh.
  22057. * Please consider using the same method from the MeshBuilder class instead
  22058. * @param name defines the name of the mesh to create
  22059. * @param width set the width of the ground
  22060. * @param height set the height of the ground
  22061. * @param subdivisions sets the number of subdivisions per side
  22062. * @param scene defines the hosting scene
  22063. * @param updatable defines if the mesh must be flagged as updatable
  22064. * @returns a new Mesh
  22065. */
  22066. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  22067. /**
  22068. * Creates a tiled ground mesh.
  22069. * Please consider using the same method from the MeshBuilder class instead
  22070. * @param name defines the name of the mesh to create
  22071. * @param xmin set the ground minimum X coordinate
  22072. * @param zmin set the ground minimum Y coordinate
  22073. * @param xmax set the ground maximum X coordinate
  22074. * @param zmax set the ground maximum Z coordinate
  22075. * @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
  22076. * @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
  22077. * @param scene defines the hosting scene
  22078. * @param updatable defines if the mesh must be flagged as updatable
  22079. * @returns a new Mesh
  22080. */
  22081. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  22082. w: number;
  22083. h: number;
  22084. }, precision: {
  22085. w: number;
  22086. h: number;
  22087. }, scene: Scene, updatable?: boolean): Mesh;
  22088. /**
  22089. * Creates a ground mesh from a height map.
  22090. * Please consider using the same method from the MeshBuilder class instead
  22091. * @see http://doc.babylonjs.com/babylon101/height_map
  22092. * @param name defines the name of the mesh to create
  22093. * @param url sets the URL of the height map image resource
  22094. * @param width set the ground width size
  22095. * @param height set the ground height size
  22096. * @param subdivisions sets the number of subdivision per side
  22097. * @param minHeight is the minimum altitude on the ground
  22098. * @param maxHeight is the maximum altitude on the ground
  22099. * @param scene defines the hosting scene
  22100. * @param updatable defines if the mesh must be flagged as updatable
  22101. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  22102. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  22103. * @returns a new Mesh
  22104. */
  22105. 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;
  22106. /**
  22107. * Creates a tube mesh.
  22108. * The tube is a parametric shape.
  22109. * It has no predefined shape. Its final shape will depend on the input parameters.
  22110. * Please consider using the same method from the MeshBuilder class instead
  22111. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  22112. * @param name defines the name of the mesh to create
  22113. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  22114. * @param radius sets the tube radius size
  22115. * @param tessellation is the number of sides on the tubular surface
  22116. * @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
  22117. * @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
  22118. * @param scene defines the hosting scene
  22119. * @param updatable defines if the mesh must be flagged as updatable
  22120. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  22121. * @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)
  22122. * @returns a new Mesh
  22123. */
  22124. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  22125. (i: number, distance: number): number;
  22126. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  22127. /**
  22128. * Creates a polyhedron mesh.
  22129. * Please consider using the same method from the MeshBuilder class instead.
  22130. * * 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
  22131. * * The parameter `size` (positive float, default 1) sets the polygon size
  22132. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  22133. * * 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`
  22134. * * 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
  22135. * * 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)`)
  22136. * * 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
  22137. * * 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
  22138. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22139. * * If you create a double-sided mesh, you can choose what parts of 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
  22140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22141. * @param name defines the name of the mesh to create
  22142. * @param options defines the options used to create the mesh
  22143. * @param scene defines the hosting scene
  22144. * @returns a new Mesh
  22145. */
  22146. static CreatePolyhedron(name: string, options: {
  22147. type?: number;
  22148. size?: number;
  22149. sizeX?: number;
  22150. sizeY?: number;
  22151. sizeZ?: number;
  22152. custom?: any;
  22153. faceUV?: Vector4[];
  22154. faceColors?: Color4[];
  22155. updatable?: boolean;
  22156. sideOrientation?: number;
  22157. }, scene: Scene): Mesh;
  22158. /**
  22159. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  22160. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  22161. * * 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`)
  22162. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  22163. * * 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
  22164. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  22165. * * If you create a double-sided mesh, you can choose what parts of 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
  22166. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  22167. * @param name defines the name of the mesh
  22168. * @param options defines the options used to create the mesh
  22169. * @param scene defines the hosting scene
  22170. * @returns a new Mesh
  22171. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  22172. */
  22173. static CreateIcoSphere(name: string, options: {
  22174. radius?: number;
  22175. flat?: boolean;
  22176. subdivisions?: number;
  22177. sideOrientation?: number;
  22178. updatable?: boolean;
  22179. }, scene: Scene): Mesh;
  22180. /**
  22181. * Creates a decal mesh.
  22182. * Please consider using the same method from the MeshBuilder class instead.
  22183. * A decal is a mesh usually applied as a model onto the surface of another mesh
  22184. * @param name defines the name of the mesh
  22185. * @param sourceMesh defines the mesh receiving the decal
  22186. * @param position sets the position of the decal in world coordinates
  22187. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  22188. * @param size sets the decal scaling
  22189. * @param angle sets the angle to rotate the decal
  22190. * @returns a new Mesh
  22191. */
  22192. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  22193. /**
  22194. * Prepare internal position array for software CPU skinning
  22195. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  22196. */
  22197. setPositionsForCPUSkinning(): Float32Array;
  22198. /**
  22199. * Prepare internal normal array for software CPU skinning
  22200. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  22201. */
  22202. setNormalsForCPUSkinning(): Float32Array;
  22203. /**
  22204. * Updates the vertex buffer by applying transformation from the bones
  22205. * @param skeleton defines the skeleton to apply to current mesh
  22206. * @returns the current mesh
  22207. */
  22208. applySkeleton(skeleton: Skeleton): Mesh;
  22209. /**
  22210. * 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
  22211. * @param meshes defines the list of meshes to scan
  22212. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  22213. */
  22214. static MinMax(meshes: AbstractMesh[]): {
  22215. min: Vector3;
  22216. max: Vector3;
  22217. };
  22218. /**
  22219. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  22220. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  22221. * @returns a vector3
  22222. */
  22223. static Center(meshesOrMinMaxVector: {
  22224. min: Vector3;
  22225. max: Vector3;
  22226. } | AbstractMesh[]): Vector3;
  22227. /**
  22228. * Merge the array of meshes into a single mesh for performance reasons.
  22229. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  22230. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  22231. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  22232. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  22233. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  22234. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  22235. * @returns a new mesh
  22236. */
  22237. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  22238. /** @hidden */
  22239. addInstance(instance: InstancedMesh): void;
  22240. /** @hidden */
  22241. removeInstance(instance: InstancedMesh): void;
  22242. }
  22243. }
  22244. declare module "babylonjs/Materials/material" {
  22245. import { IAnimatable } from "babylonjs/Misc/tools";
  22246. import { SmartArray } from "babylonjs/Misc/smartArray";
  22247. import { Observable } from "babylonjs/Misc/observable";
  22248. import { Nullable } from "babylonjs/types";
  22249. import { Scene } from "babylonjs/scene";
  22250. import { Matrix } from "babylonjs/Maths/math";
  22251. import { BaseSubMesh, SubMesh } from "babylonjs/Meshes/subMesh";
  22252. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22253. import { Mesh } from "babylonjs/Meshes/mesh";
  22254. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  22255. import { Effect } from "babylonjs/Materials/effect";
  22256. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22257. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  22258. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22259. import { IInspectable } from "babylonjs/Misc/iInspectable";
  22260. import { Animation } from "babylonjs/Animations/animation";
  22261. /**
  22262. * Base class for the main features of a material in Babylon.js
  22263. */
  22264. export class Material implements IAnimatable {
  22265. /**
  22266. * Returns the triangle fill mode
  22267. */
  22268. static readonly TriangleFillMode: number;
  22269. /**
  22270. * Returns the wireframe mode
  22271. */
  22272. static readonly WireFrameFillMode: number;
  22273. /**
  22274. * Returns the point fill mode
  22275. */
  22276. static readonly PointFillMode: number;
  22277. /**
  22278. * Returns the point list draw mode
  22279. */
  22280. static readonly PointListDrawMode: number;
  22281. /**
  22282. * Returns the line list draw mode
  22283. */
  22284. static readonly LineListDrawMode: number;
  22285. /**
  22286. * Returns the line loop draw mode
  22287. */
  22288. static readonly LineLoopDrawMode: number;
  22289. /**
  22290. * Returns the line strip draw mode
  22291. */
  22292. static readonly LineStripDrawMode: number;
  22293. /**
  22294. * Returns the triangle strip draw mode
  22295. */
  22296. static readonly TriangleStripDrawMode: number;
  22297. /**
  22298. * Returns the triangle fan draw mode
  22299. */
  22300. static readonly TriangleFanDrawMode: number;
  22301. /**
  22302. * Stores the clock-wise side orientation
  22303. */
  22304. static readonly ClockWiseSideOrientation: number;
  22305. /**
  22306. * Stores the counter clock-wise side orientation
  22307. */
  22308. static readonly CounterClockWiseSideOrientation: number;
  22309. /**
  22310. * The dirty texture flag value
  22311. */
  22312. static readonly TextureDirtyFlag: number;
  22313. /**
  22314. * The dirty light flag value
  22315. */
  22316. static readonly LightDirtyFlag: number;
  22317. /**
  22318. * The dirty fresnel flag value
  22319. */
  22320. static readonly FresnelDirtyFlag: number;
  22321. /**
  22322. * The dirty attribute flag value
  22323. */
  22324. static readonly AttributesDirtyFlag: number;
  22325. /**
  22326. * The dirty misc flag value
  22327. */
  22328. static readonly MiscDirtyFlag: number;
  22329. /**
  22330. * The all dirty flag value
  22331. */
  22332. static readonly AllDirtyFlag: number;
  22333. /**
  22334. * The ID of the material
  22335. */
  22336. id: string;
  22337. /**
  22338. * Gets or sets the unique id of the material
  22339. */
  22340. uniqueId: number;
  22341. /**
  22342. * The name of the material
  22343. */
  22344. name: string;
  22345. /**
  22346. * Gets or sets user defined metadata
  22347. */
  22348. metadata: any;
  22349. /**
  22350. * For internal use only. Please do not use.
  22351. */
  22352. reservedDataStore: any;
  22353. /**
  22354. * Specifies if the ready state should be checked on each call
  22355. */
  22356. checkReadyOnEveryCall: boolean;
  22357. /**
  22358. * Specifies if the ready state should be checked once
  22359. */
  22360. checkReadyOnlyOnce: boolean;
  22361. /**
  22362. * The state of the material
  22363. */
  22364. state: string;
  22365. /**
  22366. * The alpha value of the material
  22367. */
  22368. protected _alpha: number;
  22369. /**
  22370. * List of inspectable custom properties (used by the Inspector)
  22371. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  22372. */
  22373. inspectableCustomProperties: IInspectable[];
  22374. /**
  22375. * Sets the alpha value of the material
  22376. */
  22377. /**
  22378. * Gets the alpha value of the material
  22379. */
  22380. alpha: number;
  22381. /**
  22382. * Specifies if back face culling is enabled
  22383. */
  22384. protected _backFaceCulling: boolean;
  22385. /**
  22386. * Sets the back-face culling state
  22387. */
  22388. /**
  22389. * Gets the back-face culling state
  22390. */
  22391. backFaceCulling: boolean;
  22392. /**
  22393. * Stores the value for side orientation
  22394. */
  22395. sideOrientation: number;
  22396. /**
  22397. * Callback triggered when the material is compiled
  22398. */
  22399. onCompiled: Nullable<(effect: Effect) => void>;
  22400. /**
  22401. * Callback triggered when an error occurs
  22402. */
  22403. onError: Nullable<(effect: Effect, errors: string) => void>;
  22404. /**
  22405. * Callback triggered to get the render target textures
  22406. */
  22407. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  22408. /**
  22409. * Gets a boolean indicating that current material needs to register RTT
  22410. */
  22411. readonly hasRenderTargetTextures: boolean;
  22412. /**
  22413. * Specifies if the material should be serialized
  22414. */
  22415. doNotSerialize: boolean;
  22416. /**
  22417. * @hidden
  22418. */
  22419. _storeEffectOnSubMeshes: boolean;
  22420. /**
  22421. * Stores the animations for the material
  22422. */
  22423. animations: Nullable<Array<Animation>>;
  22424. /**
  22425. * An event triggered when the material is disposed
  22426. */
  22427. onDisposeObservable: Observable<Material>;
  22428. /**
  22429. * An observer which watches for dispose events
  22430. */
  22431. private _onDisposeObserver;
  22432. private _onUnBindObservable;
  22433. /**
  22434. * Called during a dispose event
  22435. */
  22436. onDispose: () => void;
  22437. private _onBindObservable;
  22438. /**
  22439. * An event triggered when the material is bound
  22440. */
  22441. readonly onBindObservable: Observable<AbstractMesh>;
  22442. /**
  22443. * An observer which watches for bind events
  22444. */
  22445. private _onBindObserver;
  22446. /**
  22447. * Called during a bind event
  22448. */
  22449. onBind: (Mesh: AbstractMesh) => void;
  22450. /**
  22451. * An event triggered when the material is unbound
  22452. */
  22453. readonly onUnBindObservable: Observable<Material>;
  22454. /**
  22455. * Stores the value of the alpha mode
  22456. */
  22457. private _alphaMode;
  22458. /**
  22459. * Sets the value of the alpha mode.
  22460. *
  22461. * | Value | Type | Description |
  22462. * | --- | --- | --- |
  22463. * | 0 | ALPHA_DISABLE | |
  22464. * | 1 | ALPHA_ADD | |
  22465. * | 2 | ALPHA_COMBINE | |
  22466. * | 3 | ALPHA_SUBTRACT | |
  22467. * | 4 | ALPHA_MULTIPLY | |
  22468. * | 5 | ALPHA_MAXIMIZED | |
  22469. * | 6 | ALPHA_ONEONE | |
  22470. * | 7 | ALPHA_PREMULTIPLIED | |
  22471. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  22472. * | 9 | ALPHA_INTERPOLATE | |
  22473. * | 10 | ALPHA_SCREENMODE | |
  22474. *
  22475. */
  22476. /**
  22477. * Gets the value of the alpha mode
  22478. */
  22479. alphaMode: number;
  22480. /**
  22481. * Stores the state of the need depth pre-pass value
  22482. */
  22483. private _needDepthPrePass;
  22484. /**
  22485. * Sets the need depth pre-pass value
  22486. */
  22487. /**
  22488. * Gets the depth pre-pass value
  22489. */
  22490. needDepthPrePass: boolean;
  22491. /**
  22492. * Specifies if depth writing should be disabled
  22493. */
  22494. disableDepthWrite: boolean;
  22495. /**
  22496. * Specifies if depth writing should be forced
  22497. */
  22498. forceDepthWrite: boolean;
  22499. /**
  22500. * Specifies if there should be a separate pass for culling
  22501. */
  22502. separateCullingPass: boolean;
  22503. /**
  22504. * Stores the state specifing if fog should be enabled
  22505. */
  22506. private _fogEnabled;
  22507. /**
  22508. * Sets the state for enabling fog
  22509. */
  22510. /**
  22511. * Gets the value of the fog enabled state
  22512. */
  22513. fogEnabled: boolean;
  22514. /**
  22515. * Stores the size of points
  22516. */
  22517. pointSize: number;
  22518. /**
  22519. * Stores the z offset value
  22520. */
  22521. zOffset: number;
  22522. /**
  22523. * Gets a value specifying if wireframe mode is enabled
  22524. */
  22525. /**
  22526. * Sets the state of wireframe mode
  22527. */
  22528. wireframe: boolean;
  22529. /**
  22530. * Gets the value specifying if point clouds are enabled
  22531. */
  22532. /**
  22533. * Sets the state of point cloud mode
  22534. */
  22535. pointsCloud: boolean;
  22536. /**
  22537. * Gets the material fill mode
  22538. */
  22539. /**
  22540. * Sets the material fill mode
  22541. */
  22542. fillMode: number;
  22543. /**
  22544. * @hidden
  22545. * Stores the effects for the material
  22546. */
  22547. _effect: Nullable<Effect>;
  22548. /**
  22549. * @hidden
  22550. * Specifies if the material was previously ready
  22551. */
  22552. _wasPreviouslyReady: boolean;
  22553. /**
  22554. * Specifies if uniform buffers should be used
  22555. */
  22556. private _useUBO;
  22557. /**
  22558. * Stores a reference to the scene
  22559. */
  22560. private _scene;
  22561. /**
  22562. * Stores the fill mode state
  22563. */
  22564. private _fillMode;
  22565. /**
  22566. * Specifies if the depth write state should be cached
  22567. */
  22568. private _cachedDepthWriteState;
  22569. /**
  22570. * Stores the uniform buffer
  22571. */
  22572. protected _uniformBuffer: UniformBuffer;
  22573. /** @hidden */
  22574. _indexInSceneMaterialArray: number;
  22575. /** @hidden */
  22576. meshMap: Nullable<{
  22577. [id: string]: AbstractMesh | undefined;
  22578. }>;
  22579. /**
  22580. * Creates a material instance
  22581. * @param name defines the name of the material
  22582. * @param scene defines the scene to reference
  22583. * @param doNotAdd specifies if the material should be added to the scene
  22584. */
  22585. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  22586. /**
  22587. * Returns a string representation of the current material
  22588. * @param fullDetails defines a boolean indicating which levels of logging is desired
  22589. * @returns a string with material information
  22590. */
  22591. toString(fullDetails?: boolean): string;
  22592. /**
  22593. * Gets the class name of the material
  22594. * @returns a string with the class name of the material
  22595. */
  22596. getClassName(): string;
  22597. /**
  22598. * Specifies if updates for the material been locked
  22599. */
  22600. readonly isFrozen: boolean;
  22601. /**
  22602. * Locks updates for the material
  22603. */
  22604. freeze(): void;
  22605. /**
  22606. * Unlocks updates for the material
  22607. */
  22608. unfreeze(): void;
  22609. /**
  22610. * Specifies if the material is ready to be used
  22611. * @param mesh defines the mesh to check
  22612. * @param useInstances specifies if instances should be used
  22613. * @returns a boolean indicating if the material is ready to be used
  22614. */
  22615. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22616. /**
  22617. * Specifies that the submesh is ready to be used
  22618. * @param mesh defines the mesh to check
  22619. * @param subMesh defines which submesh to check
  22620. * @param useInstances specifies that instances should be used
  22621. * @returns a boolean indicating that the submesh is ready or not
  22622. */
  22623. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  22624. /**
  22625. * Returns the material effect
  22626. * @returns the effect associated with the material
  22627. */
  22628. getEffect(): Nullable<Effect>;
  22629. /**
  22630. * Returns the current scene
  22631. * @returns a Scene
  22632. */
  22633. getScene(): Scene;
  22634. /**
  22635. * Specifies if the material will require alpha blending
  22636. * @returns a boolean specifying if alpha blending is needed
  22637. */
  22638. needAlphaBlending(): boolean;
  22639. /**
  22640. * Specifies if the mesh will require alpha blending
  22641. * @param mesh defines the mesh to check
  22642. * @returns a boolean specifying if alpha blending is needed for the mesh
  22643. */
  22644. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  22645. /**
  22646. * Specifies if this material should be rendered in alpha test mode
  22647. * @returns a boolean specifying if an alpha test is needed.
  22648. */
  22649. needAlphaTesting(): boolean;
  22650. /**
  22651. * Gets the texture used for the alpha test
  22652. * @returns the texture to use for alpha testing
  22653. */
  22654. getAlphaTestTexture(): Nullable<BaseTexture>;
  22655. /**
  22656. * Marks the material to indicate that it needs to be re-calculated
  22657. */
  22658. markDirty(): void;
  22659. /** @hidden */
  22660. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  22661. /**
  22662. * Binds the material to the mesh
  22663. * @param world defines the world transformation matrix
  22664. * @param mesh defines the mesh to bind the material to
  22665. */
  22666. bind(world: Matrix, mesh?: Mesh): void;
  22667. /**
  22668. * Binds the submesh to the material
  22669. * @param world defines the world transformation matrix
  22670. * @param mesh defines the mesh containing the submesh
  22671. * @param subMesh defines the submesh to bind the material to
  22672. */
  22673. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  22674. /**
  22675. * Binds the world matrix to the material
  22676. * @param world defines the world transformation matrix
  22677. */
  22678. bindOnlyWorldMatrix(world: Matrix): void;
  22679. /**
  22680. * Binds the scene's uniform buffer to the effect.
  22681. * @param effect defines the effect to bind to the scene uniform buffer
  22682. * @param sceneUbo defines the uniform buffer storing scene data
  22683. */
  22684. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  22685. /**
  22686. * Binds the view matrix to the effect
  22687. * @param effect defines the effect to bind the view matrix to
  22688. */
  22689. bindView(effect: Effect): void;
  22690. /**
  22691. * Binds the view projection matrix to the effect
  22692. * @param effect defines the effect to bind the view projection matrix to
  22693. */
  22694. bindViewProjection(effect: Effect): void;
  22695. /**
  22696. * Specifies if material alpha testing should be turned on for the mesh
  22697. * @param mesh defines the mesh to check
  22698. */
  22699. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  22700. /**
  22701. * Processes to execute after binding the material to a mesh
  22702. * @param mesh defines the rendered mesh
  22703. */
  22704. protected _afterBind(mesh?: Mesh): void;
  22705. /**
  22706. * Unbinds the material from the mesh
  22707. */
  22708. unbind(): void;
  22709. /**
  22710. * Gets the active textures from the material
  22711. * @returns an array of textures
  22712. */
  22713. getActiveTextures(): BaseTexture[];
  22714. /**
  22715. * Specifies if the material uses a texture
  22716. * @param texture defines the texture to check against the material
  22717. * @returns a boolean specifying if the material uses the texture
  22718. */
  22719. hasTexture(texture: BaseTexture): boolean;
  22720. /**
  22721. * Makes a duplicate of the material, and gives it a new name
  22722. * @param name defines the new name for the duplicated material
  22723. * @returns the cloned material
  22724. */
  22725. clone(name: string): Nullable<Material>;
  22726. /**
  22727. * Gets the meshes bound to the material
  22728. * @returns an array of meshes bound to the material
  22729. */
  22730. getBindedMeshes(): AbstractMesh[];
  22731. /**
  22732. * Force shader compilation
  22733. * @param mesh defines the mesh associated with this material
  22734. * @param onCompiled defines a function to execute once the material is compiled
  22735. * @param options defines the options to configure the compilation
  22736. */
  22737. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  22738. clipPlane: boolean;
  22739. }>): void;
  22740. /**
  22741. * Force shader compilation
  22742. * @param mesh defines the mesh that will use this material
  22743. * @param options defines additional options for compiling the shaders
  22744. * @returns a promise that resolves when the compilation completes
  22745. */
  22746. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  22747. clipPlane: boolean;
  22748. }>): Promise<void>;
  22749. private static readonly _ImageProcessingDirtyCallBack;
  22750. private static readonly _TextureDirtyCallBack;
  22751. private static readonly _FresnelDirtyCallBack;
  22752. private static readonly _MiscDirtyCallBack;
  22753. private static readonly _LightsDirtyCallBack;
  22754. private static readonly _AttributeDirtyCallBack;
  22755. private static _FresnelAndMiscDirtyCallBack;
  22756. private static _TextureAndMiscDirtyCallBack;
  22757. private static readonly _DirtyCallbackArray;
  22758. private static readonly _RunDirtyCallBacks;
  22759. /**
  22760. * Marks a define in the material to indicate that it needs to be re-computed
  22761. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  22762. */
  22763. markAsDirty(flag: number): void;
  22764. /**
  22765. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  22766. * @param func defines a function which checks material defines against the submeshes
  22767. */
  22768. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  22769. /**
  22770. * Indicates that image processing needs to be re-calculated for all submeshes
  22771. */
  22772. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  22773. /**
  22774. * Indicates that textures need to be re-calculated for all submeshes
  22775. */
  22776. protected _markAllSubMeshesAsTexturesDirty(): void;
  22777. /**
  22778. * Indicates that fresnel needs to be re-calculated for all submeshes
  22779. */
  22780. protected _markAllSubMeshesAsFresnelDirty(): void;
  22781. /**
  22782. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  22783. */
  22784. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  22785. /**
  22786. * Indicates that lights need to be re-calculated for all submeshes
  22787. */
  22788. protected _markAllSubMeshesAsLightsDirty(): void;
  22789. /**
  22790. * Indicates that attributes need to be re-calculated for all submeshes
  22791. */
  22792. protected _markAllSubMeshesAsAttributesDirty(): void;
  22793. /**
  22794. * Indicates that misc needs to be re-calculated for all submeshes
  22795. */
  22796. protected _markAllSubMeshesAsMiscDirty(): void;
  22797. /**
  22798. * Indicates that textures and misc need to be re-calculated for all submeshes
  22799. */
  22800. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  22801. /**
  22802. * Disposes the material
  22803. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  22804. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  22805. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  22806. */
  22807. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  22808. /** @hidden */
  22809. private releaseVertexArrayObject;
  22810. /**
  22811. * Serializes this material
  22812. * @returns the serialized material object
  22813. */
  22814. serialize(): any;
  22815. /**
  22816. * Creates a material from parsed material data
  22817. * @param parsedMaterial defines parsed material data
  22818. * @param scene defines the hosting scene
  22819. * @param rootUrl defines the root URL to use to load textures
  22820. * @returns a new material
  22821. */
  22822. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  22823. }
  22824. }
  22825. declare module "babylonjs/Meshes/subMesh" {
  22826. import { Nullable, IndicesArray, DeepImmutable } from "babylonjs/types";
  22827. import { Matrix, Vector3, Plane } from "babylonjs/Maths/math";
  22828. import { Engine } from "babylonjs/Engines/engine";
  22829. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  22830. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  22831. import { Effect } from "babylonjs/Materials/effect";
  22832. import { Collider } from "babylonjs/Collisions/collider";
  22833. import { Material } from "babylonjs/Materials/material";
  22834. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  22835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22836. import { Mesh } from "babylonjs/Meshes/mesh";
  22837. import { Ray } from "babylonjs/Culling/ray";
  22838. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  22839. /**
  22840. * Base class for submeshes
  22841. */
  22842. export class BaseSubMesh {
  22843. /** @hidden */
  22844. _materialDefines: Nullable<MaterialDefines>;
  22845. /** @hidden */
  22846. _materialEffect: Nullable<Effect>;
  22847. /**
  22848. * Gets associated effect
  22849. */
  22850. readonly effect: Nullable<Effect>;
  22851. /**
  22852. * Sets associated effect (effect used to render this submesh)
  22853. * @param effect defines the effect to associate with
  22854. * @param defines defines the set of defines used to compile this effect
  22855. */
  22856. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  22857. }
  22858. /**
  22859. * Defines a subdivision inside a mesh
  22860. */
  22861. export class SubMesh extends BaseSubMesh implements ICullable {
  22862. /** the material index to use */
  22863. materialIndex: number;
  22864. /** vertex index start */
  22865. verticesStart: number;
  22866. /** vertices count */
  22867. verticesCount: number;
  22868. /** index start */
  22869. indexStart: number;
  22870. /** indices count */
  22871. indexCount: number;
  22872. /** @hidden */
  22873. _linesIndexCount: number;
  22874. private _mesh;
  22875. private _renderingMesh;
  22876. private _boundingInfo;
  22877. private _linesIndexBuffer;
  22878. /** @hidden */
  22879. _lastColliderWorldVertices: Nullable<Vector3[]>;
  22880. /** @hidden */
  22881. _trianglePlanes: Plane[];
  22882. /** @hidden */
  22883. _lastColliderTransformMatrix: Nullable<Matrix>;
  22884. /** @hidden */
  22885. _renderId: number;
  22886. /** @hidden */
  22887. _alphaIndex: number;
  22888. /** @hidden */
  22889. _distanceToCamera: number;
  22890. /** @hidden */
  22891. _id: number;
  22892. private _currentMaterial;
  22893. /**
  22894. * Add a new submesh to a mesh
  22895. * @param materialIndex defines the material index to use
  22896. * @param verticesStart defines vertex index start
  22897. * @param verticesCount defines vertices count
  22898. * @param indexStart defines index start
  22899. * @param indexCount defines indices count
  22900. * @param mesh defines the parent mesh
  22901. * @param renderingMesh defines an optional rendering mesh
  22902. * @param createBoundingBox defines if bounding box should be created for this submesh
  22903. * @returns the new submesh
  22904. */
  22905. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  22906. /**
  22907. * Creates a new submesh
  22908. * @param materialIndex defines the material index to use
  22909. * @param verticesStart defines vertex index start
  22910. * @param verticesCount defines vertices count
  22911. * @param indexStart defines index start
  22912. * @param indexCount defines indices count
  22913. * @param mesh defines the parent mesh
  22914. * @param renderingMesh defines an optional rendering mesh
  22915. * @param createBoundingBox defines if bounding box should be created for this submesh
  22916. */
  22917. constructor(
  22918. /** the material index to use */
  22919. materialIndex: number,
  22920. /** vertex index start */
  22921. verticesStart: number,
  22922. /** vertices count */
  22923. verticesCount: number,
  22924. /** index start */
  22925. indexStart: number,
  22926. /** indices count */
  22927. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  22928. /**
  22929. * Returns true if this submesh covers the entire parent mesh
  22930. * @ignorenaming
  22931. */
  22932. readonly IsGlobal: boolean;
  22933. /**
  22934. * Returns the submesh BoudingInfo object
  22935. * @returns current bounding info (or mesh's one if the submesh is global)
  22936. */
  22937. getBoundingInfo(): BoundingInfo;
  22938. /**
  22939. * Sets the submesh BoundingInfo
  22940. * @param boundingInfo defines the new bounding info to use
  22941. * @returns the SubMesh
  22942. */
  22943. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  22944. /**
  22945. * Returns the mesh of the current submesh
  22946. * @return the parent mesh
  22947. */
  22948. getMesh(): AbstractMesh;
  22949. /**
  22950. * Returns the rendering mesh of the submesh
  22951. * @returns the rendering mesh (could be different from parent mesh)
  22952. */
  22953. getRenderingMesh(): Mesh;
  22954. /**
  22955. * Returns the submesh material
  22956. * @returns null or the current material
  22957. */
  22958. getMaterial(): Nullable<Material>;
  22959. /**
  22960. * Sets a new updated BoundingInfo object to the submesh
  22961. * @returns the SubMesh
  22962. */
  22963. refreshBoundingInfo(): SubMesh;
  22964. /** @hidden */
  22965. _checkCollision(collider: Collider): boolean;
  22966. /**
  22967. * Updates the submesh BoundingInfo
  22968. * @param world defines the world matrix to use to update the bounding info
  22969. * @returns the submesh
  22970. */
  22971. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  22972. /**
  22973. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  22974. * @param frustumPlanes defines the frustum planes
  22975. * @returns true if the submesh is intersecting with the frustum
  22976. */
  22977. isInFrustum(frustumPlanes: Plane[]): boolean;
  22978. /**
  22979. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  22980. * @param frustumPlanes defines the frustum planes
  22981. * @returns true if the submesh is inside the frustum
  22982. */
  22983. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  22984. /**
  22985. * Renders the submesh
  22986. * @param enableAlphaMode defines if alpha needs to be used
  22987. * @returns the submesh
  22988. */
  22989. render(enableAlphaMode: boolean): SubMesh;
  22990. /**
  22991. * @hidden
  22992. */
  22993. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  22994. /**
  22995. * Checks if the submesh intersects with a ray
  22996. * @param ray defines the ray to test
  22997. * @returns true is the passed ray intersects the submesh bounding box
  22998. */
  22999. canIntersects(ray: Ray): boolean;
  23000. /**
  23001. * Intersects current submesh with a ray
  23002. * @param ray defines the ray to test
  23003. * @param positions defines mesh's positions array
  23004. * @param indices defines mesh's indices array
  23005. * @param fastCheck defines if only bounding info should be used
  23006. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  23007. * @returns intersection info or null if no intersection
  23008. */
  23009. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  23010. /** @hidden */
  23011. private _intersectLines;
  23012. /** @hidden */
  23013. private _intersectTriangles;
  23014. /** @hidden */
  23015. _rebuild(): void;
  23016. /**
  23017. * Creates a new submesh from the passed mesh
  23018. * @param newMesh defines the new hosting mesh
  23019. * @param newRenderingMesh defines an optional rendering mesh
  23020. * @returns the new submesh
  23021. */
  23022. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  23023. /**
  23024. * Release associated resources
  23025. */
  23026. dispose(): void;
  23027. /**
  23028. * Gets the class name
  23029. * @returns the string "SubMesh".
  23030. */
  23031. getClassName(): string;
  23032. /**
  23033. * Creates a new submesh from indices data
  23034. * @param materialIndex the index of the main mesh material
  23035. * @param startIndex the index where to start the copy in the mesh indices array
  23036. * @param indexCount the number of indices to copy then from the startIndex
  23037. * @param mesh the main mesh to create the submesh from
  23038. * @param renderingMesh the optional rendering mesh
  23039. * @returns a new submesh
  23040. */
  23041. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  23042. }
  23043. }
  23044. declare module "babylonjs/Meshes/geometry" {
  23045. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  23046. import { Scene } from "babylonjs/scene";
  23047. import { Vector3, Vector2 } from "babylonjs/Maths/math";
  23048. import { Engine } from "babylonjs/Engines/engine";
  23049. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  23050. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  23051. import { Effect } from "babylonjs/Materials/effect";
  23052. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  23053. import { Mesh } from "babylonjs/Meshes/mesh";
  23054. /**
  23055. * Class used to store geometry data (vertex buffers + index buffer)
  23056. */
  23057. export class Geometry implements IGetSetVerticesData {
  23058. /**
  23059. * Gets or sets the ID of the geometry
  23060. */
  23061. id: string;
  23062. /**
  23063. * Gets or sets the unique ID of the geometry
  23064. */
  23065. uniqueId: number;
  23066. /**
  23067. * Gets the delay loading state of the geometry (none by default which means not delayed)
  23068. */
  23069. delayLoadState: number;
  23070. /**
  23071. * Gets the file containing the data to load when running in delay load state
  23072. */
  23073. delayLoadingFile: Nullable<string>;
  23074. /**
  23075. * Callback called when the geometry is updated
  23076. */
  23077. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  23078. private _scene;
  23079. private _engine;
  23080. private _meshes;
  23081. private _totalVertices;
  23082. /** @hidden */
  23083. _indices: IndicesArray;
  23084. /** @hidden */
  23085. _vertexBuffers: {
  23086. [key: string]: VertexBuffer;
  23087. };
  23088. private _isDisposed;
  23089. private _extend;
  23090. private _boundingBias;
  23091. /** @hidden */
  23092. _delayInfo: Array<string>;
  23093. private _indexBuffer;
  23094. private _indexBufferIsUpdatable;
  23095. /** @hidden */
  23096. _boundingInfo: Nullable<BoundingInfo>;
  23097. /** @hidden */
  23098. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  23099. /** @hidden */
  23100. _softwareSkinningFrameId: number;
  23101. private _vertexArrayObjects;
  23102. private _updatable;
  23103. /** @hidden */
  23104. _positions: Nullable<Vector3[]>;
  23105. /**
  23106. * 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
  23107. */
  23108. /**
  23109. * 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
  23110. */
  23111. boundingBias: Vector2;
  23112. /**
  23113. * Static function used to attach a new empty geometry to a mesh
  23114. * @param mesh defines the mesh to attach the geometry to
  23115. * @returns the new Geometry
  23116. */
  23117. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  23118. /**
  23119. * Creates a new geometry
  23120. * @param id defines the unique ID
  23121. * @param scene defines the hosting scene
  23122. * @param vertexData defines the VertexData used to get geometry data
  23123. * @param updatable defines if geometry must be updatable (false by default)
  23124. * @param mesh defines the mesh that will be associated with the geometry
  23125. */
  23126. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  23127. /**
  23128. * Gets the current extend of the geometry
  23129. */
  23130. readonly extend: {
  23131. minimum: Vector3;
  23132. maximum: Vector3;
  23133. };
  23134. /**
  23135. * Gets the hosting scene
  23136. * @returns the hosting Scene
  23137. */
  23138. getScene(): Scene;
  23139. /**
  23140. * Gets the hosting engine
  23141. * @returns the hosting Engine
  23142. */
  23143. getEngine(): Engine;
  23144. /**
  23145. * Defines if the geometry is ready to use
  23146. * @returns true if the geometry is ready to be used
  23147. */
  23148. isReady(): boolean;
  23149. /**
  23150. * Gets a value indicating that the geometry should not be serialized
  23151. */
  23152. readonly doNotSerialize: boolean;
  23153. /** @hidden */
  23154. _rebuild(): void;
  23155. /**
  23156. * Affects all geometry data in one call
  23157. * @param vertexData defines the geometry data
  23158. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  23159. */
  23160. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  23161. /**
  23162. * Set specific vertex data
  23163. * @param kind defines the data kind (Position, normal, etc...)
  23164. * @param data defines the vertex data to use
  23165. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23166. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23167. */
  23168. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  23169. /**
  23170. * Removes a specific vertex data
  23171. * @param kind defines the data kind (Position, normal, etc...)
  23172. */
  23173. removeVerticesData(kind: string): void;
  23174. /**
  23175. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  23176. * @param buffer defines the vertex buffer to use
  23177. * @param totalVertices defines the total number of vertices for position kind (could be null)
  23178. */
  23179. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  23180. /**
  23181. * Update a specific vertex buffer
  23182. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  23183. * It will do nothing if the buffer is not updatable
  23184. * @param kind defines the data kind (Position, normal, etc...)
  23185. * @param data defines the data to use
  23186. * @param offset defines the offset in the target buffer where to store the data
  23187. * @param useBytes set to true if the offset is in bytes
  23188. */
  23189. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  23190. /**
  23191. * Update a specific vertex buffer
  23192. * This function will create a new buffer if the current one is not updatable
  23193. * @param kind defines the data kind (Position, normal, etc...)
  23194. * @param data defines the data to use
  23195. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  23196. */
  23197. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  23198. private _updateBoundingInfo;
  23199. /** @hidden */
  23200. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  23201. /**
  23202. * Gets total number of vertices
  23203. * @returns the total number of vertices
  23204. */
  23205. getTotalVertices(): number;
  23206. /**
  23207. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23208. * @param kind defines the data kind (Position, normal, etc...)
  23209. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23210. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23211. * @returns a float array containing vertex data
  23212. */
  23213. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23214. /**
  23215. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  23216. * @param kind defines the data kind (Position, normal, etc...)
  23217. * @returns true if the vertex buffer with the specified kind is updatable
  23218. */
  23219. isVertexBufferUpdatable(kind: string): boolean;
  23220. /**
  23221. * Gets a specific vertex buffer
  23222. * @param kind defines the data kind (Position, normal, etc...)
  23223. * @returns a VertexBuffer
  23224. */
  23225. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  23226. /**
  23227. * Returns all vertex buffers
  23228. * @return an object holding all vertex buffers indexed by kind
  23229. */
  23230. getVertexBuffers(): Nullable<{
  23231. [key: string]: VertexBuffer;
  23232. }>;
  23233. /**
  23234. * Gets a boolean indicating if specific vertex buffer is present
  23235. * @param kind defines the data kind (Position, normal, etc...)
  23236. * @returns true if data is present
  23237. */
  23238. isVerticesDataPresent(kind: string): boolean;
  23239. /**
  23240. * Gets a list of all attached data kinds (Position, normal, etc...)
  23241. * @returns a list of string containing all kinds
  23242. */
  23243. getVerticesDataKinds(): string[];
  23244. /**
  23245. * Update index buffer
  23246. * @param indices defines the indices to store in the index buffer
  23247. * @param offset defines the offset in the target buffer where to store the data
  23248. * @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)
  23249. */
  23250. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  23251. /**
  23252. * Creates a new index buffer
  23253. * @param indices defines the indices to store in the index buffer
  23254. * @param totalVertices defines the total number of vertices (could be null)
  23255. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23256. */
  23257. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  23258. /**
  23259. * Return the total number of indices
  23260. * @returns the total number of indices
  23261. */
  23262. getTotalIndices(): number;
  23263. /**
  23264. * Gets the index buffer array
  23265. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23266. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23267. * @returns the index buffer array
  23268. */
  23269. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23270. /**
  23271. * Gets the index buffer
  23272. * @return the index buffer
  23273. */
  23274. getIndexBuffer(): Nullable<WebGLBuffer>;
  23275. /** @hidden */
  23276. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  23277. /**
  23278. * Release the associated resources for a specific mesh
  23279. * @param mesh defines the source mesh
  23280. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  23281. */
  23282. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  23283. /**
  23284. * Apply current geometry to a given mesh
  23285. * @param mesh defines the mesh to apply geometry to
  23286. */
  23287. applyToMesh(mesh: Mesh): void;
  23288. private _updateExtend;
  23289. private _applyToMesh;
  23290. private notifyUpdate;
  23291. /**
  23292. * Load the geometry if it was flagged as delay loaded
  23293. * @param scene defines the hosting scene
  23294. * @param onLoaded defines a callback called when the geometry is loaded
  23295. */
  23296. load(scene: Scene, onLoaded?: () => void): void;
  23297. private _queueLoad;
  23298. /**
  23299. * Invert the geometry to move from a right handed system to a left handed one.
  23300. */
  23301. toLeftHanded(): void;
  23302. /** @hidden */
  23303. _resetPointsArrayCache(): void;
  23304. /** @hidden */
  23305. _generatePointsArray(): boolean;
  23306. /**
  23307. * Gets a value indicating if the geometry is disposed
  23308. * @returns true if the geometry was disposed
  23309. */
  23310. isDisposed(): boolean;
  23311. private _disposeVertexArrayObjects;
  23312. /**
  23313. * Free all associated resources
  23314. */
  23315. dispose(): void;
  23316. /**
  23317. * Clone the current geometry into a new geometry
  23318. * @param id defines the unique ID of the new geometry
  23319. * @returns a new geometry object
  23320. */
  23321. copy(id: string): Geometry;
  23322. /**
  23323. * Serialize the current geometry info (and not the vertices data) into a JSON object
  23324. * @return a JSON representation of the current geometry data (without the vertices data)
  23325. */
  23326. serialize(): any;
  23327. private toNumberArray;
  23328. /**
  23329. * Serialize all vertices data into a JSON oject
  23330. * @returns a JSON representation of the current geometry data
  23331. */
  23332. serializeVerticeData(): any;
  23333. /**
  23334. * Extracts a clone of a mesh geometry
  23335. * @param mesh defines the source mesh
  23336. * @param id defines the unique ID of the new geometry object
  23337. * @returns the new geometry object
  23338. */
  23339. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  23340. /**
  23341. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  23342. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  23343. * Be aware Math.random() could cause collisions, but:
  23344. * "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"
  23345. * @returns a string containing a new GUID
  23346. */
  23347. static RandomId(): string;
  23348. /** @hidden */
  23349. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  23350. private static _CleanMatricesWeights;
  23351. /**
  23352. * Create a new geometry from persisted data (Using .babylon file format)
  23353. * @param parsedVertexData defines the persisted data
  23354. * @param scene defines the hosting scene
  23355. * @param rootUrl defines the root url to use to load assets (like delayed data)
  23356. * @returns the new geometry object
  23357. */
  23358. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  23359. }
  23360. }
  23361. declare module "babylonjs/Meshes/mesh.vertexData" {
  23362. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  23363. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  23364. import { Geometry } from "babylonjs/Meshes/geometry";
  23365. import { Mesh } from "babylonjs/Meshes/mesh";
  23366. /**
  23367. * Define an interface for all classes that will get and set the data on vertices
  23368. */
  23369. export interface IGetSetVerticesData {
  23370. /**
  23371. * Gets a boolean indicating if specific vertex data is present
  23372. * @param kind defines the vertex data kind to use
  23373. * @returns true is data kind is present
  23374. */
  23375. isVerticesDataPresent(kind: string): boolean;
  23376. /**
  23377. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  23378. * @param kind defines the data kind (Position, normal, etc...)
  23379. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  23380. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23381. * @returns a float array containing vertex data
  23382. */
  23383. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  23384. /**
  23385. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  23386. * @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.
  23387. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  23388. * @returns the indices array or an empty array if the mesh has no geometry
  23389. */
  23390. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  23391. /**
  23392. * Set specific vertex data
  23393. * @param kind defines the data kind (Position, normal, etc...)
  23394. * @param data defines the vertex data to use
  23395. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  23396. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  23397. */
  23398. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  23399. /**
  23400. * Update a specific associated vertex buffer
  23401. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  23402. * - VertexBuffer.PositionKind
  23403. * - VertexBuffer.UVKind
  23404. * - VertexBuffer.UV2Kind
  23405. * - VertexBuffer.UV3Kind
  23406. * - VertexBuffer.UV4Kind
  23407. * - VertexBuffer.UV5Kind
  23408. * - VertexBuffer.UV6Kind
  23409. * - VertexBuffer.ColorKind
  23410. * - VertexBuffer.MatricesIndicesKind
  23411. * - VertexBuffer.MatricesIndicesExtraKind
  23412. * - VertexBuffer.MatricesWeightsKind
  23413. * - VertexBuffer.MatricesWeightsExtraKind
  23414. * @param data defines the data source
  23415. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  23416. * @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)
  23417. */
  23418. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  23419. /**
  23420. * Creates a new index buffer
  23421. * @param indices defines the indices to store in the index buffer
  23422. * @param totalVertices defines the total number of vertices (could be null)
  23423. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  23424. */
  23425. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  23426. }
  23427. /**
  23428. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  23429. */
  23430. export class VertexData {
  23431. /**
  23432. * Mesh side orientation : usually the external or front surface
  23433. */
  23434. static readonly FRONTSIDE: number;
  23435. /**
  23436. * Mesh side orientation : usually the internal or back surface
  23437. */
  23438. static readonly BACKSIDE: number;
  23439. /**
  23440. * Mesh side orientation : both internal and external or front and back surfaces
  23441. */
  23442. static readonly DOUBLESIDE: number;
  23443. /**
  23444. * Mesh side orientation : by default, `FRONTSIDE`
  23445. */
  23446. static readonly DEFAULTSIDE: number;
  23447. /**
  23448. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  23449. */
  23450. positions: Nullable<FloatArray>;
  23451. /**
  23452. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  23453. */
  23454. normals: Nullable<FloatArray>;
  23455. /**
  23456. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  23457. */
  23458. tangents: Nullable<FloatArray>;
  23459. /**
  23460. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23461. */
  23462. uvs: Nullable<FloatArray>;
  23463. /**
  23464. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23465. */
  23466. uvs2: Nullable<FloatArray>;
  23467. /**
  23468. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23469. */
  23470. uvs3: Nullable<FloatArray>;
  23471. /**
  23472. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23473. */
  23474. uvs4: Nullable<FloatArray>;
  23475. /**
  23476. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23477. */
  23478. uvs5: Nullable<FloatArray>;
  23479. /**
  23480. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  23481. */
  23482. uvs6: Nullable<FloatArray>;
  23483. /**
  23484. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  23485. */
  23486. colors: Nullable<FloatArray>;
  23487. /**
  23488. * 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).
  23489. */
  23490. matricesIndices: Nullable<FloatArray>;
  23491. /**
  23492. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  23493. */
  23494. matricesWeights: Nullable<FloatArray>;
  23495. /**
  23496. * An array extending the number of possible indices
  23497. */
  23498. matricesIndicesExtra: Nullable<FloatArray>;
  23499. /**
  23500. * An array extending the number of possible weights when the number of indices is extended
  23501. */
  23502. matricesWeightsExtra: Nullable<FloatArray>;
  23503. /**
  23504. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  23505. */
  23506. indices: Nullable<IndicesArray>;
  23507. /**
  23508. * Uses the passed data array to set the set the values for the specified kind of data
  23509. * @param data a linear array of floating numbers
  23510. * @param kind the type of data that is being set, eg positions, colors etc
  23511. */
  23512. set(data: FloatArray, kind: string): void;
  23513. /**
  23514. * Associates the vertexData to the passed Mesh.
  23515. * Sets it as updatable or not (default `false`)
  23516. * @param mesh the mesh the vertexData is applied to
  23517. * @param updatable when used and having the value true allows new data to update the vertexData
  23518. * @returns the VertexData
  23519. */
  23520. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  23521. /**
  23522. * Associates the vertexData to the passed Geometry.
  23523. * Sets it as updatable or not (default `false`)
  23524. * @param geometry the geometry the vertexData is applied to
  23525. * @param updatable when used and having the value true allows new data to update the vertexData
  23526. * @returns VertexData
  23527. */
  23528. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  23529. /**
  23530. * Updates the associated mesh
  23531. * @param mesh the mesh to be updated
  23532. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23533. * @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
  23534. * @returns VertexData
  23535. */
  23536. updateMesh(mesh: Mesh): VertexData;
  23537. /**
  23538. * Updates the associated geometry
  23539. * @param geometry the geometry to be updated
  23540. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  23541. * @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
  23542. * @returns VertexData.
  23543. */
  23544. updateGeometry(geometry: Geometry): VertexData;
  23545. private _applyTo;
  23546. private _update;
  23547. /**
  23548. * Transforms each position and each normal of the vertexData according to the passed Matrix
  23549. * @param matrix the transforming matrix
  23550. * @returns the VertexData
  23551. */
  23552. transform(matrix: Matrix): VertexData;
  23553. /**
  23554. * Merges the passed VertexData into the current one
  23555. * @param other the VertexData to be merged into the current one
  23556. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  23557. * @returns the modified VertexData
  23558. */
  23559. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  23560. private _mergeElement;
  23561. private _validate;
  23562. /**
  23563. * Serializes the VertexData
  23564. * @returns a serialized object
  23565. */
  23566. serialize(): any;
  23567. /**
  23568. * Extracts the vertexData from a mesh
  23569. * @param mesh the mesh from which to extract the VertexData
  23570. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  23571. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23572. * @returns the object VertexData associated to the passed mesh
  23573. */
  23574. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23575. /**
  23576. * Extracts the vertexData from the geometry
  23577. * @param geometry the geometry from which to extract the VertexData
  23578. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  23579. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  23580. * @returns the object VertexData associated to the passed mesh
  23581. */
  23582. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  23583. private static _ExtractFrom;
  23584. /**
  23585. * Creates the VertexData for a Ribbon
  23586. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  23587. * * pathArray array of paths, each of which an array of successive Vector3
  23588. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  23589. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  23590. * * 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
  23591. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23592. * * 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)
  23593. * * 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)
  23594. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  23595. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  23596. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  23597. * @returns the VertexData of the ribbon
  23598. */
  23599. static CreateRibbon(options: {
  23600. pathArray: Vector3[][];
  23601. closeArray?: boolean;
  23602. closePath?: boolean;
  23603. offset?: number;
  23604. sideOrientation?: number;
  23605. frontUVs?: Vector4;
  23606. backUVs?: Vector4;
  23607. invertUV?: boolean;
  23608. uvs?: Vector2[];
  23609. colors?: Color4[];
  23610. }): VertexData;
  23611. /**
  23612. * Creates the VertexData for a box
  23613. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23614. * * size sets the width, height and depth of the box to the value of size, optional default 1
  23615. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  23616. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  23617. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  23618. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  23619. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  23620. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23621. * * 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)
  23622. * * 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)
  23623. * @returns the VertexData of the box
  23624. */
  23625. static CreateBox(options: {
  23626. size?: number;
  23627. width?: number;
  23628. height?: number;
  23629. depth?: number;
  23630. faceUV?: Vector4[];
  23631. faceColors?: Color4[];
  23632. sideOrientation?: number;
  23633. frontUVs?: Vector4;
  23634. backUVs?: Vector4;
  23635. }): VertexData;
  23636. /**
  23637. * Creates the VertexData for an ellipsoid, defaults to a sphere
  23638. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23639. * * segments sets the number of horizontal strips optional, default 32
  23640. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  23641. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  23642. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  23643. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  23644. * * 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
  23645. * * 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
  23646. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23647. * * 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)
  23648. * * 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)
  23649. * @returns the VertexData of the ellipsoid
  23650. */
  23651. static CreateSphere(options: {
  23652. segments?: number;
  23653. diameter?: number;
  23654. diameterX?: number;
  23655. diameterY?: number;
  23656. diameterZ?: number;
  23657. arc?: number;
  23658. slice?: number;
  23659. sideOrientation?: number;
  23660. frontUVs?: Vector4;
  23661. backUVs?: Vector4;
  23662. }): VertexData;
  23663. /**
  23664. * Creates the VertexData for a cylinder, cone or prism
  23665. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23666. * * height sets the height (y direction) of the cylinder, optional, default 2
  23667. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  23668. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  23669. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  23670. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23671. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  23672. * * 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
  23673. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23674. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23675. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  23676. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  23677. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23678. * * 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)
  23679. * * 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)
  23680. * @returns the VertexData of the cylinder, cone or prism
  23681. */
  23682. static CreateCylinder(options: {
  23683. height?: number;
  23684. diameterTop?: number;
  23685. diameterBottom?: number;
  23686. diameter?: number;
  23687. tessellation?: number;
  23688. subdivisions?: number;
  23689. arc?: number;
  23690. faceColors?: Color4[];
  23691. faceUV?: Vector4[];
  23692. hasRings?: boolean;
  23693. enclose?: boolean;
  23694. sideOrientation?: number;
  23695. frontUVs?: Vector4;
  23696. backUVs?: Vector4;
  23697. }): VertexData;
  23698. /**
  23699. * Creates the VertexData for a torus
  23700. * @param options an object used to set the following optional parameters for the box, required but can be empty
  23701. * * diameter the diameter of the torus, optional default 1
  23702. * * thickness the diameter of the tube forming the torus, optional default 0.5
  23703. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  23704. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23705. * * 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)
  23706. * * 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)
  23707. * @returns the VertexData of the torus
  23708. */
  23709. static CreateTorus(options: {
  23710. diameter?: number;
  23711. thickness?: number;
  23712. tessellation?: number;
  23713. sideOrientation?: number;
  23714. frontUVs?: Vector4;
  23715. backUVs?: Vector4;
  23716. }): VertexData;
  23717. /**
  23718. * Creates the VertexData of the LineSystem
  23719. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  23720. * - lines an array of lines, each line being an array of successive Vector3
  23721. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  23722. * @returns the VertexData of the LineSystem
  23723. */
  23724. static CreateLineSystem(options: {
  23725. lines: Vector3[][];
  23726. colors?: Nullable<Color4[][]>;
  23727. }): VertexData;
  23728. /**
  23729. * Create the VertexData for a DashedLines
  23730. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  23731. * - points an array successive Vector3
  23732. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  23733. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  23734. * - dashNb the intended total number of dashes, optional, default 200
  23735. * @returns the VertexData for the DashedLines
  23736. */
  23737. static CreateDashedLines(options: {
  23738. points: Vector3[];
  23739. dashSize?: number;
  23740. gapSize?: number;
  23741. dashNb?: number;
  23742. }): VertexData;
  23743. /**
  23744. * Creates the VertexData for a Ground
  23745. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23746. * - width the width (x direction) of the ground, optional, default 1
  23747. * - height the height (z direction) of the ground, optional, default 1
  23748. * - subdivisions the number of subdivisions per side, optional, default 1
  23749. * @returns the VertexData of the Ground
  23750. */
  23751. static CreateGround(options: {
  23752. width?: number;
  23753. height?: number;
  23754. subdivisions?: number;
  23755. subdivisionsX?: number;
  23756. subdivisionsY?: number;
  23757. }): VertexData;
  23758. /**
  23759. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  23760. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  23761. * * xmin the ground minimum X coordinate, optional, default -1
  23762. * * zmin the ground minimum Z coordinate, optional, default -1
  23763. * * xmax the ground maximum X coordinate, optional, default 1
  23764. * * zmax the ground maximum Z coordinate, optional, default 1
  23765. * * 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}
  23766. * * 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}
  23767. * @returns the VertexData of the TiledGround
  23768. */
  23769. static CreateTiledGround(options: {
  23770. xmin: number;
  23771. zmin: number;
  23772. xmax: number;
  23773. zmax: number;
  23774. subdivisions?: {
  23775. w: number;
  23776. h: number;
  23777. };
  23778. precision?: {
  23779. w: number;
  23780. h: number;
  23781. };
  23782. }): VertexData;
  23783. /**
  23784. * Creates the VertexData of the Ground designed from a heightmap
  23785. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  23786. * * width the width (x direction) of the ground
  23787. * * height the height (z direction) of the ground
  23788. * * subdivisions the number of subdivisions per side
  23789. * * minHeight the minimum altitude on the ground, optional, default 0
  23790. * * maxHeight the maximum altitude on the ground, optional default 1
  23791. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  23792. * * buffer the array holding the image color data
  23793. * * bufferWidth the width of image
  23794. * * bufferHeight the height of image
  23795. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  23796. * @returns the VertexData of the Ground designed from a heightmap
  23797. */
  23798. static CreateGroundFromHeightMap(options: {
  23799. width: number;
  23800. height: number;
  23801. subdivisions: number;
  23802. minHeight: number;
  23803. maxHeight: number;
  23804. colorFilter: Color3;
  23805. buffer: Uint8Array;
  23806. bufferWidth: number;
  23807. bufferHeight: number;
  23808. alphaFilter: number;
  23809. }): VertexData;
  23810. /**
  23811. * Creates the VertexData for a Plane
  23812. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  23813. * * size sets the width and height of the plane to the value of size, optional default 1
  23814. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  23815. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  23816. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23817. * * 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)
  23818. * * 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)
  23819. * @returns the VertexData of the box
  23820. */
  23821. static CreatePlane(options: {
  23822. size?: number;
  23823. width?: number;
  23824. height?: number;
  23825. sideOrientation?: number;
  23826. frontUVs?: Vector4;
  23827. backUVs?: Vector4;
  23828. }): VertexData;
  23829. /**
  23830. * Creates the VertexData of the Disc or regular Polygon
  23831. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  23832. * * radius the radius of the disc, optional default 0.5
  23833. * * tessellation the number of polygon sides, optional, default 64
  23834. * * 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
  23835. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23836. * * 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)
  23837. * * 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)
  23838. * @returns the VertexData of the box
  23839. */
  23840. static CreateDisc(options: {
  23841. radius?: number;
  23842. tessellation?: number;
  23843. arc?: number;
  23844. sideOrientation?: number;
  23845. frontUVs?: Vector4;
  23846. backUVs?: Vector4;
  23847. }): VertexData;
  23848. /**
  23849. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  23850. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  23851. * @param polygon a mesh built from polygonTriangulation.build()
  23852. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23853. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23854. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23855. * @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)
  23856. * @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)
  23857. * @returns the VertexData of the Polygon
  23858. */
  23859. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  23860. /**
  23861. * Creates the VertexData of the IcoSphere
  23862. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  23863. * * radius the radius of the IcoSphere, optional default 1
  23864. * * radiusX allows stretching in the x direction, optional, default radius
  23865. * * radiusY allows stretching in the y direction, optional, default radius
  23866. * * radiusZ allows stretching in the z direction, optional, default radius
  23867. * * flat when true creates a flat shaded mesh, optional, default true
  23868. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23869. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23870. * * 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)
  23871. * * 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)
  23872. * @returns the VertexData of the IcoSphere
  23873. */
  23874. static CreateIcoSphere(options: {
  23875. radius?: number;
  23876. radiusX?: number;
  23877. radiusY?: number;
  23878. radiusZ?: number;
  23879. flat?: boolean;
  23880. subdivisions?: number;
  23881. sideOrientation?: number;
  23882. frontUVs?: Vector4;
  23883. backUVs?: Vector4;
  23884. }): VertexData;
  23885. /**
  23886. * Creates the VertexData for a Polyhedron
  23887. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  23888. * * type provided types are:
  23889. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  23890. * * 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)
  23891. * * size the size of the IcoSphere, optional default 1
  23892. * * sizeX allows stretching in the x direction, optional, default size
  23893. * * sizeY allows stretching in the y direction, optional, default size
  23894. * * sizeZ allows stretching in the z direction, optional, default size
  23895. * * 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
  23896. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  23897. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  23898. * * flat when true creates a flat shaded mesh, optional, default true
  23899. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  23900. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23901. * * 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)
  23902. * * 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)
  23903. * @returns the VertexData of the Polyhedron
  23904. */
  23905. static CreatePolyhedron(options: {
  23906. type?: number;
  23907. size?: number;
  23908. sizeX?: number;
  23909. sizeY?: number;
  23910. sizeZ?: number;
  23911. custom?: any;
  23912. faceUV?: Vector4[];
  23913. faceColors?: Color4[];
  23914. flat?: boolean;
  23915. sideOrientation?: number;
  23916. frontUVs?: Vector4;
  23917. backUVs?: Vector4;
  23918. }): VertexData;
  23919. /**
  23920. * Creates the VertexData for a TorusKnot
  23921. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  23922. * * radius the radius of the torus knot, optional, default 2
  23923. * * tube the thickness of the tube, optional, default 0.5
  23924. * * radialSegments the number of sides on each tube segments, optional, default 32
  23925. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  23926. * * p the number of windings around the z axis, optional, default 2
  23927. * * q the number of windings around the x axis, optional, default 3
  23928. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  23929. * * 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)
  23930. * * 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)
  23931. * @returns the VertexData of the Torus Knot
  23932. */
  23933. static CreateTorusKnot(options: {
  23934. radius?: number;
  23935. tube?: number;
  23936. radialSegments?: number;
  23937. tubularSegments?: number;
  23938. p?: number;
  23939. q?: number;
  23940. sideOrientation?: number;
  23941. frontUVs?: Vector4;
  23942. backUVs?: Vector4;
  23943. }): VertexData;
  23944. /**
  23945. * Compute normals for given positions and indices
  23946. * @param positions an array of vertex positions, [...., x, y, z, ......]
  23947. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  23948. * @param normals an array of vertex normals, [...., x, y, z, ......]
  23949. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  23950. * * facetNormals : optional array of facet normals (vector3)
  23951. * * facetPositions : optional array of facet positions (vector3)
  23952. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  23953. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  23954. * * bInfo : optional bounding info, required for facetPartitioning computation
  23955. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  23956. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  23957. * * useRightHandedSystem: optional boolean to for right handed system computation
  23958. * * depthSort : optional boolean to enable the facet depth sort computation
  23959. * * distanceTo : optional Vector3 to compute the facet depth from this location
  23960. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  23961. */
  23962. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  23963. facetNormals?: any;
  23964. facetPositions?: any;
  23965. facetPartitioning?: any;
  23966. ratio?: number;
  23967. bInfo?: any;
  23968. bbSize?: Vector3;
  23969. subDiv?: any;
  23970. useRightHandedSystem?: boolean;
  23971. depthSort?: boolean;
  23972. distanceTo?: Vector3;
  23973. depthSortedFacets?: any;
  23974. }): void;
  23975. /** @hidden */
  23976. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  23977. /**
  23978. * Applies VertexData created from the imported parameters to the geometry
  23979. * @param parsedVertexData the parsed data from an imported file
  23980. * @param geometry the geometry to apply the VertexData to
  23981. */
  23982. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  23983. }
  23984. }
  23985. declare module "babylonjs/Meshes/Builders/discBuilder" {
  23986. import { Nullable } from "babylonjs/types";
  23987. import { Scene } from "babylonjs/scene";
  23988. import { Vector4 } from "babylonjs/Maths/math";
  23989. import { Mesh } from "babylonjs/Meshes/mesh";
  23990. /**
  23991. * Class containing static functions to help procedurally build meshes
  23992. */
  23993. export class DiscBuilder {
  23994. /**
  23995. * Creates a plane polygonal mesh. By default, this is a disc
  23996. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  23997. * * 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
  23998. * * 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
  23999. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  24000. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  24001. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  24002. * @param name defines the name of the mesh
  24003. * @param options defines the options used to create the mesh
  24004. * @param scene defines the hosting scene
  24005. * @returns the plane polygonal mesh
  24006. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  24007. */
  24008. static CreateDisc(name: string, options: {
  24009. radius?: number;
  24010. tessellation?: number;
  24011. arc?: number;
  24012. updatable?: boolean;
  24013. sideOrientation?: number;
  24014. frontUVs?: Vector4;
  24015. backUVs?: Vector4;
  24016. }, scene?: Nullable<Scene>): Mesh;
  24017. }
  24018. }
  24019. declare module "babylonjs/Particles/solidParticleSystem" {
  24020. import { Vector3 } from "babylonjs/Maths/math";
  24021. import { Mesh } from "babylonjs/Meshes/mesh";
  24022. import { Scene, IDisposable } from "babylonjs/scene";
  24023. import { DepthSortedParticle, SolidParticle } from "babylonjs/Particles/solidParticle";
  24024. /**
  24025. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  24026. *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.
  24027. * The SPS is also a particle system. It provides some methods to manage the particles.
  24028. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  24029. *
  24030. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  24031. */
  24032. export class SolidParticleSystem implements IDisposable {
  24033. /**
  24034. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  24035. * Example : var p = SPS.particles[i];
  24036. */
  24037. particles: SolidParticle[];
  24038. /**
  24039. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  24040. */
  24041. nbParticles: number;
  24042. /**
  24043. * If the particles must ever face the camera (default false). Useful for planar particles.
  24044. */
  24045. billboard: boolean;
  24046. /**
  24047. * Recompute normals when adding a shape
  24048. */
  24049. recomputeNormals: boolean;
  24050. /**
  24051. * This a counter ofr your own usage. It's not set by any SPS functions.
  24052. */
  24053. counter: number;
  24054. /**
  24055. * The SPS name. This name is also given to the underlying mesh.
  24056. */
  24057. name: string;
  24058. /**
  24059. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  24060. */
  24061. mesh: Mesh;
  24062. /**
  24063. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  24064. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  24065. */
  24066. vars: any;
  24067. /**
  24068. * This array is populated when the SPS is set as 'pickable'.
  24069. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  24070. * Each element of this array is an object `{idx: int, faceId: int}`.
  24071. * `idx` is the picked particle index in the `SPS.particles` array
  24072. * `faceId` is the picked face index counted within this particle.
  24073. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  24074. */
  24075. pickedParticles: {
  24076. idx: number;
  24077. faceId: number;
  24078. }[];
  24079. /**
  24080. * This array is populated when `enableDepthSort` is set to true.
  24081. * Each element of this array is an instance of the class DepthSortedParticle.
  24082. */
  24083. depthSortedParticles: DepthSortedParticle[];
  24084. /**
  24085. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  24086. * @hidden
  24087. */
  24088. _bSphereOnly: boolean;
  24089. /**
  24090. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  24091. * @hidden
  24092. */
  24093. _bSphereRadiusFactor: number;
  24094. private _scene;
  24095. private _positions;
  24096. private _indices;
  24097. private _normals;
  24098. private _colors;
  24099. private _uvs;
  24100. private _indices32;
  24101. private _positions32;
  24102. private _normals32;
  24103. private _fixedNormal32;
  24104. private _colors32;
  24105. private _uvs32;
  24106. private _index;
  24107. private _updatable;
  24108. private _pickable;
  24109. private _isVisibilityBoxLocked;
  24110. private _alwaysVisible;
  24111. private _depthSort;
  24112. private _shapeCounter;
  24113. private _copy;
  24114. private _color;
  24115. private _computeParticleColor;
  24116. private _computeParticleTexture;
  24117. private _computeParticleRotation;
  24118. private _computeParticleVertex;
  24119. private _computeBoundingBox;
  24120. private _depthSortParticles;
  24121. private _camera;
  24122. private _mustUnrotateFixedNormals;
  24123. private _particlesIntersect;
  24124. private _needs32Bits;
  24125. /**
  24126. * Creates a SPS (Solid Particle System) object.
  24127. * @param name (String) is the SPS name, this will be the underlying mesh name.
  24128. * @param scene (Scene) is the scene in which the SPS is added.
  24129. * @param options defines the options of the sps e.g.
  24130. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  24131. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  24132. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  24133. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  24134. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  24135. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  24136. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  24137. */
  24138. constructor(name: string, scene: Scene, options?: {
  24139. updatable?: boolean;
  24140. isPickable?: boolean;
  24141. enableDepthSort?: boolean;
  24142. particleIntersection?: boolean;
  24143. boundingSphereOnly?: boolean;
  24144. bSphereRadiusFactor?: number;
  24145. });
  24146. /**
  24147. * Builds the SPS underlying mesh. Returns a standard Mesh.
  24148. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  24149. * @returns the created mesh
  24150. */
  24151. buildMesh(): Mesh;
  24152. /**
  24153. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  24154. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  24155. * Thus the particles generated from `digest()` have their property `position` set yet.
  24156. * @param mesh ( Mesh ) is the mesh to be digested
  24157. * @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
  24158. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  24159. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  24160. * @returns the current SPS
  24161. */
  24162. digest(mesh: Mesh, options?: {
  24163. facetNb?: number;
  24164. number?: number;
  24165. delta?: number;
  24166. }): SolidParticleSystem;
  24167. private _unrotateFixedNormals;
  24168. private _resetCopy;
  24169. private _meshBuilder;
  24170. private _posToShape;
  24171. private _uvsToShapeUV;
  24172. private _addParticle;
  24173. /**
  24174. * Adds some particles to the SPS from the model shape. Returns the shape id.
  24175. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  24176. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  24177. * @param nb (positive integer) the number of particles to be created from this model
  24178. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  24179. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  24180. * @returns the number of shapes in the system
  24181. */
  24182. addShape(mesh: Mesh, nb: number, options?: {
  24183. positionFunction?: any;
  24184. vertexFunction?: any;
  24185. }): number;
  24186. private _rebuildParticle;
  24187. /**
  24188. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  24189. * @returns the SPS.
  24190. */
  24191. rebuildMesh(): SolidParticleSystem;
  24192. /**
  24193. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  24194. * This method calls `updateParticle()` for each particle of the SPS.
  24195. * For an animated SPS, it is usually called within the render loop.
  24196. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  24197. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  24198. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  24199. * @returns the SPS.
  24200. */
  24201. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  24202. /**
  24203. * Disposes the SPS.
  24204. */
  24205. dispose(): void;
  24206. /**
  24207. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  24208. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24209. * @returns the SPS.
  24210. */
  24211. refreshVisibleSize(): SolidParticleSystem;
  24212. /**
  24213. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  24214. * @param size the size (float) of the visibility box
  24215. * note : this doesn't lock the SPS mesh bounding box.
  24216. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24217. */
  24218. setVisibilityBox(size: number): void;
  24219. /**
  24220. * Gets whether the SPS as always visible or not
  24221. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24222. */
  24223. /**
  24224. * Sets the SPS as always visible or not
  24225. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24226. */
  24227. isAlwaysVisible: boolean;
  24228. /**
  24229. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24230. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24231. */
  24232. /**
  24233. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  24234. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  24235. */
  24236. isVisibilityBoxLocked: boolean;
  24237. /**
  24238. * Tells to `setParticles()` to compute the particle rotations or not.
  24239. * Default value : true. The SPS is faster when it's set to false.
  24240. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24241. */
  24242. /**
  24243. * Gets if `setParticles()` computes the particle rotations or not.
  24244. * Default value : true. The SPS is faster when it's set to false.
  24245. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  24246. */
  24247. computeParticleRotation: boolean;
  24248. /**
  24249. * Tells to `setParticles()` to compute the particle colors or not.
  24250. * Default value : true. The SPS is faster when it's set to false.
  24251. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24252. */
  24253. /**
  24254. * Gets if `setParticles()` computes the particle colors or not.
  24255. * Default value : true. The SPS is faster when it's set to false.
  24256. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  24257. */
  24258. computeParticleColor: boolean;
  24259. /**
  24260. * Gets if `setParticles()` computes the particle textures or not.
  24261. * Default value : true. The SPS is faster when it's set to false.
  24262. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  24263. */
  24264. computeParticleTexture: boolean;
  24265. /**
  24266. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  24267. * Default value : false. The SPS is faster when it's set to false.
  24268. * Note : the particle custom vertex positions aren't stored values.
  24269. */
  24270. /**
  24271. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  24272. * Default value : false. The SPS is faster when it's set to false.
  24273. * Note : the particle custom vertex positions aren't stored values.
  24274. */
  24275. computeParticleVertex: boolean;
  24276. /**
  24277. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  24278. */
  24279. /**
  24280. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  24281. */
  24282. computeBoundingBox: boolean;
  24283. /**
  24284. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  24285. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24286. * Default : `true`
  24287. */
  24288. /**
  24289. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  24290. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  24291. * Default : `true`
  24292. */
  24293. depthSortParticles: boolean;
  24294. /**
  24295. * This function does nothing. It may be overwritten to set all the particle first values.
  24296. * The SPS doesn't call this function, you may have to call it by your own.
  24297. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24298. */
  24299. initParticles(): void;
  24300. /**
  24301. * This function does nothing. It may be overwritten to recycle a particle.
  24302. * The SPS doesn't call this function, you may have to call it by your own.
  24303. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24304. * @param particle The particle to recycle
  24305. * @returns the recycled particle
  24306. */
  24307. recycleParticle(particle: SolidParticle): SolidParticle;
  24308. /**
  24309. * Updates a particle : this function should be overwritten by the user.
  24310. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  24311. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  24312. * @example : just set a particle position or velocity and recycle conditions
  24313. * @param particle The particle to update
  24314. * @returns the updated particle
  24315. */
  24316. updateParticle(particle: SolidParticle): SolidParticle;
  24317. /**
  24318. * Updates a vertex of a particle : it can be overwritten by the user.
  24319. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  24320. * @param particle the current particle
  24321. * @param vertex the current index of the current particle
  24322. * @param pt the index of the current vertex in the particle shape
  24323. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  24324. * @example : just set a vertex particle position
  24325. * @returns the updated vertex
  24326. */
  24327. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  24328. /**
  24329. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  24330. * This does nothing and may be overwritten by the user.
  24331. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24332. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24333. * @param update the boolean update value actually passed to setParticles()
  24334. */
  24335. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24336. /**
  24337. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  24338. * This will be passed three parameters.
  24339. * This does nothing and may be overwritten by the user.
  24340. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24341. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  24342. * @param update the boolean update value actually passed to setParticles()
  24343. */
  24344. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  24345. }
  24346. }
  24347. declare module "babylonjs/Particles/solidParticle" {
  24348. import { Nullable } from "babylonjs/types";
  24349. import { Color4, Vector3, Matrix, Quaternion, Vector4, Plane } from "babylonjs/Maths/math";
  24350. import { Mesh } from "babylonjs/Meshes/mesh";
  24351. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24352. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  24353. /**
  24354. * Represents one particle of a solid particle system.
  24355. */
  24356. export class SolidParticle {
  24357. /**
  24358. * particle global index
  24359. */
  24360. idx: number;
  24361. /**
  24362. * The color of the particle
  24363. */
  24364. color: Nullable<Color4>;
  24365. /**
  24366. * The world space position of the particle.
  24367. */
  24368. position: Vector3;
  24369. /**
  24370. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  24371. */
  24372. rotation: Vector3;
  24373. /**
  24374. * The world space rotation quaternion of the particle.
  24375. */
  24376. rotationQuaternion: Nullable<Quaternion>;
  24377. /**
  24378. * The scaling of the particle.
  24379. */
  24380. scaling: Vector3;
  24381. /**
  24382. * The uvs of the particle.
  24383. */
  24384. uvs: Vector4;
  24385. /**
  24386. * The current speed of the particle.
  24387. */
  24388. velocity: Vector3;
  24389. /**
  24390. * The pivot point in the particle local space.
  24391. */
  24392. pivot: Vector3;
  24393. /**
  24394. * Must the particle be translated from its pivot point in its local space ?
  24395. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  24396. * Default : false
  24397. */
  24398. translateFromPivot: boolean;
  24399. /**
  24400. * Is the particle active or not ?
  24401. */
  24402. alive: boolean;
  24403. /**
  24404. * Is the particle visible or not ?
  24405. */
  24406. isVisible: boolean;
  24407. /**
  24408. * Index of this particle in the global "positions" array (Internal use)
  24409. * @hidden
  24410. */
  24411. _pos: number;
  24412. /**
  24413. * @hidden Index of this particle in the global "indices" array (Internal use)
  24414. */
  24415. _ind: number;
  24416. /**
  24417. * @hidden ModelShape of this particle (Internal use)
  24418. */
  24419. _model: ModelShape;
  24420. /**
  24421. * ModelShape id of this particle
  24422. */
  24423. shapeId: number;
  24424. /**
  24425. * Index of the particle in its shape id (Internal use)
  24426. */
  24427. idxInShape: number;
  24428. /**
  24429. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  24430. */
  24431. _modelBoundingInfo: BoundingInfo;
  24432. /**
  24433. * @hidden Particle BoundingInfo object (Internal use)
  24434. */
  24435. _boundingInfo: BoundingInfo;
  24436. /**
  24437. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  24438. */
  24439. _sps: SolidParticleSystem;
  24440. /**
  24441. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  24442. */
  24443. _stillInvisible: boolean;
  24444. /**
  24445. * @hidden Last computed particle rotation matrix
  24446. */
  24447. _rotationMatrix: number[];
  24448. /**
  24449. * Parent particle Id, if any.
  24450. * Default null.
  24451. */
  24452. parentId: Nullable<number>;
  24453. /**
  24454. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  24455. * The possible values are :
  24456. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24457. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24458. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24459. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24460. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24461. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  24462. * */
  24463. cullingStrategy: number;
  24464. /**
  24465. * @hidden Internal global position in the SPS.
  24466. */
  24467. _globalPosition: Vector3;
  24468. /**
  24469. * Creates a Solid Particle object.
  24470. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  24471. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  24472. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  24473. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  24474. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  24475. * @param shapeId (integer) is the model shape identifier in the SPS.
  24476. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  24477. * @param sps defines the sps it is associated to
  24478. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  24479. */
  24480. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  24481. /**
  24482. * Legacy support, changed scale to scaling
  24483. */
  24484. /**
  24485. * Legacy support, changed scale to scaling
  24486. */
  24487. scale: Vector3;
  24488. /**
  24489. * Legacy support, changed quaternion to rotationQuaternion
  24490. */
  24491. /**
  24492. * Legacy support, changed quaternion to rotationQuaternion
  24493. */
  24494. quaternion: Nullable<Quaternion>;
  24495. /**
  24496. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  24497. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  24498. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  24499. * @returns true if it intersects
  24500. */
  24501. intersectsMesh(target: Mesh | SolidParticle): boolean;
  24502. /**
  24503. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  24504. * A particle is in the frustum if its bounding box intersects the frustum
  24505. * @param frustumPlanes defines the frustum to test
  24506. * @returns true if the particle is in the frustum planes
  24507. */
  24508. isInFrustum(frustumPlanes: Plane[]): boolean;
  24509. /**
  24510. * get the rotation matrix of the particle
  24511. * @hidden
  24512. */
  24513. getRotationMatrix(m: Matrix): void;
  24514. }
  24515. /**
  24516. * Represents the shape of the model used by one particle of a solid particle system.
  24517. * SPS internal tool, don't use it manually.
  24518. */
  24519. export class ModelShape {
  24520. /**
  24521. * The shape id
  24522. * @hidden
  24523. */
  24524. shapeID: number;
  24525. /**
  24526. * flat array of model positions (internal use)
  24527. * @hidden
  24528. */
  24529. _shape: Vector3[];
  24530. /**
  24531. * flat array of model UVs (internal use)
  24532. * @hidden
  24533. */
  24534. _shapeUV: number[];
  24535. /**
  24536. * length of the shape in the model indices array (internal use)
  24537. * @hidden
  24538. */
  24539. _indicesLength: number;
  24540. /**
  24541. * Custom position function (internal use)
  24542. * @hidden
  24543. */
  24544. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  24545. /**
  24546. * Custom vertex function (internal use)
  24547. * @hidden
  24548. */
  24549. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  24550. /**
  24551. * 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.
  24552. * SPS internal tool, don't use it manually.
  24553. * @hidden
  24554. */
  24555. 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>);
  24556. }
  24557. /**
  24558. * Represents a Depth Sorted Particle in the solid particle system.
  24559. */
  24560. export class DepthSortedParticle {
  24561. /**
  24562. * Index of the particle in the "indices" array
  24563. */
  24564. ind: number;
  24565. /**
  24566. * Length of the particle shape in the "indices" array
  24567. */
  24568. indicesLength: number;
  24569. /**
  24570. * Squared distance from the particle to the camera
  24571. */
  24572. sqDistance: number;
  24573. }
  24574. }
  24575. declare module "babylonjs/Meshes/abstractMesh" {
  24576. import { Observable } from "babylonjs/Misc/observable";
  24577. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  24578. import { Camera } from "babylonjs/Cameras/camera";
  24579. import { Scene, IDisposable } from "babylonjs/scene";
  24580. import { Matrix, Vector3, Color3, Color4, Plane, Vector2 } from "babylonjs/Maths/math";
  24581. import { Node } from "babylonjs/node";
  24582. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  24583. import { TransformNode } from "babylonjs/Meshes/transformNode";
  24584. import { SubMesh } from "babylonjs/Meshes/subMesh";
  24585. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  24586. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  24587. import { Material } from "babylonjs/Materials/material";
  24588. import { Light } from "babylonjs/Lights/light";
  24589. import { Skeleton } from "babylonjs/Bones/skeleton";
  24590. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  24591. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  24592. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  24593. import { Ray } from "babylonjs/Culling/ray";
  24594. import { Collider } from "babylonjs/Collisions/collider";
  24595. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  24596. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  24597. /**
  24598. * Class used to store all common mesh properties
  24599. */
  24600. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  24601. /** No occlusion */
  24602. static OCCLUSION_TYPE_NONE: number;
  24603. /** Occlusion set to optimisitic */
  24604. static OCCLUSION_TYPE_OPTIMISTIC: number;
  24605. /** Occlusion set to strict */
  24606. static OCCLUSION_TYPE_STRICT: number;
  24607. /** Use an accurante occlusion algorithm */
  24608. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  24609. /** Use a conservative occlusion algorithm */
  24610. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  24611. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  24612. * Test order :
  24613. * Is the bounding sphere outside the frustum ?
  24614. * If not, are the bounding box vertices outside the frustum ?
  24615. * It not, then the cullable object is in the frustum.
  24616. */
  24617. static readonly CULLINGSTRATEGY_STANDARD: number;
  24618. /** Culling strategy : Bounding Sphere Only.
  24619. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  24620. * It's also less accurate than the standard because some not visible objects can still be selected.
  24621. * Test : is the bounding sphere outside the frustum ?
  24622. * If not, then the cullable object is in the frustum.
  24623. */
  24624. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  24625. /** Culling strategy : Optimistic Inclusion.
  24626. * This in an inclusion test first, then the standard exclusion test.
  24627. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  24628. * 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.
  24629. * Anyway, it's as accurate as the standard strategy.
  24630. * Test :
  24631. * Is the cullable object bounding sphere center in the frustum ?
  24632. * If not, apply the default culling strategy.
  24633. */
  24634. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  24635. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  24636. * This in an inclusion test first, then the bounding sphere only exclusion test.
  24637. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  24638. * 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.
  24639. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  24640. * Test :
  24641. * Is the cullable object bounding sphere center in the frustum ?
  24642. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  24643. */
  24644. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  24645. /**
  24646. * No billboard
  24647. */
  24648. static readonly BILLBOARDMODE_NONE: number;
  24649. /** Billboard on X axis */
  24650. static readonly BILLBOARDMODE_X: number;
  24651. /** Billboard on Y axis */
  24652. static readonly BILLBOARDMODE_Y: number;
  24653. /** Billboard on Z axis */
  24654. static readonly BILLBOARDMODE_Z: number;
  24655. /** Billboard on all axes */
  24656. static readonly BILLBOARDMODE_ALL: number;
  24657. private _facetData;
  24658. /**
  24659. * The culling strategy to use to check whether the mesh must be rendered or not.
  24660. * This value can be changed at any time and will be used on the next render mesh selection.
  24661. * The possible values are :
  24662. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  24663. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  24664. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  24665. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  24666. * Please read each static variable documentation to get details about the culling process.
  24667. * */
  24668. cullingStrategy: number;
  24669. /**
  24670. * Gets the number of facets in the mesh
  24671. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24672. */
  24673. readonly facetNb: number;
  24674. /**
  24675. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  24676. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24677. */
  24678. partitioningSubdivisions: number;
  24679. /**
  24680. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  24681. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  24682. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  24683. */
  24684. partitioningBBoxRatio: number;
  24685. /**
  24686. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  24687. * Works only for updatable meshes.
  24688. * Doesn't work with multi-materials
  24689. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24690. */
  24691. mustDepthSortFacets: boolean;
  24692. /**
  24693. * The location (Vector3) where the facet depth sort must be computed from.
  24694. * By default, the active camera position.
  24695. * Used only when facet depth sort is enabled
  24696. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  24697. */
  24698. facetDepthSortFrom: Vector3;
  24699. /**
  24700. * gets a boolean indicating if facetData is enabled
  24701. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  24702. */
  24703. readonly isFacetDataEnabled: boolean;
  24704. /** @hidden */
  24705. _updateNonUniformScalingState(value: boolean): boolean;
  24706. /**
  24707. * An event triggered when this mesh collides with another one
  24708. */
  24709. onCollideObservable: Observable<AbstractMesh>;
  24710. private _onCollideObserver;
  24711. /** Set a function to call when this mesh collides with another one */
  24712. onCollide: () => void;
  24713. /**
  24714. * An event triggered when the collision's position changes
  24715. */
  24716. onCollisionPositionChangeObservable: Observable<Vector3>;
  24717. private _onCollisionPositionChangeObserver;
  24718. /** Set a function to call when the collision's position changes */
  24719. onCollisionPositionChange: () => void;
  24720. /**
  24721. * An event triggered when material is changed
  24722. */
  24723. onMaterialChangedObservable: Observable<AbstractMesh>;
  24724. /**
  24725. * Gets or sets the orientation for POV movement & rotation
  24726. */
  24727. definedFacingForward: boolean;
  24728. /** @hidden */
  24729. _occlusionQuery: Nullable<WebGLQuery>;
  24730. private _visibility;
  24731. /** @hidden */
  24732. _isActive: boolean;
  24733. /** @hidden */
  24734. _renderingGroup: Nullable<RenderingGroup>;
  24735. /**
  24736. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24737. */
  24738. /**
  24739. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  24740. */
  24741. visibility: number;
  24742. /** Gets or sets the alpha index used to sort transparent meshes
  24743. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  24744. */
  24745. alphaIndex: number;
  24746. /**
  24747. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  24748. */
  24749. isVisible: boolean;
  24750. /**
  24751. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  24752. */
  24753. isPickable: boolean;
  24754. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  24755. showSubMeshesBoundingBox: boolean;
  24756. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  24757. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  24758. */
  24759. isBlocker: boolean;
  24760. /**
  24761. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  24762. */
  24763. enablePointerMoveEvents: boolean;
  24764. /**
  24765. * Specifies the rendering group id for this mesh (0 by default)
  24766. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  24767. */
  24768. renderingGroupId: number;
  24769. private _material;
  24770. /** Gets or sets current material */
  24771. material: Nullable<Material>;
  24772. private _receiveShadows;
  24773. /**
  24774. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  24775. * @see http://doc.babylonjs.com/babylon101/shadows
  24776. */
  24777. receiveShadows: boolean;
  24778. /** Defines color to use when rendering outline */
  24779. outlineColor: Color3;
  24780. /** Define width to use when rendering outline */
  24781. outlineWidth: number;
  24782. /** Defines color to use when rendering overlay */
  24783. overlayColor: Color3;
  24784. /** Defines alpha to use when rendering overlay */
  24785. overlayAlpha: number;
  24786. private _hasVertexAlpha;
  24787. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  24788. hasVertexAlpha: boolean;
  24789. private _useVertexColors;
  24790. /** 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) */
  24791. useVertexColors: boolean;
  24792. private _computeBonesUsingShaders;
  24793. /**
  24794. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  24795. */
  24796. computeBonesUsingShaders: boolean;
  24797. private _numBoneInfluencers;
  24798. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  24799. numBoneInfluencers: number;
  24800. private _applyFog;
  24801. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  24802. applyFog: boolean;
  24803. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  24804. useOctreeForRenderingSelection: boolean;
  24805. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  24806. useOctreeForPicking: boolean;
  24807. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  24808. useOctreeForCollisions: boolean;
  24809. private _layerMask;
  24810. /**
  24811. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  24812. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  24813. */
  24814. layerMask: number;
  24815. /**
  24816. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  24817. */
  24818. alwaysSelectAsActiveMesh: boolean;
  24819. /**
  24820. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  24821. */
  24822. doNotSyncBoundingInfo: boolean;
  24823. /**
  24824. * Gets or sets the current action manager
  24825. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  24826. */
  24827. actionManager: Nullable<AbstractActionManager>;
  24828. private _checkCollisions;
  24829. private _collisionMask;
  24830. private _collisionGroup;
  24831. /**
  24832. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  24833. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24834. */
  24835. ellipsoid: Vector3;
  24836. /**
  24837. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  24838. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  24839. */
  24840. ellipsoidOffset: Vector3;
  24841. private _collider;
  24842. private _oldPositionForCollisions;
  24843. private _diffPositionForCollisions;
  24844. /**
  24845. * Gets or sets a collision mask used to mask collisions (default is -1).
  24846. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24847. */
  24848. collisionMask: number;
  24849. /**
  24850. * Gets or sets the current collision group mask (-1 by default).
  24851. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  24852. */
  24853. collisionGroup: number;
  24854. /**
  24855. * Defines edge width used when edgesRenderer is enabled
  24856. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24857. */
  24858. edgesWidth: number;
  24859. /**
  24860. * Defines edge color used when edgesRenderer is enabled
  24861. * @see https://www.babylonjs-playground.com/#10OJSG#13
  24862. */
  24863. edgesColor: Color4;
  24864. /** @hidden */
  24865. _edgesRenderer: Nullable<IEdgesRenderer>;
  24866. /** @hidden */
  24867. _masterMesh: Nullable<AbstractMesh>;
  24868. /** @hidden */
  24869. _boundingInfo: Nullable<BoundingInfo>;
  24870. /** @hidden */
  24871. _renderId: number;
  24872. /**
  24873. * Gets or sets the list of subMeshes
  24874. * @see http://doc.babylonjs.com/how_to/multi_materials
  24875. */
  24876. subMeshes: SubMesh[];
  24877. /** @hidden */
  24878. _intersectionsInProgress: AbstractMesh[];
  24879. /** @hidden */
  24880. _unIndexed: boolean;
  24881. /** @hidden */
  24882. _lightSources: Light[];
  24883. /** @hidden */
  24884. readonly _positions: Nullable<Vector3[]>;
  24885. /** @hidden */
  24886. _waitingActions: Nullable<any>;
  24887. /** @hidden */
  24888. _waitingFreezeWorldMatrix: Nullable<boolean>;
  24889. private _skeleton;
  24890. /** @hidden */
  24891. _bonesTransformMatrices: Nullable<Float32Array>;
  24892. /**
  24893. * Gets or sets a skeleton to apply skining transformations
  24894. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  24895. */
  24896. skeleton: Nullable<Skeleton>;
  24897. /**
  24898. * An event triggered when the mesh is rebuilt.
  24899. */
  24900. onRebuildObservable: Observable<AbstractMesh>;
  24901. /**
  24902. * Creates a new AbstractMesh
  24903. * @param name defines the name of the mesh
  24904. * @param scene defines the hosting scene
  24905. */
  24906. constructor(name: string, scene?: Nullable<Scene>);
  24907. /**
  24908. * Returns the string "AbstractMesh"
  24909. * @returns "AbstractMesh"
  24910. */
  24911. getClassName(): string;
  24912. /**
  24913. * Gets a string representation of the current mesh
  24914. * @param fullDetails defines a boolean indicating if full details must be included
  24915. * @returns a string representation of the current mesh
  24916. */
  24917. toString(fullDetails?: boolean): string;
  24918. /**
  24919. * @hidden
  24920. */
  24921. protected _getEffectiveParent(): Nullable<Node>;
  24922. /** @hidden */
  24923. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  24924. /** @hidden */
  24925. _rebuild(): void;
  24926. /** @hidden */
  24927. _resyncLightSources(): void;
  24928. /** @hidden */
  24929. _resyncLighSource(light: Light): void;
  24930. /** @hidden */
  24931. _unBindEffect(): void;
  24932. /** @hidden */
  24933. _removeLightSource(light: Light): void;
  24934. private _markSubMeshesAsDirty;
  24935. /** @hidden */
  24936. _markSubMeshesAsLightDirty(): void;
  24937. /** @hidden */
  24938. _markSubMeshesAsAttributesDirty(): void;
  24939. /** @hidden */
  24940. _markSubMeshesAsMiscDirty(): void;
  24941. /**
  24942. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  24943. */
  24944. scaling: Vector3;
  24945. /**
  24946. * Returns true if the mesh is blocked. Implemented by child classes
  24947. */
  24948. readonly isBlocked: boolean;
  24949. /**
  24950. * Returns the mesh itself by default. Implemented by child classes
  24951. * @param camera defines the camera to use to pick the right LOD level
  24952. * @returns the currentAbstractMesh
  24953. */
  24954. getLOD(camera: Camera): Nullable<AbstractMesh>;
  24955. /**
  24956. * Returns 0 by default. Implemented by child classes
  24957. * @returns an integer
  24958. */
  24959. getTotalVertices(): number;
  24960. /**
  24961. * Returns a positive integer : the total number of indices in this mesh geometry.
  24962. * @returns the numner of indices or zero if the mesh has no geometry.
  24963. */
  24964. getTotalIndices(): number;
  24965. /**
  24966. * Returns null by default. Implemented by child classes
  24967. * @returns null
  24968. */
  24969. getIndices(): Nullable<IndicesArray>;
  24970. /**
  24971. * Returns the array of the requested vertex data kind. Implemented by child classes
  24972. * @param kind defines the vertex data kind to use
  24973. * @returns null
  24974. */
  24975. getVerticesData(kind: string): Nullable<FloatArray>;
  24976. /**
  24977. * Sets the vertex data of the mesh geometry for the requested `kind`.
  24978. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  24979. * Note that a new underlying VertexBuffer object is created each call.
  24980. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  24981. * @param kind defines vertex data kind:
  24982. * * VertexBuffer.PositionKind
  24983. * * VertexBuffer.UVKind
  24984. * * VertexBuffer.UV2Kind
  24985. * * VertexBuffer.UV3Kind
  24986. * * VertexBuffer.UV4Kind
  24987. * * VertexBuffer.UV5Kind
  24988. * * VertexBuffer.UV6Kind
  24989. * * VertexBuffer.ColorKind
  24990. * * VertexBuffer.MatricesIndicesKind
  24991. * * VertexBuffer.MatricesIndicesExtraKind
  24992. * * VertexBuffer.MatricesWeightsKind
  24993. * * VertexBuffer.MatricesWeightsExtraKind
  24994. * @param data defines the data source
  24995. * @param updatable defines if the data must be flagged as updatable (or static)
  24996. * @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
  24997. * @returns the current mesh
  24998. */
  24999. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  25000. /**
  25001. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  25002. * If the mesh has no geometry, it is simply returned as it is.
  25003. * @param kind defines vertex data kind:
  25004. * * VertexBuffer.PositionKind
  25005. * * VertexBuffer.UVKind
  25006. * * VertexBuffer.UV2Kind
  25007. * * VertexBuffer.UV3Kind
  25008. * * VertexBuffer.UV4Kind
  25009. * * VertexBuffer.UV5Kind
  25010. * * VertexBuffer.UV6Kind
  25011. * * VertexBuffer.ColorKind
  25012. * * VertexBuffer.MatricesIndicesKind
  25013. * * VertexBuffer.MatricesIndicesExtraKind
  25014. * * VertexBuffer.MatricesWeightsKind
  25015. * * VertexBuffer.MatricesWeightsExtraKind
  25016. * @param data defines the data source
  25017. * @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
  25018. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  25019. * @returns the current mesh
  25020. */
  25021. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  25022. /**
  25023. * Sets the mesh indices,
  25024. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  25025. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  25026. * @param totalVertices Defines the total number of vertices
  25027. * @returns the current mesh
  25028. */
  25029. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  25030. /**
  25031. * Gets a boolean indicating if specific vertex data is present
  25032. * @param kind defines the vertex data kind to use
  25033. * @returns true is data kind is present
  25034. */
  25035. isVerticesDataPresent(kind: string): boolean;
  25036. /**
  25037. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  25038. * @returns a BoundingInfo
  25039. */
  25040. getBoundingInfo(): BoundingInfo;
  25041. /**
  25042. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  25043. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  25044. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  25045. * @returns the current mesh
  25046. */
  25047. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  25048. /**
  25049. * Overwrite the current bounding info
  25050. * @param boundingInfo defines the new bounding info
  25051. * @returns the current mesh
  25052. */
  25053. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  25054. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  25055. readonly useBones: boolean;
  25056. /** @hidden */
  25057. _preActivate(): void;
  25058. /** @hidden */
  25059. _preActivateForIntermediateRendering(renderId: number): void;
  25060. /** @hidden */
  25061. _activate(renderId: number): boolean;
  25062. /** @hidden */
  25063. _freeze(): void;
  25064. /** @hidden */
  25065. _unFreeze(): void;
  25066. /**
  25067. * Gets the current world matrix
  25068. * @returns a Matrix
  25069. */
  25070. getWorldMatrix(): Matrix;
  25071. /** @hidden */
  25072. _getWorldMatrixDeterminant(): number;
  25073. /**
  25074. * Perform relative position change from the point of view of behind the front of the mesh.
  25075. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25076. * Supports definition of mesh facing forward or backward
  25077. * @param amountRight defines the distance on the right axis
  25078. * @param amountUp defines the distance on the up axis
  25079. * @param amountForward defines the distance on the forward axis
  25080. * @returns the current mesh
  25081. */
  25082. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  25083. /**
  25084. * Calculate relative position change from the point of view of behind the front of the mesh.
  25085. * This is performed taking into account the meshes current rotation, so you do not have to care.
  25086. * Supports definition of mesh facing forward or backward
  25087. * @param amountRight defines the distance on the right axis
  25088. * @param amountUp defines the distance on the up axis
  25089. * @param amountForward defines the distance on the forward axis
  25090. * @returns the new displacement vector
  25091. */
  25092. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  25093. /**
  25094. * Perform relative rotation change from the point of view of behind the front of the mesh.
  25095. * Supports definition of mesh facing forward or backward
  25096. * @param flipBack defines the flip
  25097. * @param twirlClockwise defines the twirl
  25098. * @param tiltRight defines the tilt
  25099. * @returns the current mesh
  25100. */
  25101. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  25102. /**
  25103. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  25104. * Supports definition of mesh facing forward or backward.
  25105. * @param flipBack defines the flip
  25106. * @param twirlClockwise defines the twirl
  25107. * @param tiltRight defines the tilt
  25108. * @returns the new rotation vector
  25109. */
  25110. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  25111. /**
  25112. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  25113. * This means the mesh underlying bounding box and sphere are recomputed.
  25114. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  25115. * @returns the current mesh
  25116. */
  25117. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  25118. /** @hidden */
  25119. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  25120. /** @hidden */
  25121. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  25122. /** @hidden */
  25123. _updateBoundingInfo(): AbstractMesh;
  25124. /** @hidden */
  25125. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  25126. /** @hidden */
  25127. protected _afterComputeWorldMatrix(): void;
  25128. /** @hidden */
  25129. readonly _effectiveMesh: AbstractMesh;
  25130. /**
  25131. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  25132. * A mesh is in the frustum if its bounding box intersects the frustum
  25133. * @param frustumPlanes defines the frustum to test
  25134. * @returns true if the mesh is in the frustum planes
  25135. */
  25136. isInFrustum(frustumPlanes: Plane[]): boolean;
  25137. /**
  25138. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  25139. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  25140. * @param frustumPlanes defines the frustum to test
  25141. * @returns true if the mesh is completely in the frustum planes
  25142. */
  25143. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  25144. /**
  25145. * True if the mesh intersects another mesh or a SolidParticle object
  25146. * @param mesh defines a target mesh or SolidParticle to test
  25147. * @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)
  25148. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  25149. * @returns true if there is an intersection
  25150. */
  25151. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  25152. /**
  25153. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  25154. * @param point defines the point to test
  25155. * @returns true if there is an intersection
  25156. */
  25157. intersectsPoint(point: Vector3): boolean;
  25158. /**
  25159. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  25160. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25161. */
  25162. checkCollisions: boolean;
  25163. /**
  25164. * Gets Collider object used to compute collisions (not physics)
  25165. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25166. */
  25167. readonly collider: Nullable<Collider>;
  25168. /**
  25169. * Move the mesh using collision engine
  25170. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  25171. * @param displacement defines the requested displacement vector
  25172. * @returns the current mesh
  25173. */
  25174. moveWithCollisions(displacement: Vector3): AbstractMesh;
  25175. private _onCollisionPositionChange;
  25176. /** @hidden */
  25177. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  25178. /** @hidden */
  25179. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  25180. /** @hidden */
  25181. _checkCollision(collider: Collider): AbstractMesh;
  25182. /** @hidden */
  25183. _generatePointsArray(): boolean;
  25184. /**
  25185. * Checks if the passed Ray intersects with the mesh
  25186. * @param ray defines the ray to use
  25187. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  25188. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  25189. * @returns the picking info
  25190. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  25191. */
  25192. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  25193. /**
  25194. * Clones the current mesh
  25195. * @param name defines the mesh name
  25196. * @param newParent defines the new mesh parent
  25197. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  25198. * @returns the new mesh
  25199. */
  25200. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  25201. /**
  25202. * Disposes all the submeshes of the current meshnp
  25203. * @returns the current mesh
  25204. */
  25205. releaseSubMeshes(): AbstractMesh;
  25206. /**
  25207. * Releases resources associated with this abstract mesh.
  25208. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25209. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25210. */
  25211. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25212. /**
  25213. * Adds the passed mesh as a child to the current mesh
  25214. * @param mesh defines the child mesh
  25215. * @returns the current mesh
  25216. */
  25217. addChild(mesh: AbstractMesh): AbstractMesh;
  25218. /**
  25219. * Removes the passed mesh from the current mesh children list
  25220. * @param mesh defines the child mesh
  25221. * @returns the current mesh
  25222. */
  25223. removeChild(mesh: AbstractMesh): AbstractMesh;
  25224. /** @hidden */
  25225. private _initFacetData;
  25226. /**
  25227. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  25228. * This method can be called within the render loop.
  25229. * 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
  25230. * @returns the current mesh
  25231. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25232. */
  25233. updateFacetData(): AbstractMesh;
  25234. /**
  25235. * Returns the facetLocalNormals array.
  25236. * The normals are expressed in the mesh local spac
  25237. * @returns an array of Vector3
  25238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25239. */
  25240. getFacetLocalNormals(): Vector3[];
  25241. /**
  25242. * Returns the facetLocalPositions array.
  25243. * The facet positions are expressed in the mesh local space
  25244. * @returns an array of Vector3
  25245. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25246. */
  25247. getFacetLocalPositions(): Vector3[];
  25248. /**
  25249. * Returns the facetLocalPartioning array
  25250. * @returns an array of array of numbers
  25251. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25252. */
  25253. getFacetLocalPartitioning(): number[][];
  25254. /**
  25255. * Returns the i-th facet position in the world system.
  25256. * This method allocates a new Vector3 per call
  25257. * @param i defines the facet index
  25258. * @returns a new Vector3
  25259. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25260. */
  25261. getFacetPosition(i: number): Vector3;
  25262. /**
  25263. * Sets the reference Vector3 with the i-th facet position in the world system
  25264. * @param i defines the facet index
  25265. * @param ref defines the target vector
  25266. * @returns the current mesh
  25267. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25268. */
  25269. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  25270. /**
  25271. * Returns the i-th facet normal in the world system.
  25272. * This method allocates a new Vector3 per call
  25273. * @param i defines the facet index
  25274. * @returns a new Vector3
  25275. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25276. */
  25277. getFacetNormal(i: number): Vector3;
  25278. /**
  25279. * Sets the reference Vector3 with the i-th facet normal in the world system
  25280. * @param i defines the facet index
  25281. * @param ref defines the target vector
  25282. * @returns the current mesh
  25283. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25284. */
  25285. getFacetNormalToRef(i: number, ref: Vector3): this;
  25286. /**
  25287. * 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)
  25288. * @param x defines x coordinate
  25289. * @param y defines y coordinate
  25290. * @param z defines z coordinate
  25291. * @returns the array of facet indexes
  25292. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25293. */
  25294. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  25295. /**
  25296. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  25297. * @param projected sets as the (x,y,z) world projection on the facet
  25298. * @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
  25299. * @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
  25300. * @param x defines x coordinate
  25301. * @param y defines y coordinate
  25302. * @param z defines z coordinate
  25303. * @returns the face index if found (or null instead)
  25304. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25305. */
  25306. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25307. /**
  25308. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  25309. * @param projected sets as the (x,y,z) local projection on the facet
  25310. * @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
  25311. * @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
  25312. * @param x defines x coordinate
  25313. * @param y defines y coordinate
  25314. * @param z defines z coordinate
  25315. * @returns the face index if found (or null instead)
  25316. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25317. */
  25318. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  25319. /**
  25320. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  25321. * @returns the parameters
  25322. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25323. */
  25324. getFacetDataParameters(): any;
  25325. /**
  25326. * Disables the feature FacetData and frees the related memory
  25327. * @returns the current mesh
  25328. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  25329. */
  25330. disableFacetData(): AbstractMesh;
  25331. /**
  25332. * Updates the AbstractMesh indices array
  25333. * @param indices defines the data source
  25334. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  25335. * @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)
  25336. * @returns the current mesh
  25337. */
  25338. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  25339. /**
  25340. * Creates new normals data for the mesh
  25341. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  25342. * @returns the current mesh
  25343. */
  25344. createNormals(updatable: boolean): AbstractMesh;
  25345. /**
  25346. * Align the mesh with a normal
  25347. * @param normal defines the normal to use
  25348. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  25349. * @returns the current mesh
  25350. */
  25351. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  25352. /** @hidden */
  25353. _checkOcclusionQuery(): boolean;
  25354. }
  25355. }
  25356. declare module "babylonjs/Actions/actionEvent" {
  25357. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25358. import { Nullable } from "babylonjs/types";
  25359. import { Sprite } from "babylonjs/Sprites/sprite";
  25360. import { Scene } from "babylonjs/scene";
  25361. import { Vector2 } from "babylonjs/Maths/math";
  25362. /**
  25363. * Interface used to define ActionEvent
  25364. */
  25365. export interface IActionEvent {
  25366. /** The mesh or sprite that triggered the action */
  25367. source: any;
  25368. /** The X mouse cursor position at the time of the event */
  25369. pointerX: number;
  25370. /** The Y mouse cursor position at the time of the event */
  25371. pointerY: number;
  25372. /** The mesh that is currently pointed at (can be null) */
  25373. meshUnderPointer: Nullable<AbstractMesh>;
  25374. /** the original (browser) event that triggered the ActionEvent */
  25375. sourceEvent?: any;
  25376. /** additional data for the event */
  25377. additionalData?: any;
  25378. }
  25379. /**
  25380. * ActionEvent is the event being sent when an action is triggered.
  25381. */
  25382. export class ActionEvent implements IActionEvent {
  25383. /** The mesh or sprite that triggered the action */
  25384. source: any;
  25385. /** The X mouse cursor position at the time of the event */
  25386. pointerX: number;
  25387. /** The Y mouse cursor position at the time of the event */
  25388. pointerY: number;
  25389. /** The mesh that is currently pointed at (can be null) */
  25390. meshUnderPointer: Nullable<AbstractMesh>;
  25391. /** the original (browser) event that triggered the ActionEvent */
  25392. sourceEvent?: any;
  25393. /** additional data for the event */
  25394. additionalData?: any;
  25395. /**
  25396. * Creates a new ActionEvent
  25397. * @param source The mesh or sprite that triggered the action
  25398. * @param pointerX The X mouse cursor position at the time of the event
  25399. * @param pointerY The Y mouse cursor position at the time of the event
  25400. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  25401. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  25402. * @param additionalData additional data for the event
  25403. */
  25404. constructor(
  25405. /** The mesh or sprite that triggered the action */
  25406. source: any,
  25407. /** The X mouse cursor position at the time of the event */
  25408. pointerX: number,
  25409. /** The Y mouse cursor position at the time of the event */
  25410. pointerY: number,
  25411. /** The mesh that is currently pointed at (can be null) */
  25412. meshUnderPointer: Nullable<AbstractMesh>,
  25413. /** the original (browser) event that triggered the ActionEvent */
  25414. sourceEvent?: any,
  25415. /** additional data for the event */
  25416. additionalData?: any);
  25417. /**
  25418. * Helper function to auto-create an ActionEvent from a source mesh.
  25419. * @param source The source mesh that triggered the event
  25420. * @param evt The original (browser) event
  25421. * @param additionalData additional data for the event
  25422. * @returns the new ActionEvent
  25423. */
  25424. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  25425. /**
  25426. * Helper function to auto-create an ActionEvent from a source sprite
  25427. * @param source The source sprite that triggered the event
  25428. * @param scene Scene associated with the sprite
  25429. * @param evt The original (browser) event
  25430. * @param additionalData additional data for the event
  25431. * @returns the new ActionEvent
  25432. */
  25433. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  25434. /**
  25435. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  25436. * @param scene the scene where the event occurred
  25437. * @param evt The original (browser) event
  25438. * @returns the new ActionEvent
  25439. */
  25440. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  25441. /**
  25442. * Helper function to auto-create an ActionEvent from a primitive
  25443. * @param prim defines the target primitive
  25444. * @param pointerPos defines the pointer position
  25445. * @param evt The original (browser) event
  25446. * @param additionalData additional data for the event
  25447. * @returns the new ActionEvent
  25448. */
  25449. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  25450. }
  25451. }
  25452. declare module "babylonjs/Actions/abstractActionManager" {
  25453. import { IDisposable } from "babylonjs/scene";
  25454. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  25455. import { IAction } from "babylonjs/Actions/action";
  25456. import { Nullable } from "babylonjs/types";
  25457. /**
  25458. * Abstract class used to decouple action Manager from scene and meshes.
  25459. * Do not instantiate.
  25460. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  25461. */
  25462. export abstract class AbstractActionManager implements IDisposable {
  25463. /** Gets the list of active triggers */
  25464. static Triggers: {
  25465. [key: string]: number;
  25466. };
  25467. /** Gets the cursor to use when hovering items */
  25468. hoverCursor: string;
  25469. /** Gets the list of actions */
  25470. actions: IAction[];
  25471. /**
  25472. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  25473. */
  25474. isRecursive: boolean;
  25475. /**
  25476. * Releases all associated resources
  25477. */
  25478. abstract dispose(): void;
  25479. /**
  25480. * Does this action manager has pointer triggers
  25481. */
  25482. abstract readonly hasPointerTriggers: boolean;
  25483. /**
  25484. * Does this action manager has pick triggers
  25485. */
  25486. abstract readonly hasPickTriggers: boolean;
  25487. /**
  25488. * Process a specific trigger
  25489. * @param trigger defines the trigger to process
  25490. * @param evt defines the event details to be processed
  25491. */
  25492. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  25493. /**
  25494. * Does this action manager handles actions of any of the given triggers
  25495. * @param triggers defines the triggers to be tested
  25496. * @return a boolean indicating whether one (or more) of the triggers is handled
  25497. */
  25498. abstract hasSpecificTriggers(triggers: number[]): boolean;
  25499. /**
  25500. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  25501. * speed.
  25502. * @param triggerA defines the trigger to be tested
  25503. * @param triggerB defines the trigger to be tested
  25504. * @return a boolean indicating whether one (or more) of the triggers is handled
  25505. */
  25506. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  25507. /**
  25508. * Does this action manager handles actions of a given trigger
  25509. * @param trigger defines the trigger to be tested
  25510. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  25511. * @return whether the trigger is handled
  25512. */
  25513. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  25514. /**
  25515. * Serialize this manager to a JSON object
  25516. * @param name defines the property name to store this manager
  25517. * @returns a JSON representation of this manager
  25518. */
  25519. abstract serialize(name: string): any;
  25520. /**
  25521. * Registers an action to this action manager
  25522. * @param action defines the action to be registered
  25523. * @return the action amended (prepared) after registration
  25524. */
  25525. abstract registerAction(action: IAction): Nullable<IAction>;
  25526. /**
  25527. * Unregisters an action to this action manager
  25528. * @param action defines the action to be unregistered
  25529. * @return a boolean indicating whether the action has been unregistered
  25530. */
  25531. abstract unregisterAction(action: IAction): Boolean;
  25532. /**
  25533. * Does exist one action manager with at least one trigger
  25534. **/
  25535. static readonly HasTriggers: boolean;
  25536. /**
  25537. * Does exist one action manager with at least one pick trigger
  25538. **/
  25539. static readonly HasPickTriggers: boolean;
  25540. /**
  25541. * Does exist one action manager that handles actions of a given trigger
  25542. * @param trigger defines the trigger to be tested
  25543. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  25544. **/
  25545. static HasSpecificTrigger(trigger: number): boolean;
  25546. }
  25547. }
  25548. declare module "babylonjs/node" {
  25549. import { Scene } from "babylonjs/scene";
  25550. import { Nullable } from "babylonjs/types";
  25551. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  25552. import { Engine } from "babylonjs/Engines/engine";
  25553. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  25554. import { Observable } from "babylonjs/Misc/observable";
  25555. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  25556. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25557. import { Animatable } from "babylonjs/Animations/animatable";
  25558. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  25559. import { Animation } from "babylonjs/Animations/animation";
  25560. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25561. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25562. /**
  25563. * Defines how a node can be built from a string name.
  25564. */
  25565. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  25566. /**
  25567. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  25568. */
  25569. export class Node implements IBehaviorAware<Node> {
  25570. /** @hidden */
  25571. static _AnimationRangeFactory: (name: string, from: number, to: number) => import("babylonjs/Animations/animationRange").AnimationRange;
  25572. private static _NodeConstructors;
  25573. /**
  25574. * Add a new node constructor
  25575. * @param type defines the type name of the node to construct
  25576. * @param constructorFunc defines the constructor function
  25577. */
  25578. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  25579. /**
  25580. * Returns a node constructor based on type name
  25581. * @param type defines the type name
  25582. * @param name defines the new node name
  25583. * @param scene defines the hosting scene
  25584. * @param options defines optional options to transmit to constructors
  25585. * @returns the new constructor or null
  25586. */
  25587. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  25588. /**
  25589. * Gets or sets the name of the node
  25590. */
  25591. name: string;
  25592. /**
  25593. * Gets or sets the id of the node
  25594. */
  25595. id: string;
  25596. /**
  25597. * Gets or sets the unique id of the node
  25598. */
  25599. uniqueId: number;
  25600. /**
  25601. * Gets or sets a string used to store user defined state for the node
  25602. */
  25603. state: string;
  25604. /**
  25605. * Gets or sets an object used to store user defined information for the node
  25606. */
  25607. metadata: any;
  25608. /**
  25609. * For internal use only. Please do not use.
  25610. */
  25611. reservedDataStore: any;
  25612. /**
  25613. * List of inspectable custom properties (used by the Inspector)
  25614. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25615. */
  25616. inspectableCustomProperties: IInspectable[];
  25617. /**
  25618. * Gets or sets a boolean used to define if the node must be serialized
  25619. */
  25620. doNotSerialize: boolean;
  25621. /** @hidden */
  25622. _isDisposed: boolean;
  25623. /**
  25624. * Gets a list of Animations associated with the node
  25625. */
  25626. animations: import("babylonjs/Animations/animation").Animation[];
  25627. protected _ranges: {
  25628. [name: string]: Nullable<AnimationRange>;
  25629. };
  25630. /**
  25631. * Callback raised when the node is ready to be used
  25632. */
  25633. onReady: Nullable<(node: Node) => void>;
  25634. private _isEnabled;
  25635. private _isParentEnabled;
  25636. private _isReady;
  25637. /** @hidden */
  25638. _currentRenderId: number;
  25639. private _parentUpdateId;
  25640. /** @hidden */
  25641. _childUpdateId: number;
  25642. /** @hidden */
  25643. _waitingParentId: Nullable<string>;
  25644. /** @hidden */
  25645. _scene: Scene;
  25646. /** @hidden */
  25647. _cache: any;
  25648. private _parentNode;
  25649. private _children;
  25650. /** @hidden */
  25651. _worldMatrix: Matrix;
  25652. /** @hidden */
  25653. _worldMatrixDeterminant: number;
  25654. /** @hidden */
  25655. _worldMatrixDeterminantIsDirty: boolean;
  25656. /** @hidden */
  25657. private _sceneRootNodesIndex;
  25658. /**
  25659. * Gets a boolean indicating if the node has been disposed
  25660. * @returns true if the node was disposed
  25661. */
  25662. isDisposed(): boolean;
  25663. /**
  25664. * Gets or sets the parent of the node (without keeping the current position in the scene)
  25665. * @see https://doc.babylonjs.com/how_to/parenting
  25666. */
  25667. parent: Nullable<Node>;
  25668. private addToSceneRootNodes;
  25669. private removeFromSceneRootNodes;
  25670. private _animationPropertiesOverride;
  25671. /**
  25672. * Gets or sets the animation properties override
  25673. */
  25674. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  25675. /**
  25676. * Gets a string idenfifying the name of the class
  25677. * @returns "Node" string
  25678. */
  25679. getClassName(): string;
  25680. /** @hidden */
  25681. readonly _isNode: boolean;
  25682. /**
  25683. * An event triggered when the mesh is disposed
  25684. */
  25685. onDisposeObservable: Observable<Node>;
  25686. private _onDisposeObserver;
  25687. /**
  25688. * Sets a callback that will be raised when the node will be disposed
  25689. */
  25690. onDispose: () => void;
  25691. /**
  25692. * Creates a new Node
  25693. * @param name the name and id to be given to this node
  25694. * @param scene the scene this node will be added to
  25695. * @param addToRootNodes the node will be added to scene.rootNodes
  25696. */
  25697. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  25698. /**
  25699. * Gets the scene of the node
  25700. * @returns a scene
  25701. */
  25702. getScene(): Scene;
  25703. /**
  25704. * Gets the engine of the node
  25705. * @returns a Engine
  25706. */
  25707. getEngine(): Engine;
  25708. private _behaviors;
  25709. /**
  25710. * Attach a behavior to the node
  25711. * @see http://doc.babylonjs.com/features/behaviour
  25712. * @param behavior defines the behavior to attach
  25713. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  25714. * @returns the current Node
  25715. */
  25716. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  25717. /**
  25718. * Remove an attached behavior
  25719. * @see http://doc.babylonjs.com/features/behaviour
  25720. * @param behavior defines the behavior to attach
  25721. * @returns the current Node
  25722. */
  25723. removeBehavior(behavior: Behavior<Node>): Node;
  25724. /**
  25725. * Gets the list of attached behaviors
  25726. * @see http://doc.babylonjs.com/features/behaviour
  25727. */
  25728. readonly behaviors: Behavior<Node>[];
  25729. /**
  25730. * Gets an attached behavior by name
  25731. * @param name defines the name of the behavior to look for
  25732. * @see http://doc.babylonjs.com/features/behaviour
  25733. * @returns null if behavior was not found else the requested behavior
  25734. */
  25735. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  25736. /**
  25737. * Returns the latest update of the World matrix
  25738. * @returns a Matrix
  25739. */
  25740. getWorldMatrix(): Matrix;
  25741. /** @hidden */
  25742. _getWorldMatrixDeterminant(): number;
  25743. /**
  25744. * Returns directly the latest state of the mesh World matrix.
  25745. * A Matrix is returned.
  25746. */
  25747. readonly worldMatrixFromCache: Matrix;
  25748. /** @hidden */
  25749. _initCache(): void;
  25750. /** @hidden */
  25751. updateCache(force?: boolean): void;
  25752. /** @hidden */
  25753. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  25754. /** @hidden */
  25755. _updateCache(ignoreParentClass?: boolean): void;
  25756. /** @hidden */
  25757. _isSynchronized(): boolean;
  25758. /** @hidden */
  25759. _markSyncedWithParent(): void;
  25760. /** @hidden */
  25761. isSynchronizedWithParent(): boolean;
  25762. /** @hidden */
  25763. isSynchronized(): boolean;
  25764. /**
  25765. * Is this node ready to be used/rendered
  25766. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  25767. * @return true if the node is ready
  25768. */
  25769. isReady(completeCheck?: boolean): boolean;
  25770. /**
  25771. * Is this node enabled?
  25772. * 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
  25773. * @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
  25774. * @return whether this node (and its parent) is enabled
  25775. */
  25776. isEnabled(checkAncestors?: boolean): boolean;
  25777. /** @hidden */
  25778. protected _syncParentEnabledState(): void;
  25779. /**
  25780. * Set the enabled state of this node
  25781. * @param value defines the new enabled state
  25782. */
  25783. setEnabled(value: boolean): void;
  25784. /**
  25785. * Is this node a descendant of the given node?
  25786. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  25787. * @param ancestor defines the parent node to inspect
  25788. * @returns a boolean indicating if this node is a descendant of the given node
  25789. */
  25790. isDescendantOf(ancestor: Node): boolean;
  25791. /** @hidden */
  25792. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  25793. /**
  25794. * Will return all nodes that have this node as ascendant
  25795. * @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
  25796. * @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
  25797. * @return all children nodes of all types
  25798. */
  25799. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  25800. /**
  25801. * Get all child-meshes of this node
  25802. * @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)
  25803. * @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
  25804. * @returns an array of AbstractMesh
  25805. */
  25806. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  25807. /**
  25808. * Get all direct children of this node
  25809. * @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
  25810. * @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)
  25811. * @returns an array of Node
  25812. */
  25813. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  25814. /** @hidden */
  25815. _setReady(state: boolean): void;
  25816. /**
  25817. * Get an animation by name
  25818. * @param name defines the name of the animation to look for
  25819. * @returns null if not found else the requested animation
  25820. */
  25821. getAnimationByName(name: string): Nullable<Animation>;
  25822. /**
  25823. * Creates an animation range for this node
  25824. * @param name defines the name of the range
  25825. * @param from defines the starting key
  25826. * @param to defines the end key
  25827. */
  25828. createAnimationRange(name: string, from: number, to: number): void;
  25829. /**
  25830. * Delete a specific animation range
  25831. * @param name defines the name of the range to delete
  25832. * @param deleteFrames defines if animation frames from the range must be deleted as well
  25833. */
  25834. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  25835. /**
  25836. * Get an animation range by name
  25837. * @param name defines the name of the animation range to look for
  25838. * @returns null if not found else the requested animation range
  25839. */
  25840. getAnimationRange(name: string): Nullable<AnimationRange>;
  25841. /**
  25842. * Gets the list of all animation ranges defined on this node
  25843. * @returns an array
  25844. */
  25845. getAnimationRanges(): Nullable<AnimationRange>[];
  25846. /**
  25847. * Will start the animation sequence
  25848. * @param name defines the range frames for animation sequence
  25849. * @param loop defines if the animation should loop (false by default)
  25850. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  25851. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  25852. * @returns the object created for this animation. If range does not exist, it will return null
  25853. */
  25854. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  25855. /**
  25856. * Serialize animation ranges into a JSON compatible object
  25857. * @returns serialization object
  25858. */
  25859. serializeAnimationRanges(): any;
  25860. /**
  25861. * Computes the world matrix of the node
  25862. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  25863. * @returns the world matrix
  25864. */
  25865. computeWorldMatrix(force?: boolean): Matrix;
  25866. /**
  25867. * Releases resources associated with this node.
  25868. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  25869. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  25870. */
  25871. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  25872. /**
  25873. * Parse animation range data from a serialization object and store them into a given node
  25874. * @param node defines where to store the animation ranges
  25875. * @param parsedNode defines the serialization object to read data from
  25876. * @param scene defines the hosting scene
  25877. */
  25878. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  25879. /**
  25880. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  25881. * @param includeDescendants Include bounding info from descendants as well (true by default)
  25882. * @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
  25883. * @returns the new bounding vectors
  25884. */
  25885. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  25886. min: Vector3;
  25887. max: Vector3;
  25888. };
  25889. }
  25890. }
  25891. declare module "babylonjs/Animations/animation" {
  25892. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  25893. import { Vector3, Quaternion, Vector2, Color3, Size, Matrix } from "babylonjs/Maths/math";
  25894. import { Nullable } from "babylonjs/types";
  25895. import { Scene } from "babylonjs/scene";
  25896. import { IAnimatable } from "babylonjs/Misc/tools";
  25897. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  25898. import { AnimationRange } from "babylonjs/Animations/animationRange";
  25899. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  25900. import { Node } from "babylonjs/node";
  25901. import { Animatable } from "babylonjs/Animations/animatable";
  25902. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  25903. /**
  25904. * @hidden
  25905. */
  25906. export class _IAnimationState {
  25907. key: number;
  25908. repeatCount: number;
  25909. workValue?: any;
  25910. loopMode?: number;
  25911. offsetValue?: any;
  25912. highLimitValue?: any;
  25913. }
  25914. /**
  25915. * Class used to store any kind of animation
  25916. */
  25917. export class Animation {
  25918. /**Name of the animation */
  25919. name: string;
  25920. /**Property to animate */
  25921. targetProperty: string;
  25922. /**The frames per second of the animation */
  25923. framePerSecond: number;
  25924. /**The data type of the animation */
  25925. dataType: number;
  25926. /**The loop mode of the animation */
  25927. loopMode?: number | undefined;
  25928. /**Specifies if blending should be enabled */
  25929. enableBlending?: boolean | undefined;
  25930. /**
  25931. * Use matrix interpolation instead of using direct key value when animating matrices
  25932. */
  25933. static AllowMatricesInterpolation: boolean;
  25934. /**
  25935. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  25936. */
  25937. static AllowMatrixDecomposeForInterpolation: boolean;
  25938. /**
  25939. * Stores the key frames of the animation
  25940. */
  25941. private _keys;
  25942. /**
  25943. * Stores the easing function of the animation
  25944. */
  25945. private _easingFunction;
  25946. /**
  25947. * @hidden Internal use only
  25948. */
  25949. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  25950. /**
  25951. * The set of event that will be linked to this animation
  25952. */
  25953. private _events;
  25954. /**
  25955. * Stores an array of target property paths
  25956. */
  25957. targetPropertyPath: string[];
  25958. /**
  25959. * Stores the blending speed of the animation
  25960. */
  25961. blendingSpeed: number;
  25962. /**
  25963. * Stores the animation ranges for the animation
  25964. */
  25965. private _ranges;
  25966. /**
  25967. * @hidden Internal use
  25968. */
  25969. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  25970. /**
  25971. * Sets up an animation
  25972. * @param property The property to animate
  25973. * @param animationType The animation type to apply
  25974. * @param framePerSecond The frames per second of the animation
  25975. * @param easingFunction The easing function used in the animation
  25976. * @returns The created animation
  25977. */
  25978. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  25979. /**
  25980. * Create and start an animation on a node
  25981. * @param name defines the name of the global animation that will be run on all nodes
  25982. * @param node defines the root node where the animation will take place
  25983. * @param targetProperty defines property to animate
  25984. * @param framePerSecond defines the number of frame per second yo use
  25985. * @param totalFrame defines the number of frames in total
  25986. * @param from defines the initial value
  25987. * @param to defines the final value
  25988. * @param loopMode defines which loop mode you want to use (off by default)
  25989. * @param easingFunction defines the easing function to use (linear by default)
  25990. * @param onAnimationEnd defines the callback to call when animation end
  25991. * @returns the animatable created for this animation
  25992. */
  25993. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  25994. /**
  25995. * Create and start an animation on a node and its descendants
  25996. * @param name defines the name of the global animation that will be run on all nodes
  25997. * @param node defines the root node where the animation will take place
  25998. * @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
  25999. * @param targetProperty defines property to animate
  26000. * @param framePerSecond defines the number of frame per second to use
  26001. * @param totalFrame defines the number of frames in total
  26002. * @param from defines the initial value
  26003. * @param to defines the final value
  26004. * @param loopMode defines which loop mode you want to use (off by default)
  26005. * @param easingFunction defines the easing function to use (linear by default)
  26006. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  26007. * @returns the list of animatables created for all nodes
  26008. * @example https://www.babylonjs-playground.com/#MH0VLI
  26009. */
  26010. 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[]>;
  26011. /**
  26012. * Creates a new animation, merges it with the existing animations and starts it
  26013. * @param name Name of the animation
  26014. * @param node Node which contains the scene that begins the animations
  26015. * @param targetProperty Specifies which property to animate
  26016. * @param framePerSecond The frames per second of the animation
  26017. * @param totalFrame The total number of frames
  26018. * @param from The frame at the beginning of the animation
  26019. * @param to The frame at the end of the animation
  26020. * @param loopMode Specifies the loop mode of the animation
  26021. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  26022. * @param onAnimationEnd Callback to run once the animation is complete
  26023. * @returns Nullable animation
  26024. */
  26025. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  26026. /**
  26027. * Transition property of an host to the target Value
  26028. * @param property The property to transition
  26029. * @param targetValue The target Value of the property
  26030. * @param host The object where the property to animate belongs
  26031. * @param scene Scene used to run the animation
  26032. * @param frameRate Framerate (in frame/s) to use
  26033. * @param transition The transition type we want to use
  26034. * @param duration The duration of the animation, in milliseconds
  26035. * @param onAnimationEnd Callback trigger at the end of the animation
  26036. * @returns Nullable animation
  26037. */
  26038. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  26039. /**
  26040. * Return the array of runtime animations currently using this animation
  26041. */
  26042. readonly runtimeAnimations: RuntimeAnimation[];
  26043. /**
  26044. * Specifies if any of the runtime animations are currently running
  26045. */
  26046. readonly hasRunningRuntimeAnimations: boolean;
  26047. /**
  26048. * Initializes the animation
  26049. * @param name Name of the animation
  26050. * @param targetProperty Property to animate
  26051. * @param framePerSecond The frames per second of the animation
  26052. * @param dataType The data type of the animation
  26053. * @param loopMode The loop mode of the animation
  26054. * @param enableBlending Specifies if blending should be enabled
  26055. */
  26056. constructor(
  26057. /**Name of the animation */
  26058. name: string,
  26059. /**Property to animate */
  26060. targetProperty: string,
  26061. /**The frames per second of the animation */
  26062. framePerSecond: number,
  26063. /**The data type of the animation */
  26064. dataType: number,
  26065. /**The loop mode of the animation */
  26066. loopMode?: number | undefined,
  26067. /**Specifies if blending should be enabled */
  26068. enableBlending?: boolean | undefined);
  26069. /**
  26070. * Converts the animation to a string
  26071. * @param fullDetails support for multiple levels of logging within scene loading
  26072. * @returns String form of the animation
  26073. */
  26074. toString(fullDetails?: boolean): string;
  26075. /**
  26076. * Add an event to this animation
  26077. * @param event Event to add
  26078. */
  26079. addEvent(event: AnimationEvent): void;
  26080. /**
  26081. * Remove all events found at the given frame
  26082. * @param frame The frame to remove events from
  26083. */
  26084. removeEvents(frame: number): void;
  26085. /**
  26086. * Retrieves all the events from the animation
  26087. * @returns Events from the animation
  26088. */
  26089. getEvents(): AnimationEvent[];
  26090. /**
  26091. * Creates an animation range
  26092. * @param name Name of the animation range
  26093. * @param from Starting frame of the animation range
  26094. * @param to Ending frame of the animation
  26095. */
  26096. createRange(name: string, from: number, to: number): void;
  26097. /**
  26098. * Deletes an animation range by name
  26099. * @param name Name of the animation range to delete
  26100. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  26101. */
  26102. deleteRange(name: string, deleteFrames?: boolean): void;
  26103. /**
  26104. * Gets the animation range by name, or null if not defined
  26105. * @param name Name of the animation range
  26106. * @returns Nullable animation range
  26107. */
  26108. getRange(name: string): Nullable<AnimationRange>;
  26109. /**
  26110. * Gets the key frames from the animation
  26111. * @returns The key frames of the animation
  26112. */
  26113. getKeys(): Array<IAnimationKey>;
  26114. /**
  26115. * Gets the highest frame rate of the animation
  26116. * @returns Highest frame rate of the animation
  26117. */
  26118. getHighestFrame(): number;
  26119. /**
  26120. * Gets the easing function of the animation
  26121. * @returns Easing function of the animation
  26122. */
  26123. getEasingFunction(): IEasingFunction;
  26124. /**
  26125. * Sets the easing function of the animation
  26126. * @param easingFunction A custom mathematical formula for animation
  26127. */
  26128. setEasingFunction(easingFunction: EasingFunction): void;
  26129. /**
  26130. * Interpolates a scalar linearly
  26131. * @param startValue Start value of the animation curve
  26132. * @param endValue End value of the animation curve
  26133. * @param gradient Scalar amount to interpolate
  26134. * @returns Interpolated scalar value
  26135. */
  26136. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  26137. /**
  26138. * Interpolates a scalar cubically
  26139. * @param startValue Start value of the animation curve
  26140. * @param outTangent End tangent of the animation
  26141. * @param endValue End value of the animation curve
  26142. * @param inTangent Start tangent of the animation curve
  26143. * @param gradient Scalar amount to interpolate
  26144. * @returns Interpolated scalar value
  26145. */
  26146. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  26147. /**
  26148. * Interpolates a quaternion using a spherical linear interpolation
  26149. * @param startValue Start value of the animation curve
  26150. * @param endValue End value of the animation curve
  26151. * @param gradient Scalar amount to interpolate
  26152. * @returns Interpolated quaternion value
  26153. */
  26154. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  26155. /**
  26156. * Interpolates a quaternion cubically
  26157. * @param startValue Start value of the animation curve
  26158. * @param outTangent End tangent of the animation curve
  26159. * @param endValue End value of the animation curve
  26160. * @param inTangent Start tangent of the animation curve
  26161. * @param gradient Scalar amount to interpolate
  26162. * @returns Interpolated quaternion value
  26163. */
  26164. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  26165. /**
  26166. * Interpolates a Vector3 linearl
  26167. * @param startValue Start value of the animation curve
  26168. * @param endValue End value of the animation curve
  26169. * @param gradient Scalar amount to interpolate
  26170. * @returns Interpolated scalar value
  26171. */
  26172. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  26173. /**
  26174. * Interpolates a Vector3 cubically
  26175. * @param startValue Start value of the animation curve
  26176. * @param outTangent End tangent of the animation
  26177. * @param endValue End value of the animation curve
  26178. * @param inTangent Start tangent of the animation curve
  26179. * @param gradient Scalar amount to interpolate
  26180. * @returns InterpolatedVector3 value
  26181. */
  26182. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  26183. /**
  26184. * Interpolates a Vector2 linearly
  26185. * @param startValue Start value of the animation curve
  26186. * @param endValue End value of the animation curve
  26187. * @param gradient Scalar amount to interpolate
  26188. * @returns Interpolated Vector2 value
  26189. */
  26190. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  26191. /**
  26192. * Interpolates a Vector2 cubically
  26193. * @param startValue Start value of the animation curve
  26194. * @param outTangent End tangent of the animation
  26195. * @param endValue End value of the animation curve
  26196. * @param inTangent Start tangent of the animation curve
  26197. * @param gradient Scalar amount to interpolate
  26198. * @returns Interpolated Vector2 value
  26199. */
  26200. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  26201. /**
  26202. * Interpolates a size linearly
  26203. * @param startValue Start value of the animation curve
  26204. * @param endValue End value of the animation curve
  26205. * @param gradient Scalar amount to interpolate
  26206. * @returns Interpolated Size value
  26207. */
  26208. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  26209. /**
  26210. * Interpolates a Color3 linearly
  26211. * @param startValue Start value of the animation curve
  26212. * @param endValue End value of the animation curve
  26213. * @param gradient Scalar amount to interpolate
  26214. * @returns Interpolated Color3 value
  26215. */
  26216. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  26217. /**
  26218. * @hidden Internal use only
  26219. */
  26220. _getKeyValue(value: any): any;
  26221. /**
  26222. * @hidden Internal use only
  26223. */
  26224. _interpolate(currentFrame: number, state: _IAnimationState): any;
  26225. /**
  26226. * Defines the function to use to interpolate matrices
  26227. * @param startValue defines the start matrix
  26228. * @param endValue defines the end matrix
  26229. * @param gradient defines the gradient between both matrices
  26230. * @param result defines an optional target matrix where to store the interpolation
  26231. * @returns the interpolated matrix
  26232. */
  26233. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  26234. /**
  26235. * Makes a copy of the animation
  26236. * @returns Cloned animation
  26237. */
  26238. clone(): Animation;
  26239. /**
  26240. * Sets the key frames of the animation
  26241. * @param values The animation key frames to set
  26242. */
  26243. setKeys(values: Array<IAnimationKey>): void;
  26244. /**
  26245. * Serializes the animation to an object
  26246. * @returns Serialized object
  26247. */
  26248. serialize(): any;
  26249. /**
  26250. * Float animation type
  26251. */
  26252. private static _ANIMATIONTYPE_FLOAT;
  26253. /**
  26254. * Vector3 animation type
  26255. */
  26256. private static _ANIMATIONTYPE_VECTOR3;
  26257. /**
  26258. * Quaternion animation type
  26259. */
  26260. private static _ANIMATIONTYPE_QUATERNION;
  26261. /**
  26262. * Matrix animation type
  26263. */
  26264. private static _ANIMATIONTYPE_MATRIX;
  26265. /**
  26266. * Color3 animation type
  26267. */
  26268. private static _ANIMATIONTYPE_COLOR3;
  26269. /**
  26270. * Vector2 animation type
  26271. */
  26272. private static _ANIMATIONTYPE_VECTOR2;
  26273. /**
  26274. * Size animation type
  26275. */
  26276. private static _ANIMATIONTYPE_SIZE;
  26277. /**
  26278. * Relative Loop Mode
  26279. */
  26280. private static _ANIMATIONLOOPMODE_RELATIVE;
  26281. /**
  26282. * Cycle Loop Mode
  26283. */
  26284. private static _ANIMATIONLOOPMODE_CYCLE;
  26285. /**
  26286. * Constant Loop Mode
  26287. */
  26288. private static _ANIMATIONLOOPMODE_CONSTANT;
  26289. /**
  26290. * Get the float animation type
  26291. */
  26292. static readonly ANIMATIONTYPE_FLOAT: number;
  26293. /**
  26294. * Get the Vector3 animation type
  26295. */
  26296. static readonly ANIMATIONTYPE_VECTOR3: number;
  26297. /**
  26298. * Get the Vector2 animation type
  26299. */
  26300. static readonly ANIMATIONTYPE_VECTOR2: number;
  26301. /**
  26302. * Get the Size animation type
  26303. */
  26304. static readonly ANIMATIONTYPE_SIZE: number;
  26305. /**
  26306. * Get the Quaternion animation type
  26307. */
  26308. static readonly ANIMATIONTYPE_QUATERNION: number;
  26309. /**
  26310. * Get the Matrix animation type
  26311. */
  26312. static readonly ANIMATIONTYPE_MATRIX: number;
  26313. /**
  26314. * Get the Color3 animation type
  26315. */
  26316. static readonly ANIMATIONTYPE_COLOR3: number;
  26317. /**
  26318. * Get the Relative Loop Mode
  26319. */
  26320. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  26321. /**
  26322. * Get the Cycle Loop Mode
  26323. */
  26324. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  26325. /**
  26326. * Get the Constant Loop Mode
  26327. */
  26328. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  26329. /** @hidden */
  26330. static _UniversalLerp(left: any, right: any, amount: number): any;
  26331. /**
  26332. * Parses an animation object and creates an animation
  26333. * @param parsedAnimation Parsed animation object
  26334. * @returns Animation object
  26335. */
  26336. static Parse(parsedAnimation: any): Animation;
  26337. /**
  26338. * Appends the serialized animations from the source animations
  26339. * @param source Source containing the animations
  26340. * @param destination Target to store the animations
  26341. */
  26342. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  26343. }
  26344. }
  26345. declare module "babylonjs/Materials/Textures/baseTexture" {
  26346. import { Observable } from "babylonjs/Misc/observable";
  26347. import { IAnimatable } from "babylonjs/Misc/tools";
  26348. import { Nullable } from "babylonjs/types";
  26349. import { Scene } from "babylonjs/scene";
  26350. import { Matrix, ISize } from "babylonjs/Maths/math";
  26351. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  26352. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26353. /**
  26354. * Base class of all the textures in babylon.
  26355. * It groups all the common properties the materials, post process, lights... might need
  26356. * in order to make a correct use of the texture.
  26357. */
  26358. export class BaseTexture implements IAnimatable {
  26359. /**
  26360. * Default anisotropic filtering level for the application.
  26361. * It is set to 4 as a good tradeoff between perf and quality.
  26362. */
  26363. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  26364. /**
  26365. * Gets or sets the unique id of the texture
  26366. */
  26367. uniqueId: number;
  26368. /**
  26369. * Define the name of the texture.
  26370. */
  26371. name: string;
  26372. /**
  26373. * Gets or sets an object used to store user defined information.
  26374. */
  26375. metadata: any;
  26376. /**
  26377. * For internal use only. Please do not use.
  26378. */
  26379. reservedDataStore: any;
  26380. private _hasAlpha;
  26381. /**
  26382. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  26383. */
  26384. hasAlpha: boolean;
  26385. /**
  26386. * Defines if the alpha value should be determined via the rgb values.
  26387. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  26388. */
  26389. getAlphaFromRGB: boolean;
  26390. /**
  26391. * Intensity or strength of the texture.
  26392. * It is commonly used by materials to fine tune the intensity of the texture
  26393. */
  26394. level: number;
  26395. /**
  26396. * Define the UV chanel to use starting from 0 and defaulting to 0.
  26397. * This is part of the texture as textures usually maps to one uv set.
  26398. */
  26399. coordinatesIndex: number;
  26400. private _coordinatesMode;
  26401. /**
  26402. * How a texture is mapped.
  26403. *
  26404. * | Value | Type | Description |
  26405. * | ----- | ----------------------------------- | ----------- |
  26406. * | 0 | EXPLICIT_MODE | |
  26407. * | 1 | SPHERICAL_MODE | |
  26408. * | 2 | PLANAR_MODE | |
  26409. * | 3 | CUBIC_MODE | |
  26410. * | 4 | PROJECTION_MODE | |
  26411. * | 5 | SKYBOX_MODE | |
  26412. * | 6 | INVCUBIC_MODE | |
  26413. * | 7 | EQUIRECTANGULAR_MODE | |
  26414. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  26415. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  26416. */
  26417. coordinatesMode: number;
  26418. /**
  26419. * | Value | Type | Description |
  26420. * | ----- | ------------------ | ----------- |
  26421. * | 0 | CLAMP_ADDRESSMODE | |
  26422. * | 1 | WRAP_ADDRESSMODE | |
  26423. * | 2 | MIRROR_ADDRESSMODE | |
  26424. */
  26425. wrapU: number;
  26426. /**
  26427. * | Value | Type | Description |
  26428. * | ----- | ------------------ | ----------- |
  26429. * | 0 | CLAMP_ADDRESSMODE | |
  26430. * | 1 | WRAP_ADDRESSMODE | |
  26431. * | 2 | MIRROR_ADDRESSMODE | |
  26432. */
  26433. wrapV: number;
  26434. /**
  26435. * | Value | Type | Description |
  26436. * | ----- | ------------------ | ----------- |
  26437. * | 0 | CLAMP_ADDRESSMODE | |
  26438. * | 1 | WRAP_ADDRESSMODE | |
  26439. * | 2 | MIRROR_ADDRESSMODE | |
  26440. */
  26441. wrapR: number;
  26442. /**
  26443. * With compliant hardware and browser (supporting anisotropic filtering)
  26444. * this defines the level of anisotropic filtering in the texture.
  26445. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  26446. */
  26447. anisotropicFilteringLevel: number;
  26448. /**
  26449. * Define if the texture is a cube texture or if false a 2d texture.
  26450. */
  26451. isCube: boolean;
  26452. /**
  26453. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  26454. */
  26455. is3D: boolean;
  26456. /**
  26457. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  26458. * HDR texture are usually stored in linear space.
  26459. * This only impacts the PBR and Background materials
  26460. */
  26461. gammaSpace: boolean;
  26462. /**
  26463. * Gets whether or not the texture contains RGBD data.
  26464. */
  26465. readonly isRGBD: boolean;
  26466. /**
  26467. * Is Z inverted in the texture (useful in a cube texture).
  26468. */
  26469. invertZ: boolean;
  26470. /**
  26471. * Are mip maps generated for this texture or not.
  26472. */
  26473. readonly noMipmap: boolean;
  26474. /**
  26475. * @hidden
  26476. */
  26477. lodLevelInAlpha: boolean;
  26478. /**
  26479. * With prefiltered texture, defined the offset used during the prefiltering steps.
  26480. */
  26481. lodGenerationOffset: number;
  26482. /**
  26483. * With prefiltered texture, defined the scale used during the prefiltering steps.
  26484. */
  26485. lodGenerationScale: number;
  26486. /**
  26487. * Define if the texture is a render target.
  26488. */
  26489. isRenderTarget: boolean;
  26490. /**
  26491. * Define the unique id of the texture in the scene.
  26492. */
  26493. readonly uid: string;
  26494. /**
  26495. * Return a string representation of the texture.
  26496. * @returns the texture as a string
  26497. */
  26498. toString(): string;
  26499. /**
  26500. * Get the class name of the texture.
  26501. * @returns "BaseTexture"
  26502. */
  26503. getClassName(): string;
  26504. /**
  26505. * Define the list of animation attached to the texture.
  26506. */
  26507. animations: import("babylonjs/Animations/animation").Animation[];
  26508. /**
  26509. * An event triggered when the texture is disposed.
  26510. */
  26511. onDisposeObservable: Observable<BaseTexture>;
  26512. private _onDisposeObserver;
  26513. /**
  26514. * Callback triggered when the texture has been disposed.
  26515. * Kept for back compatibility, you can use the onDisposeObservable instead.
  26516. */
  26517. onDispose: () => void;
  26518. /**
  26519. * Define the current state of the loading sequence when in delayed load mode.
  26520. */
  26521. delayLoadState: number;
  26522. private _scene;
  26523. /** @hidden */
  26524. _texture: Nullable<InternalTexture>;
  26525. private _uid;
  26526. /**
  26527. * Define if the texture is preventinga material to render or not.
  26528. * If not and the texture is not ready, the engine will use a default black texture instead.
  26529. */
  26530. readonly isBlocking: boolean;
  26531. /**
  26532. * Instantiates a new BaseTexture.
  26533. * Base class of all the textures in babylon.
  26534. * It groups all the common properties the materials, post process, lights... might need
  26535. * in order to make a correct use of the texture.
  26536. * @param scene Define the scene the texture blongs to
  26537. */
  26538. constructor(scene: Nullable<Scene>);
  26539. /**
  26540. * Get the scene the texture belongs to.
  26541. * @returns the scene or null if undefined
  26542. */
  26543. getScene(): Nullable<Scene>;
  26544. /**
  26545. * Get the texture transform matrix used to offset tile the texture for istance.
  26546. * @returns the transformation matrix
  26547. */
  26548. getTextureMatrix(): Matrix;
  26549. /**
  26550. * Get the texture reflection matrix used to rotate/transform the reflection.
  26551. * @returns the reflection matrix
  26552. */
  26553. getReflectionTextureMatrix(): Matrix;
  26554. /**
  26555. * Get the underlying lower level texture from Babylon.
  26556. * @returns the insternal texture
  26557. */
  26558. getInternalTexture(): Nullable<InternalTexture>;
  26559. /**
  26560. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  26561. * @returns true if ready or not blocking
  26562. */
  26563. isReadyOrNotBlocking(): boolean;
  26564. /**
  26565. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  26566. * @returns true if fully ready
  26567. */
  26568. isReady(): boolean;
  26569. private _cachedSize;
  26570. /**
  26571. * Get the size of the texture.
  26572. * @returns the texture size.
  26573. */
  26574. getSize(): ISize;
  26575. /**
  26576. * Get the base size of the texture.
  26577. * It can be different from the size if the texture has been resized for POT for instance
  26578. * @returns the base size
  26579. */
  26580. getBaseSize(): ISize;
  26581. /**
  26582. * Update the sampling mode of the texture.
  26583. * Default is Trilinear mode.
  26584. *
  26585. * | Value | Type | Description |
  26586. * | ----- | ------------------ | ----------- |
  26587. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  26588. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  26589. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  26590. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  26591. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  26592. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  26593. * | 7 | NEAREST_LINEAR | |
  26594. * | 8 | NEAREST_NEAREST | |
  26595. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  26596. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  26597. * | 11 | LINEAR_LINEAR | |
  26598. * | 12 | LINEAR_NEAREST | |
  26599. *
  26600. * > _mag_: magnification filter (close to the viewer)
  26601. * > _min_: minification filter (far from the viewer)
  26602. * > _mip_: filter used between mip map levels
  26603. *@param samplingMode Define the new sampling mode of the texture
  26604. */
  26605. updateSamplingMode(samplingMode: number): void;
  26606. /**
  26607. * Scales the texture if is `canRescale()`
  26608. * @param ratio the resize factor we want to use to rescale
  26609. */
  26610. scale(ratio: number): void;
  26611. /**
  26612. * Get if the texture can rescale.
  26613. */
  26614. readonly canRescale: boolean;
  26615. /** @hidden */
  26616. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  26617. /** @hidden */
  26618. _rebuild(): void;
  26619. /**
  26620. * Triggers the load sequence in delayed load mode.
  26621. */
  26622. delayLoad(): void;
  26623. /**
  26624. * Clones the texture.
  26625. * @returns the cloned texture
  26626. */
  26627. clone(): Nullable<BaseTexture>;
  26628. /**
  26629. * Get the texture underlying type (INT, FLOAT...)
  26630. */
  26631. readonly textureType: number;
  26632. /**
  26633. * Get the texture underlying format (RGB, RGBA...)
  26634. */
  26635. readonly textureFormat: number;
  26636. /**
  26637. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  26638. * This will returns an RGBA array buffer containing either in values (0-255) or
  26639. * float values (0-1) depending of the underlying buffer type.
  26640. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  26641. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  26642. * @param buffer defines a user defined buffer to fill with data (can be null)
  26643. * @returns The Array buffer containing the pixels data.
  26644. */
  26645. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  26646. /**
  26647. * Release and destroy the underlying lower level texture aka internalTexture.
  26648. */
  26649. releaseInternalTexture(): void;
  26650. /**
  26651. * Get the polynomial representation of the texture data.
  26652. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  26653. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  26654. */
  26655. sphericalPolynomial: Nullable<SphericalPolynomial>;
  26656. /** @hidden */
  26657. readonly _lodTextureHigh: Nullable<BaseTexture>;
  26658. /** @hidden */
  26659. readonly _lodTextureMid: Nullable<BaseTexture>;
  26660. /** @hidden */
  26661. readonly _lodTextureLow: Nullable<BaseTexture>;
  26662. /**
  26663. * Dispose the texture and release its associated resources.
  26664. */
  26665. dispose(): void;
  26666. /**
  26667. * Serialize the texture into a JSON representation that can be parsed later on.
  26668. * @returns the JSON representation of the texture
  26669. */
  26670. serialize(): any;
  26671. /**
  26672. * Helper function to be called back once a list of texture contains only ready textures.
  26673. * @param textures Define the list of textures to wait for
  26674. * @param callback Define the callback triggered once the entire list will be ready
  26675. */
  26676. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  26677. }
  26678. }
  26679. declare module "babylonjs/Materials/uniformBuffer" {
  26680. import { Nullable, FloatArray } from "babylonjs/types";
  26681. import { Matrix, Vector3, Color3, Vector4 } from "babylonjs/Maths/math";
  26682. import { Engine } from "babylonjs/Engines/engine";
  26683. import { Effect } from "babylonjs/Materials/effect";
  26684. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26685. /**
  26686. * Uniform buffer objects.
  26687. *
  26688. * Handles blocks of uniform on the GPU.
  26689. *
  26690. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26691. *
  26692. * For more information, please refer to :
  26693. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26694. */
  26695. export class UniformBuffer {
  26696. private _engine;
  26697. private _buffer;
  26698. private _data;
  26699. private _bufferData;
  26700. private _dynamic?;
  26701. private _uniformLocations;
  26702. private _uniformSizes;
  26703. private _uniformLocationPointer;
  26704. private _needSync;
  26705. private _noUBO;
  26706. private _currentEffect;
  26707. private static _MAX_UNIFORM_SIZE;
  26708. private static _tempBuffer;
  26709. /**
  26710. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  26711. * This is dynamic to allow compat with webgl 1 and 2.
  26712. * You will need to pass the name of the uniform as well as the value.
  26713. */
  26714. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  26715. /**
  26716. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  26717. * This is dynamic to allow compat with webgl 1 and 2.
  26718. * You will need to pass the name of the uniform as well as the value.
  26719. */
  26720. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  26721. /**
  26722. * Lambda to Update a single float in a uniform buffer.
  26723. * This is dynamic to allow compat with webgl 1 and 2.
  26724. * You will need to pass the name of the uniform as well as the value.
  26725. */
  26726. updateFloat: (name: string, x: number) => void;
  26727. /**
  26728. * Lambda to Update a vec2 of float in a uniform buffer.
  26729. * This is dynamic to allow compat with webgl 1 and 2.
  26730. * You will need to pass the name of the uniform as well as the value.
  26731. */
  26732. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  26733. /**
  26734. * Lambda to Update a vec3 of float in a uniform buffer.
  26735. * This is dynamic to allow compat with webgl 1 and 2.
  26736. * You will need to pass the name of the uniform as well as the value.
  26737. */
  26738. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  26739. /**
  26740. * Lambda to Update a vec4 of float in a uniform buffer.
  26741. * This is dynamic to allow compat with webgl 1 and 2.
  26742. * You will need to pass the name of the uniform as well as the value.
  26743. */
  26744. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  26745. /**
  26746. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  26747. * This is dynamic to allow compat with webgl 1 and 2.
  26748. * You will need to pass the name of the uniform as well as the value.
  26749. */
  26750. updateMatrix: (name: string, mat: Matrix) => void;
  26751. /**
  26752. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  26753. * This is dynamic to allow compat with webgl 1 and 2.
  26754. * You will need to pass the name of the uniform as well as the value.
  26755. */
  26756. updateVector3: (name: string, vector: Vector3) => void;
  26757. /**
  26758. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  26759. * This is dynamic to allow compat with webgl 1 and 2.
  26760. * You will need to pass the name of the uniform as well as the value.
  26761. */
  26762. updateVector4: (name: string, vector: Vector4) => void;
  26763. /**
  26764. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  26765. * This is dynamic to allow compat with webgl 1 and 2.
  26766. * You will need to pass the name of the uniform as well as the value.
  26767. */
  26768. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  26769. /**
  26770. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  26771. * This is dynamic to allow compat with webgl 1 and 2.
  26772. * You will need to pass the name of the uniform as well as the value.
  26773. */
  26774. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  26775. /**
  26776. * Instantiates a new Uniform buffer objects.
  26777. *
  26778. * Handles blocks of uniform on the GPU.
  26779. *
  26780. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  26781. *
  26782. * For more information, please refer to :
  26783. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  26784. * @param engine Define the engine the buffer is associated with
  26785. * @param data Define the data contained in the buffer
  26786. * @param dynamic Define if the buffer is updatable
  26787. */
  26788. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  26789. /**
  26790. * Indicates if the buffer is using the WebGL2 UBO implementation,
  26791. * or just falling back on setUniformXXX calls.
  26792. */
  26793. readonly useUbo: boolean;
  26794. /**
  26795. * Indicates if the WebGL underlying uniform buffer is in sync
  26796. * with the javascript cache data.
  26797. */
  26798. readonly isSync: boolean;
  26799. /**
  26800. * Indicates if the WebGL underlying uniform buffer is dynamic.
  26801. * Also, a dynamic UniformBuffer will disable cache verification and always
  26802. * update the underlying WebGL uniform buffer to the GPU.
  26803. * @returns if Dynamic, otherwise false
  26804. */
  26805. isDynamic(): boolean;
  26806. /**
  26807. * The data cache on JS side.
  26808. * @returns the underlying data as a float array
  26809. */
  26810. getData(): Float32Array;
  26811. /**
  26812. * The underlying WebGL Uniform buffer.
  26813. * @returns the webgl buffer
  26814. */
  26815. getBuffer(): Nullable<WebGLBuffer>;
  26816. /**
  26817. * std140 layout specifies how to align data within an UBO structure.
  26818. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  26819. * for specs.
  26820. */
  26821. private _fillAlignment;
  26822. /**
  26823. * Adds an uniform in the buffer.
  26824. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  26825. * for the layout to be correct !
  26826. * @param name Name of the uniform, as used in the uniform block in the shader.
  26827. * @param size Data size, or data directly.
  26828. */
  26829. addUniform(name: string, size: number | number[]): void;
  26830. /**
  26831. * Adds a Matrix 4x4 to the uniform buffer.
  26832. * @param name Name of the uniform, as used in the uniform block in the shader.
  26833. * @param mat A 4x4 matrix.
  26834. */
  26835. addMatrix(name: string, mat: Matrix): void;
  26836. /**
  26837. * Adds a vec2 to the uniform buffer.
  26838. * @param name Name of the uniform, as used in the uniform block in the shader.
  26839. * @param x Define the x component value of the vec2
  26840. * @param y Define the y component value of the vec2
  26841. */
  26842. addFloat2(name: string, x: number, y: number): void;
  26843. /**
  26844. * Adds a vec3 to the uniform buffer.
  26845. * @param name Name of the uniform, as used in the uniform block in the shader.
  26846. * @param x Define the x component value of the vec3
  26847. * @param y Define the y component value of the vec3
  26848. * @param z Define the z component value of the vec3
  26849. */
  26850. addFloat3(name: string, x: number, y: number, z: number): void;
  26851. /**
  26852. * Adds a vec3 to the uniform buffer.
  26853. * @param name Name of the uniform, as used in the uniform block in the shader.
  26854. * @param color Define the vec3 from a Color
  26855. */
  26856. addColor3(name: string, color: Color3): void;
  26857. /**
  26858. * Adds a vec4 to the uniform buffer.
  26859. * @param name Name of the uniform, as used in the uniform block in the shader.
  26860. * @param color Define the rgb components from a Color
  26861. * @param alpha Define the a component of the vec4
  26862. */
  26863. addColor4(name: string, color: Color3, alpha: number): void;
  26864. /**
  26865. * Adds a vec3 to the uniform buffer.
  26866. * @param name Name of the uniform, as used in the uniform block in the shader.
  26867. * @param vector Define the vec3 components from a Vector
  26868. */
  26869. addVector3(name: string, vector: Vector3): void;
  26870. /**
  26871. * Adds a Matrix 3x3 to the uniform buffer.
  26872. * @param name Name of the uniform, as used in the uniform block in the shader.
  26873. */
  26874. addMatrix3x3(name: string): void;
  26875. /**
  26876. * Adds a Matrix 2x2 to the uniform buffer.
  26877. * @param name Name of the uniform, as used in the uniform block in the shader.
  26878. */
  26879. addMatrix2x2(name: string): void;
  26880. /**
  26881. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  26882. */
  26883. create(): void;
  26884. /** @hidden */
  26885. _rebuild(): void;
  26886. /**
  26887. * Updates the WebGL Uniform Buffer on the GPU.
  26888. * If the `dynamic` flag is set to true, no cache comparison is done.
  26889. * Otherwise, the buffer will be updated only if the cache differs.
  26890. */
  26891. update(): void;
  26892. /**
  26893. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  26894. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26895. * @param data Define the flattened data
  26896. * @param size Define the size of the data.
  26897. */
  26898. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  26899. private _updateMatrix3x3ForUniform;
  26900. private _updateMatrix3x3ForEffect;
  26901. private _updateMatrix2x2ForEffect;
  26902. private _updateMatrix2x2ForUniform;
  26903. private _updateFloatForEffect;
  26904. private _updateFloatForUniform;
  26905. private _updateFloat2ForEffect;
  26906. private _updateFloat2ForUniform;
  26907. private _updateFloat3ForEffect;
  26908. private _updateFloat3ForUniform;
  26909. private _updateFloat4ForEffect;
  26910. private _updateFloat4ForUniform;
  26911. private _updateMatrixForEffect;
  26912. private _updateMatrixForUniform;
  26913. private _updateVector3ForEffect;
  26914. private _updateVector3ForUniform;
  26915. private _updateVector4ForEffect;
  26916. private _updateVector4ForUniform;
  26917. private _updateColor3ForEffect;
  26918. private _updateColor3ForUniform;
  26919. private _updateColor4ForEffect;
  26920. private _updateColor4ForUniform;
  26921. /**
  26922. * Sets a sampler uniform on the effect.
  26923. * @param name Define the name of the sampler.
  26924. * @param texture Define the texture to set in the sampler
  26925. */
  26926. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  26927. /**
  26928. * Directly updates the value of the uniform in the cache AND on the GPU.
  26929. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  26930. * @param data Define the flattened data
  26931. */
  26932. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  26933. /**
  26934. * Binds this uniform buffer to an effect.
  26935. * @param effect Define the effect to bind the buffer to
  26936. * @param name Name of the uniform block in the shader.
  26937. */
  26938. bindToEffect(effect: Effect, name: string): void;
  26939. /**
  26940. * Disposes the uniform buffer.
  26941. */
  26942. dispose(): void;
  26943. }
  26944. }
  26945. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  26946. import { Nullable } from "babylonjs/types";
  26947. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  26948. /**
  26949. * This represents the required contract to create a new type of texture loader.
  26950. */
  26951. export interface IInternalTextureLoader {
  26952. /**
  26953. * Defines wether the loader supports cascade loading the different faces.
  26954. */
  26955. supportCascades: boolean;
  26956. /**
  26957. * This returns if the loader support the current file information.
  26958. * @param extension defines the file extension of the file being loaded
  26959. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26960. * @param fallback defines the fallback internal texture if any
  26961. * @param isBase64 defines whether the texture is encoded as a base64
  26962. * @param isBuffer defines whether the texture data are stored as a buffer
  26963. * @returns true if the loader can load the specified file
  26964. */
  26965. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  26966. /**
  26967. * Transform the url before loading if required.
  26968. * @param rootUrl the url of the texture
  26969. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26970. * @returns the transformed texture
  26971. */
  26972. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  26973. /**
  26974. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  26975. * @param rootUrl the url of the texture
  26976. * @param textureFormatInUse defines the current compressed format in use iun the engine
  26977. * @returns the fallback texture
  26978. */
  26979. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  26980. /**
  26981. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  26982. * @param data contains the texture data
  26983. * @param texture defines the BabylonJS internal texture
  26984. * @param createPolynomials will be true if polynomials have been requested
  26985. * @param onLoad defines the callback to trigger once the texture is ready
  26986. * @param onError defines the callback to trigger in case of error
  26987. */
  26988. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  26989. /**
  26990. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  26991. * @param data contains the texture data
  26992. * @param texture defines the BabylonJS internal texture
  26993. * @param callback defines the method to call once ready to upload
  26994. */
  26995. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  26996. }
  26997. }
  26998. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  26999. import { Scene } from "babylonjs/scene";
  27000. import { Engine } from "babylonjs/Engines/engine";
  27001. import { Texture } from "babylonjs/Materials/Textures/texture";
  27002. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27003. /**
  27004. * Creation options of the multi render target texture.
  27005. */
  27006. export interface IMultiRenderTargetOptions {
  27007. /**
  27008. * Define if the texture needs to create mip maps after render.
  27009. */
  27010. generateMipMaps?: boolean;
  27011. /**
  27012. * Define the types of all the draw buffers we want to create
  27013. */
  27014. types?: number[];
  27015. /**
  27016. * Define the sampling modes of all the draw buffers we want to create
  27017. */
  27018. samplingModes?: number[];
  27019. /**
  27020. * Define if a depth buffer is required
  27021. */
  27022. generateDepthBuffer?: boolean;
  27023. /**
  27024. * Define if a stencil buffer is required
  27025. */
  27026. generateStencilBuffer?: boolean;
  27027. /**
  27028. * Define if a depth texture is required instead of a depth buffer
  27029. */
  27030. generateDepthTexture?: boolean;
  27031. /**
  27032. * Define the number of desired draw buffers
  27033. */
  27034. textureCount?: number;
  27035. /**
  27036. * Define if aspect ratio should be adapted to the texture or stay the scene one
  27037. */
  27038. doNotChangeAspectRatio?: boolean;
  27039. /**
  27040. * Define the default type of the buffers we are creating
  27041. */
  27042. defaultType?: number;
  27043. }
  27044. /**
  27045. * A multi render target, like a render target provides the ability to render to a texture.
  27046. * Unlike the render target, it can render to several draw buffers in one draw.
  27047. * This is specially interesting in deferred rendering or for any effects requiring more than
  27048. * just one color from a single pass.
  27049. */
  27050. export class MultiRenderTarget extends RenderTargetTexture {
  27051. private _internalTextures;
  27052. private _textures;
  27053. private _multiRenderTargetOptions;
  27054. /**
  27055. * Get if draw buffers are currently supported by the used hardware and browser.
  27056. */
  27057. readonly isSupported: boolean;
  27058. /**
  27059. * Get the list of textures generated by the multi render target.
  27060. */
  27061. readonly textures: Texture[];
  27062. /**
  27063. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  27064. */
  27065. readonly depthTexture: Texture;
  27066. /**
  27067. * Set the wrapping mode on U of all the textures we are rendering to.
  27068. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27069. */
  27070. wrapU: number;
  27071. /**
  27072. * Set the wrapping mode on V of all the textures we are rendering to.
  27073. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  27074. */
  27075. wrapV: number;
  27076. /**
  27077. * Instantiate a new multi render target texture.
  27078. * A multi render target, like a render target provides the ability to render to a texture.
  27079. * Unlike the render target, it can render to several draw buffers in one draw.
  27080. * This is specially interesting in deferred rendering or for any effects requiring more than
  27081. * just one color from a single pass.
  27082. * @param name Define the name of the texture
  27083. * @param size Define the size of the buffers to render to
  27084. * @param count Define the number of target we are rendering into
  27085. * @param scene Define the scene the texture belongs to
  27086. * @param options Define the options used to create the multi render target
  27087. */
  27088. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  27089. /** @hidden */
  27090. _rebuild(): void;
  27091. private _createInternalTextures;
  27092. private _createTextures;
  27093. /**
  27094. * Define the number of samples used if MSAA is enabled.
  27095. */
  27096. samples: number;
  27097. /**
  27098. * Resize all the textures in the multi render target.
  27099. * Be carrefull as it will recreate all the data in the new texture.
  27100. * @param size Define the new size
  27101. */
  27102. resize(size: any): void;
  27103. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  27104. /**
  27105. * Dispose the render targets and their associated resources
  27106. */
  27107. dispose(): void;
  27108. /**
  27109. * Release all the underlying texture used as draw buffers.
  27110. */
  27111. releaseInternalTextures(): void;
  27112. }
  27113. }
  27114. declare module "babylonjs/Audio/analyser" {
  27115. import { Scene } from "babylonjs/scene";
  27116. /**
  27117. * Class used to work with sound analyzer using fast fourier transform (FFT)
  27118. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27119. */
  27120. export class Analyser {
  27121. /**
  27122. * Gets or sets the smoothing
  27123. * @ignorenaming
  27124. */
  27125. SMOOTHING: number;
  27126. /**
  27127. * Gets or sets the FFT table size
  27128. * @ignorenaming
  27129. */
  27130. FFT_SIZE: number;
  27131. /**
  27132. * Gets or sets the bar graph amplitude
  27133. * @ignorenaming
  27134. */
  27135. BARGRAPHAMPLITUDE: number;
  27136. /**
  27137. * Gets or sets the position of the debug canvas
  27138. * @ignorenaming
  27139. */
  27140. DEBUGCANVASPOS: {
  27141. x: number;
  27142. y: number;
  27143. };
  27144. /**
  27145. * Gets or sets the debug canvas size
  27146. * @ignorenaming
  27147. */
  27148. DEBUGCANVASSIZE: {
  27149. width: number;
  27150. height: number;
  27151. };
  27152. private _byteFreqs;
  27153. private _byteTime;
  27154. private _floatFreqs;
  27155. private _webAudioAnalyser;
  27156. private _debugCanvas;
  27157. private _debugCanvasContext;
  27158. private _scene;
  27159. private _registerFunc;
  27160. private _audioEngine;
  27161. /**
  27162. * Creates a new analyser
  27163. * @param scene defines hosting scene
  27164. */
  27165. constructor(scene: Scene);
  27166. /**
  27167. * Get the number of data values you will have to play with for the visualization
  27168. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  27169. * @returns a number
  27170. */
  27171. getFrequencyBinCount(): number;
  27172. /**
  27173. * Gets the current frequency data as a byte array
  27174. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27175. * @returns a Uint8Array
  27176. */
  27177. getByteFrequencyData(): Uint8Array;
  27178. /**
  27179. * Gets the current waveform as a byte array
  27180. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  27181. * @returns a Uint8Array
  27182. */
  27183. getByteTimeDomainData(): Uint8Array;
  27184. /**
  27185. * Gets the current frequency data as a float array
  27186. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  27187. * @returns a Float32Array
  27188. */
  27189. getFloatFrequencyData(): Float32Array;
  27190. /**
  27191. * Renders the debug canvas
  27192. */
  27193. drawDebugCanvas(): void;
  27194. /**
  27195. * Stops rendering the debug canvas and removes it
  27196. */
  27197. stopDebugCanvas(): void;
  27198. /**
  27199. * Connects two audio nodes
  27200. * @param inputAudioNode defines first node to connect
  27201. * @param outputAudioNode defines second node to connect
  27202. */
  27203. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  27204. /**
  27205. * Releases all associated resources
  27206. */
  27207. dispose(): void;
  27208. }
  27209. }
  27210. declare module "babylonjs/Audio/audioEngine" {
  27211. import { IDisposable } from "babylonjs/scene";
  27212. import { Analyser } from "babylonjs/Audio/analyser";
  27213. import { Nullable } from "babylonjs/types";
  27214. import { Observable } from "babylonjs/Misc/observable";
  27215. /**
  27216. * This represents an audio engine and it is responsible
  27217. * to play, synchronize and analyse sounds throughout the application.
  27218. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27219. */
  27220. export interface IAudioEngine extends IDisposable {
  27221. /**
  27222. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27223. */
  27224. readonly canUseWebAudio: boolean;
  27225. /**
  27226. * Gets the current AudioContext if available.
  27227. */
  27228. readonly audioContext: Nullable<AudioContext>;
  27229. /**
  27230. * The master gain node defines the global audio volume of your audio engine.
  27231. */
  27232. readonly masterGain: GainNode;
  27233. /**
  27234. * Gets whether or not mp3 are supported by your browser.
  27235. */
  27236. readonly isMP3supported: boolean;
  27237. /**
  27238. * Gets whether or not ogg are supported by your browser.
  27239. */
  27240. readonly isOGGsupported: boolean;
  27241. /**
  27242. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27243. * @ignoreNaming
  27244. */
  27245. WarnedWebAudioUnsupported: boolean;
  27246. /**
  27247. * Defines if the audio engine relies on a custom unlocked button.
  27248. * In this case, the embedded button will not be displayed.
  27249. */
  27250. useCustomUnlockedButton: boolean;
  27251. /**
  27252. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  27253. */
  27254. readonly unlocked: boolean;
  27255. /**
  27256. * Event raised when audio has been unlocked on the browser.
  27257. */
  27258. onAudioUnlockedObservable: Observable<AudioEngine>;
  27259. /**
  27260. * Event raised when audio has been locked on the browser.
  27261. */
  27262. onAudioLockedObservable: Observable<AudioEngine>;
  27263. /**
  27264. * Flags the audio engine in Locked state.
  27265. * This happens due to new browser policies preventing audio to autoplay.
  27266. */
  27267. lock(): void;
  27268. /**
  27269. * Unlocks the audio engine once a user action has been done on the dom.
  27270. * This is helpful to resume play once browser policies have been satisfied.
  27271. */
  27272. unlock(): void;
  27273. }
  27274. /**
  27275. * This represents the default audio engine used in babylon.
  27276. * It is responsible to play, synchronize and analyse sounds throughout the application.
  27277. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27278. */
  27279. export class AudioEngine implements IAudioEngine {
  27280. private _audioContext;
  27281. private _audioContextInitialized;
  27282. private _muteButton;
  27283. private _hostElement;
  27284. /**
  27285. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  27286. */
  27287. canUseWebAudio: boolean;
  27288. /**
  27289. * The master gain node defines the global audio volume of your audio engine.
  27290. */
  27291. masterGain: GainNode;
  27292. /**
  27293. * Defines if Babylon should emit a warning if WebAudio is not supported.
  27294. * @ignoreNaming
  27295. */
  27296. WarnedWebAudioUnsupported: boolean;
  27297. /**
  27298. * Gets whether or not mp3 are supported by your browser.
  27299. */
  27300. isMP3supported: boolean;
  27301. /**
  27302. * Gets whether or not ogg are supported by your browser.
  27303. */
  27304. isOGGsupported: boolean;
  27305. /**
  27306. * Gets whether audio has been unlocked on the device.
  27307. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  27308. * a user interaction has happened.
  27309. */
  27310. unlocked: boolean;
  27311. /**
  27312. * Defines if the audio engine relies on a custom unlocked button.
  27313. * In this case, the embedded button will not be displayed.
  27314. */
  27315. useCustomUnlockedButton: boolean;
  27316. /**
  27317. * Event raised when audio has been unlocked on the browser.
  27318. */
  27319. onAudioUnlockedObservable: Observable<AudioEngine>;
  27320. /**
  27321. * Event raised when audio has been locked on the browser.
  27322. */
  27323. onAudioLockedObservable: Observable<AudioEngine>;
  27324. /**
  27325. * Gets the current AudioContext if available.
  27326. */
  27327. readonly audioContext: Nullable<AudioContext>;
  27328. private _connectedAnalyser;
  27329. /**
  27330. * Instantiates a new audio engine.
  27331. *
  27332. * There should be only one per page as some browsers restrict the number
  27333. * of audio contexts you can create.
  27334. * @param hostElement defines the host element where to display the mute icon if necessary
  27335. */
  27336. constructor(hostElement?: Nullable<HTMLElement>);
  27337. /**
  27338. * Flags the audio engine in Locked state.
  27339. * This happens due to new browser policies preventing audio to autoplay.
  27340. */
  27341. lock(): void;
  27342. /**
  27343. * Unlocks the audio engine once a user action has been done on the dom.
  27344. * This is helpful to resume play once browser policies have been satisfied.
  27345. */
  27346. unlock(): void;
  27347. private _resumeAudioContext;
  27348. private _initializeAudioContext;
  27349. private _tryToRun;
  27350. private _triggerRunningState;
  27351. private _triggerSuspendedState;
  27352. private _displayMuteButton;
  27353. private _moveButtonToTopLeft;
  27354. private _onResize;
  27355. private _hideMuteButton;
  27356. /**
  27357. * Destroy and release the resources associated with the audio ccontext.
  27358. */
  27359. dispose(): void;
  27360. /**
  27361. * Gets the global volume sets on the master gain.
  27362. * @returns the global volume if set or -1 otherwise
  27363. */
  27364. getGlobalVolume(): number;
  27365. /**
  27366. * Sets the global volume of your experience (sets on the master gain).
  27367. * @param newVolume Defines the new global volume of the application
  27368. */
  27369. setGlobalVolume(newVolume: number): void;
  27370. /**
  27371. * Connect the audio engine to an audio analyser allowing some amazing
  27372. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  27373. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  27374. * @param analyser The analyser to connect to the engine
  27375. */
  27376. connectToAnalyser(analyser: Analyser): void;
  27377. }
  27378. }
  27379. declare module "babylonjs/Loading/loadingScreen" {
  27380. /**
  27381. * Interface used to present a loading screen while loading a scene
  27382. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27383. */
  27384. export interface ILoadingScreen {
  27385. /**
  27386. * Function called to display the loading screen
  27387. */
  27388. displayLoadingUI: () => void;
  27389. /**
  27390. * Function called to hide the loading screen
  27391. */
  27392. hideLoadingUI: () => void;
  27393. /**
  27394. * Gets or sets the color to use for the background
  27395. */
  27396. loadingUIBackgroundColor: string;
  27397. /**
  27398. * Gets or sets the text to display while loading
  27399. */
  27400. loadingUIText: string;
  27401. }
  27402. /**
  27403. * Class used for the default loading screen
  27404. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  27405. */
  27406. export class DefaultLoadingScreen implements ILoadingScreen {
  27407. private _renderingCanvas;
  27408. private _loadingText;
  27409. private _loadingDivBackgroundColor;
  27410. private _loadingDiv;
  27411. private _loadingTextDiv;
  27412. /**
  27413. * Creates a new default loading screen
  27414. * @param _renderingCanvas defines the canvas used to render the scene
  27415. * @param _loadingText defines the default text to display
  27416. * @param _loadingDivBackgroundColor defines the default background color
  27417. */
  27418. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  27419. /**
  27420. * Function called to display the loading screen
  27421. */
  27422. displayLoadingUI(): void;
  27423. /**
  27424. * Function called to hide the loading screen
  27425. */
  27426. hideLoadingUI(): void;
  27427. /**
  27428. * Gets or sets the text to display while loading
  27429. */
  27430. loadingUIText: string;
  27431. /**
  27432. * Gets or sets the color to use for the background
  27433. */
  27434. loadingUIBackgroundColor: string;
  27435. private _resizeLoadingUI;
  27436. }
  27437. }
  27438. declare module "babylonjs/Materials/Textures/videoTexture" {
  27439. import { Observable } from "babylonjs/Misc/observable";
  27440. import { Nullable } from "babylonjs/types";
  27441. import { Scene } from "babylonjs/scene";
  27442. import { Texture } from "babylonjs/Materials/Textures/texture";
  27443. /**
  27444. * Settings for finer control over video usage
  27445. */
  27446. export interface VideoTextureSettings {
  27447. /**
  27448. * Applies `autoplay` to video, if specified
  27449. */
  27450. autoPlay?: boolean;
  27451. /**
  27452. * Applies `loop` to video, if specified
  27453. */
  27454. loop?: boolean;
  27455. /**
  27456. * Automatically updates internal texture from video at every frame in the render loop
  27457. */
  27458. autoUpdateTexture: boolean;
  27459. /**
  27460. * Image src displayed during the video loading or until the user interacts with the video.
  27461. */
  27462. poster?: string;
  27463. }
  27464. /**
  27465. * If you want to display a video in your scene, this is the special texture for that.
  27466. * This special texture works similar to other textures, with the exception of a few parameters.
  27467. * @see https://doc.babylonjs.com/how_to/video_texture
  27468. */
  27469. export class VideoTexture extends Texture {
  27470. /**
  27471. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  27472. */
  27473. readonly autoUpdateTexture: boolean;
  27474. /**
  27475. * The video instance used by the texture internally
  27476. */
  27477. readonly video: HTMLVideoElement;
  27478. private _onUserActionRequestedObservable;
  27479. /**
  27480. * Event triggerd when a dom action is required by the user to play the video.
  27481. * This happens due to recent changes in browser policies preventing video to auto start.
  27482. */
  27483. readonly onUserActionRequestedObservable: Observable<Texture>;
  27484. private _generateMipMaps;
  27485. private _engine;
  27486. private _stillImageCaptured;
  27487. private _displayingPosterTexture;
  27488. private _settings;
  27489. private _createInternalTextureOnEvent;
  27490. /**
  27491. * Creates a video texture.
  27492. * If you want to display a video in your scene, this is the special texture for that.
  27493. * This special texture works similar to other textures, with the exception of a few parameters.
  27494. * @see https://doc.babylonjs.com/how_to/video_texture
  27495. * @param name optional name, will detect from video source, if not defined
  27496. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  27497. * @param scene is obviously the current scene.
  27498. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  27499. * @param invertY is false by default but can be used to invert video on Y axis
  27500. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  27501. * @param settings allows finer control over video usage
  27502. */
  27503. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  27504. private _getName;
  27505. private _getVideo;
  27506. private _createInternalTexture;
  27507. private reset;
  27508. /**
  27509. * @hidden Internal method to initiate `update`.
  27510. */
  27511. _rebuild(): void;
  27512. /**
  27513. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  27514. */
  27515. update(): void;
  27516. /**
  27517. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  27518. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  27519. */
  27520. updateTexture(isVisible: boolean): void;
  27521. protected _updateInternalTexture: () => void;
  27522. /**
  27523. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  27524. * @param url New url.
  27525. */
  27526. updateURL(url: string): void;
  27527. /**
  27528. * Dispose the texture and release its associated resources.
  27529. */
  27530. dispose(): void;
  27531. /**
  27532. * Creates a video texture straight from a stream.
  27533. * @param scene Define the scene the texture should be created in
  27534. * @param stream Define the stream the texture should be created from
  27535. * @returns The created video texture as a promise
  27536. */
  27537. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  27538. /**
  27539. * Creates a video texture straight from your WebCam video feed.
  27540. * @param scene Define the scene the texture should be created in
  27541. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27542. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27543. * @returns The created video texture as a promise
  27544. */
  27545. static CreateFromWebCamAsync(scene: Scene, constraints: {
  27546. minWidth: number;
  27547. maxWidth: number;
  27548. minHeight: number;
  27549. maxHeight: number;
  27550. deviceId: string;
  27551. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  27552. /**
  27553. * Creates a video texture straight from your WebCam video feed.
  27554. * @param scene Define the scene the texture should be created in
  27555. * @param onReady Define a callback to triggered once the texture will be ready
  27556. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  27557. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  27558. */
  27559. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  27560. minWidth: number;
  27561. maxWidth: number;
  27562. minHeight: number;
  27563. maxHeight: number;
  27564. deviceId: string;
  27565. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  27566. }
  27567. }
  27568. declare module "babylonjs/Engines/engine" {
  27569. import { Observable } from "babylonjs/Misc/observable";
  27570. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  27571. import { ICustomAnimationFrameRequester, PerfCounter, IFileRequest } from "babylonjs/Misc/tools";
  27572. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  27573. import { Camera } from "babylonjs/Cameras/camera";
  27574. import { Scene } from "babylonjs/scene";
  27575. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  27576. import { IDisplayChangedEventArgs } from "babylonjs/Engines/engine";
  27577. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  27578. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  27579. import { Effect, EffectCreationOptions, EffectFallbacks } from "babylonjs/Materials/effect";
  27580. import { Material } from "babylonjs/Materials/material";
  27581. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  27582. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  27583. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  27584. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  27585. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  27586. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  27587. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  27588. import { _DepthCullingState, _StencilState, _AlphaState } from "babylonjs/States/index";
  27589. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  27590. import { WebRequest } from "babylonjs/Misc/webRequest";
  27591. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  27592. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  27593. /**
  27594. * Interface for attribute information associated with buffer instanciation
  27595. */
  27596. export class InstancingAttributeInfo {
  27597. /**
  27598. * Index/offset of the attribute in the vertex shader
  27599. */
  27600. index: number;
  27601. /**
  27602. * size of the attribute, 1, 2, 3 or 4
  27603. */
  27604. attributeSize: number;
  27605. /**
  27606. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  27607. * default is FLOAT
  27608. */
  27609. attribyteType: number;
  27610. /**
  27611. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  27612. */
  27613. normalized: boolean;
  27614. /**
  27615. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  27616. */
  27617. offset: number;
  27618. /**
  27619. * Name of the GLSL attribute, for debugging purpose only
  27620. */
  27621. attributeName: string;
  27622. }
  27623. /**
  27624. * Define options used to create a depth texture
  27625. */
  27626. export class DepthTextureCreationOptions {
  27627. /** Specifies whether or not a stencil should be allocated in the texture */
  27628. generateStencil?: boolean;
  27629. /** Specifies whether or not bilinear filtering is enable on the texture */
  27630. bilinearFiltering?: boolean;
  27631. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  27632. comparisonFunction?: number;
  27633. /** Specifies if the created texture is a cube texture */
  27634. isCube?: boolean;
  27635. }
  27636. /**
  27637. * Class used to describe the capabilities of the engine relatively to the current browser
  27638. */
  27639. export class EngineCapabilities {
  27640. /** Maximum textures units per fragment shader */
  27641. maxTexturesImageUnits: number;
  27642. /** Maximum texture units per vertex shader */
  27643. maxVertexTextureImageUnits: number;
  27644. /** Maximum textures units in the entire pipeline */
  27645. maxCombinedTexturesImageUnits: number;
  27646. /** Maximum texture size */
  27647. maxTextureSize: number;
  27648. /** Maximum cube texture size */
  27649. maxCubemapTextureSize: number;
  27650. /** Maximum render texture size */
  27651. maxRenderTextureSize: number;
  27652. /** Maximum number of vertex attributes */
  27653. maxVertexAttribs: number;
  27654. /** Maximum number of varyings */
  27655. maxVaryingVectors: number;
  27656. /** Maximum number of uniforms per vertex shader */
  27657. maxVertexUniformVectors: number;
  27658. /** Maximum number of uniforms per fragment shader */
  27659. maxFragmentUniformVectors: number;
  27660. /** Defines if standard derivates (dx/dy) are supported */
  27661. standardDerivatives: boolean;
  27662. /** Defines if s3tc texture compression is supported */
  27663. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  27664. /** Defines if pvrtc texture compression is supported */
  27665. pvrtc: any;
  27666. /** Defines if etc1 texture compression is supported */
  27667. etc1: any;
  27668. /** Defines if etc2 texture compression is supported */
  27669. etc2: any;
  27670. /** Defines if astc texture compression is supported */
  27671. astc: any;
  27672. /** Defines if float textures are supported */
  27673. textureFloat: boolean;
  27674. /** Defines if vertex array objects are supported */
  27675. vertexArrayObject: boolean;
  27676. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  27677. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  27678. /** Gets the maximum level of anisotropy supported */
  27679. maxAnisotropy: number;
  27680. /** Defines if instancing is supported */
  27681. instancedArrays: boolean;
  27682. /** Defines if 32 bits indices are supported */
  27683. uintIndices: boolean;
  27684. /** Defines if high precision shaders are supported */
  27685. highPrecisionShaderSupported: boolean;
  27686. /** Defines if depth reading in the fragment shader is supported */
  27687. fragmentDepthSupported: boolean;
  27688. /** Defines if float texture linear filtering is supported*/
  27689. textureFloatLinearFiltering: boolean;
  27690. /** Defines if rendering to float textures is supported */
  27691. textureFloatRender: boolean;
  27692. /** Defines if half float textures are supported*/
  27693. textureHalfFloat: boolean;
  27694. /** Defines if half float texture linear filtering is supported*/
  27695. textureHalfFloatLinearFiltering: boolean;
  27696. /** Defines if rendering to half float textures is supported */
  27697. textureHalfFloatRender: boolean;
  27698. /** Defines if textureLOD shader command is supported */
  27699. textureLOD: boolean;
  27700. /** Defines if draw buffers extension is supported */
  27701. drawBuffersExtension: boolean;
  27702. /** Defines if depth textures are supported */
  27703. depthTextureExtension: boolean;
  27704. /** Defines if float color buffer are supported */
  27705. colorBufferFloat: boolean;
  27706. /** Gets disjoint timer query extension (null if not supported) */
  27707. timerQuery: EXT_disjoint_timer_query;
  27708. /** Defines if timestamp can be used with timer query */
  27709. canUseTimestampForTimerQuery: boolean;
  27710. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  27711. multiview: any;
  27712. /** Function used to let the system compiles shaders in background */
  27713. parallelShaderCompile: {
  27714. COMPLETION_STATUS_KHR: number;
  27715. };
  27716. }
  27717. /** Interface defining initialization parameters for Engine class */
  27718. export interface EngineOptions extends WebGLContextAttributes {
  27719. /**
  27720. * Defines if the engine should no exceed a specified device ratio
  27721. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  27722. */
  27723. limitDeviceRatio?: number;
  27724. /**
  27725. * Defines if webvr should be enabled automatically
  27726. * @see http://doc.babylonjs.com/how_to/webvr_camera
  27727. */
  27728. autoEnableWebVR?: boolean;
  27729. /**
  27730. * Defines if webgl2 should be turned off even if supported
  27731. * @see http://doc.babylonjs.com/features/webgl2
  27732. */
  27733. disableWebGL2Support?: boolean;
  27734. /**
  27735. * Defines if webaudio should be initialized as well
  27736. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  27737. */
  27738. audioEngine?: boolean;
  27739. /**
  27740. * Defines if animations should run using a deterministic lock step
  27741. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  27742. */
  27743. deterministicLockstep?: boolean;
  27744. /** Defines the maximum steps to use with deterministic lock step mode */
  27745. lockstepMaxSteps?: number;
  27746. /**
  27747. * Defines that engine should ignore context lost events
  27748. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  27749. */
  27750. doNotHandleContextLost?: boolean;
  27751. /**
  27752. * Defines that engine should ignore modifying touch action attribute and style
  27753. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  27754. */
  27755. doNotHandleTouchAction?: boolean;
  27756. /**
  27757. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  27758. */
  27759. useHighPrecisionFloats?: boolean;
  27760. }
  27761. /**
  27762. * Defines the interface used by display changed events
  27763. */
  27764. export interface IDisplayChangedEventArgs {
  27765. /** Gets the vrDisplay object (if any) */
  27766. vrDisplay: Nullable<any>;
  27767. /** Gets a boolean indicating if webVR is supported */
  27768. vrSupported: boolean;
  27769. }
  27770. /**
  27771. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27772. */
  27773. export class Engine {
  27774. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  27775. static ExceptionList: ({
  27776. key: string;
  27777. capture: string;
  27778. captureConstraint: number;
  27779. targets: string[];
  27780. } | {
  27781. key: string;
  27782. capture: null;
  27783. captureConstraint: null;
  27784. targets: string[];
  27785. })[];
  27786. /** Gets the list of created engines */
  27787. static readonly Instances: Engine[];
  27788. /**
  27789. * Gets the latest created engine
  27790. */
  27791. static readonly LastCreatedEngine: Nullable<Engine>;
  27792. /**
  27793. * Gets the latest created scene
  27794. */
  27795. static readonly LastCreatedScene: Nullable<Scene>;
  27796. /**
  27797. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27798. * @param flag defines which part of the materials must be marked as dirty
  27799. * @param predicate defines a predicate used to filter which materials should be affected
  27800. */
  27801. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  27802. /**
  27803. * Hidden
  27804. */
  27805. static _TextureLoaders: IInternalTextureLoader[];
  27806. /** Defines that alpha blending is disabled */
  27807. static readonly ALPHA_DISABLE: number;
  27808. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27809. static readonly ALPHA_ADD: number;
  27810. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27811. static readonly ALPHA_COMBINE: number;
  27812. /** Defines that alpha blending to DEST - SRC * DEST */
  27813. static readonly ALPHA_SUBTRACT: number;
  27814. /** Defines that alpha blending to SRC * DEST */
  27815. static readonly ALPHA_MULTIPLY: number;
  27816. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27817. static readonly ALPHA_MAXIMIZED: number;
  27818. /** Defines that alpha blending to SRC + DEST */
  27819. static readonly ALPHA_ONEONE: number;
  27820. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27821. static readonly ALPHA_PREMULTIPLIED: number;
  27822. /**
  27823. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27824. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27825. */
  27826. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  27827. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27828. static readonly ALPHA_INTERPOLATE: number;
  27829. /**
  27830. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27831. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27832. */
  27833. static readonly ALPHA_SCREENMODE: number;
  27834. /** Defines that the ressource is not delayed*/
  27835. static readonly DELAYLOADSTATE_NONE: number;
  27836. /** Defines that the ressource was successfully delay loaded */
  27837. static readonly DELAYLOADSTATE_LOADED: number;
  27838. /** Defines that the ressource is currently delay loading */
  27839. static readonly DELAYLOADSTATE_LOADING: number;
  27840. /** Defines that the ressource is delayed and has not started loading */
  27841. static readonly DELAYLOADSTATE_NOTLOADED: number;
  27842. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27843. static readonly NEVER: number;
  27844. /** 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 */
  27845. static readonly ALWAYS: number;
  27846. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27847. static readonly LESS: number;
  27848. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27849. static readonly EQUAL: number;
  27850. /** 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 */
  27851. static readonly LEQUAL: number;
  27852. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27853. static readonly GREATER: number;
  27854. /** 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 */
  27855. static readonly GEQUAL: number;
  27856. /** 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 */
  27857. static readonly NOTEQUAL: number;
  27858. /** Passed to stencilOperation to specify that stencil value must be kept */
  27859. static readonly KEEP: number;
  27860. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27861. static readonly REPLACE: number;
  27862. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27863. static readonly INCR: number;
  27864. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27865. static readonly DECR: number;
  27866. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27867. static readonly INVERT: number;
  27868. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27869. static readonly INCR_WRAP: number;
  27870. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27871. static readonly DECR_WRAP: number;
  27872. /** Texture is not repeating outside of 0..1 UVs */
  27873. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  27874. /** Texture is repeating outside of 0..1 UVs */
  27875. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  27876. /** Texture is repeating and mirrored */
  27877. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  27878. /** ALPHA */
  27879. static readonly TEXTUREFORMAT_ALPHA: number;
  27880. /** LUMINANCE */
  27881. static readonly TEXTUREFORMAT_LUMINANCE: number;
  27882. /** LUMINANCE_ALPHA */
  27883. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  27884. /** RGB */
  27885. static readonly TEXTUREFORMAT_RGB: number;
  27886. /** RGBA */
  27887. static readonly TEXTUREFORMAT_RGBA: number;
  27888. /** RED */
  27889. static readonly TEXTUREFORMAT_RED: number;
  27890. /** RED (2nd reference) */
  27891. static readonly TEXTUREFORMAT_R: number;
  27892. /** RG */
  27893. static readonly TEXTUREFORMAT_RG: number;
  27894. /** RED_INTEGER */
  27895. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  27896. /** RED_INTEGER (2nd reference) */
  27897. static readonly TEXTUREFORMAT_R_INTEGER: number;
  27898. /** RG_INTEGER */
  27899. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  27900. /** RGB_INTEGER */
  27901. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  27902. /** RGBA_INTEGER */
  27903. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  27904. /** UNSIGNED_BYTE */
  27905. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  27906. /** UNSIGNED_BYTE (2nd reference) */
  27907. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  27908. /** FLOAT */
  27909. static readonly TEXTURETYPE_FLOAT: number;
  27910. /** HALF_FLOAT */
  27911. static readonly TEXTURETYPE_HALF_FLOAT: number;
  27912. /** BYTE */
  27913. static readonly TEXTURETYPE_BYTE: number;
  27914. /** SHORT */
  27915. static readonly TEXTURETYPE_SHORT: number;
  27916. /** UNSIGNED_SHORT */
  27917. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  27918. /** INT */
  27919. static readonly TEXTURETYPE_INT: number;
  27920. /** UNSIGNED_INT */
  27921. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  27922. /** UNSIGNED_SHORT_4_4_4_4 */
  27923. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  27924. /** UNSIGNED_SHORT_5_5_5_1 */
  27925. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  27926. /** UNSIGNED_SHORT_5_6_5 */
  27927. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  27928. /** UNSIGNED_INT_2_10_10_10_REV */
  27929. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  27930. /** UNSIGNED_INT_24_8 */
  27931. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  27932. /** UNSIGNED_INT_10F_11F_11F_REV */
  27933. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  27934. /** UNSIGNED_INT_5_9_9_9_REV */
  27935. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  27936. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27937. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  27938. /** nearest is mag = nearest and min = nearest and mip = linear */
  27939. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  27940. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27941. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  27942. /** Trilinear is mag = linear and min = linear and mip = linear */
  27943. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  27944. /** nearest is mag = nearest and min = nearest and mip = linear */
  27945. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  27946. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27947. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  27948. /** Trilinear is mag = linear and min = linear and mip = linear */
  27949. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  27950. /** mag = nearest and min = nearest and mip = nearest */
  27951. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  27952. /** mag = nearest and min = linear and mip = nearest */
  27953. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  27954. /** mag = nearest and min = linear and mip = linear */
  27955. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  27956. /** mag = nearest and min = linear and mip = none */
  27957. static readonly TEXTURE_NEAREST_LINEAR: number;
  27958. /** mag = nearest and min = nearest and mip = none */
  27959. static readonly TEXTURE_NEAREST_NEAREST: number;
  27960. /** mag = linear and min = nearest and mip = nearest */
  27961. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  27962. /** mag = linear and min = nearest and mip = linear */
  27963. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  27964. /** mag = linear and min = linear and mip = none */
  27965. static readonly TEXTURE_LINEAR_LINEAR: number;
  27966. /** mag = linear and min = nearest and mip = none */
  27967. static readonly TEXTURE_LINEAR_NEAREST: number;
  27968. /** Explicit coordinates mode */
  27969. static readonly TEXTURE_EXPLICIT_MODE: number;
  27970. /** Spherical coordinates mode */
  27971. static readonly TEXTURE_SPHERICAL_MODE: number;
  27972. /** Planar coordinates mode */
  27973. static readonly TEXTURE_PLANAR_MODE: number;
  27974. /** Cubic coordinates mode */
  27975. static readonly TEXTURE_CUBIC_MODE: number;
  27976. /** Projection coordinates mode */
  27977. static readonly TEXTURE_PROJECTION_MODE: number;
  27978. /** Skybox coordinates mode */
  27979. static readonly TEXTURE_SKYBOX_MODE: number;
  27980. /** Inverse Cubic coordinates mode */
  27981. static readonly TEXTURE_INVCUBIC_MODE: number;
  27982. /** Equirectangular coordinates mode */
  27983. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  27984. /** Equirectangular Fixed coordinates mode */
  27985. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  27986. /** Equirectangular Fixed Mirrored coordinates mode */
  27987. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  27988. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27989. static readonly SCALEMODE_FLOOR: number;
  27990. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27991. static readonly SCALEMODE_NEAREST: number;
  27992. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27993. static readonly SCALEMODE_CEILING: number;
  27994. /**
  27995. * Returns the current npm package of the sdk
  27996. */
  27997. static readonly NpmPackage: string;
  27998. /**
  27999. * Returns the current version of the framework
  28000. */
  28001. static readonly Version: string;
  28002. /**
  28003. * Returns a string describing the current engine
  28004. */
  28005. readonly description: string;
  28006. /**
  28007. * Gets or sets the epsilon value used by collision engine
  28008. */
  28009. static CollisionsEpsilon: number;
  28010. /**
  28011. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28012. */
  28013. static ShadersRepository: string;
  28014. /**
  28015. * Method called to create the default loading screen.
  28016. * This can be overriden in your own app.
  28017. * @param canvas The rendering canvas element
  28018. * @returns The loading screen
  28019. */
  28020. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  28021. /**
  28022. * Method called to create the default rescale post process on each engine.
  28023. */
  28024. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  28025. /**
  28026. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  28027. */
  28028. forcePOTTextures: boolean;
  28029. /**
  28030. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  28031. */
  28032. isFullscreen: boolean;
  28033. /**
  28034. * Gets a boolean indicating if the pointer is currently locked
  28035. */
  28036. isPointerLock: boolean;
  28037. /**
  28038. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  28039. */
  28040. cullBackFaces: boolean;
  28041. /**
  28042. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  28043. */
  28044. renderEvenInBackground: boolean;
  28045. /**
  28046. * Gets or sets a boolean indicating that cache can be kept between frames
  28047. */
  28048. preventCacheWipeBetweenFrames: boolean;
  28049. /**
  28050. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  28051. **/
  28052. enableOfflineSupport: boolean;
  28053. /**
  28054. * 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)
  28055. **/
  28056. disableManifestCheck: boolean;
  28057. /**
  28058. * Gets the list of created scenes
  28059. */
  28060. scenes: Scene[];
  28061. /**
  28062. * Event raised when a new scene is created
  28063. */
  28064. onNewSceneAddedObservable: Observable<Scene>;
  28065. /**
  28066. * Gets the list of created postprocesses
  28067. */
  28068. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  28069. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  28070. validateShaderPrograms: boolean;
  28071. /**
  28072. * Observable event triggered each time the rendering canvas is resized
  28073. */
  28074. onResizeObservable: Observable<Engine>;
  28075. /**
  28076. * Observable event triggered each time the canvas loses focus
  28077. */
  28078. onCanvasBlurObservable: Observable<Engine>;
  28079. /**
  28080. * Observable event triggered each time the canvas gains focus
  28081. */
  28082. onCanvasFocusObservable: Observable<Engine>;
  28083. /**
  28084. * Observable event triggered each time the canvas receives pointerout event
  28085. */
  28086. onCanvasPointerOutObservable: Observable<PointerEvent>;
  28087. /**
  28088. * Observable event triggered before each texture is initialized
  28089. */
  28090. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  28091. private _vrDisplay;
  28092. private _vrSupported;
  28093. private _oldSize;
  28094. private _oldHardwareScaleFactor;
  28095. private _vrExclusivePointerMode;
  28096. private _webVRInitPromise;
  28097. /**
  28098. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28099. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28100. */
  28101. readonly isInVRExclusivePointerMode: boolean;
  28102. /**
  28103. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  28104. */
  28105. disableUniformBuffers: boolean;
  28106. /** @hidden */
  28107. _uniformBuffers: UniformBuffer[];
  28108. /**
  28109. * Gets a boolean indicating that the engine supports uniform buffers
  28110. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28111. */
  28112. readonly supportsUniformBuffers: boolean;
  28113. /**
  28114. * Observable raised when the engine begins a new frame
  28115. */
  28116. onBeginFrameObservable: Observable<Engine>;
  28117. /**
  28118. * If set, will be used to request the next animation frame for the render loop
  28119. */
  28120. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  28121. /**
  28122. * Observable raised when the engine ends the current frame
  28123. */
  28124. onEndFrameObservable: Observable<Engine>;
  28125. /**
  28126. * Observable raised when the engine is about to compile a shader
  28127. */
  28128. onBeforeShaderCompilationObservable: Observable<Engine>;
  28129. /**
  28130. * Observable raised when the engine has jsut compiled a shader
  28131. */
  28132. onAfterShaderCompilationObservable: Observable<Engine>;
  28133. /** @hidden */
  28134. _gl: WebGLRenderingContext;
  28135. private _renderingCanvas;
  28136. private _windowIsBackground;
  28137. private _webGLVersion;
  28138. protected _highPrecisionShadersAllowed: boolean;
  28139. /** @hidden */
  28140. readonly _shouldUseHighPrecisionShader: boolean;
  28141. /**
  28142. * Gets a boolean indicating that only power of 2 textures are supported
  28143. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28144. */
  28145. readonly needPOTTextures: boolean;
  28146. /** @hidden */
  28147. _badOS: boolean;
  28148. /** @hidden */
  28149. _badDesktopOS: boolean;
  28150. /**
  28151. * Gets the audio engine
  28152. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  28153. * @ignorenaming
  28154. */
  28155. static audioEngine: IAudioEngine;
  28156. /**
  28157. * Default AudioEngine factory responsible of creating the Audio Engine.
  28158. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  28159. */
  28160. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  28161. /**
  28162. * Default offline support factory responsible of creating a tool used to store data locally.
  28163. * By default, this will create a Database object if the workload has been embedded.
  28164. */
  28165. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  28166. private _onFocus;
  28167. private _onBlur;
  28168. private _onCanvasPointerOut;
  28169. private _onCanvasBlur;
  28170. private _onCanvasFocus;
  28171. private _onFullscreenChange;
  28172. private _onPointerLockChange;
  28173. private _onVRDisplayPointerRestricted;
  28174. private _onVRDisplayPointerUnrestricted;
  28175. private _onVrDisplayConnect;
  28176. private _onVrDisplayDisconnect;
  28177. private _onVrDisplayPresentChange;
  28178. /**
  28179. * Observable signaled when VR display mode changes
  28180. */
  28181. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  28182. /**
  28183. * Observable signaled when VR request present is complete
  28184. */
  28185. onVRRequestPresentComplete: Observable<boolean>;
  28186. /**
  28187. * Observable signaled when VR request present starts
  28188. */
  28189. onVRRequestPresentStart: Observable<Engine>;
  28190. private _hardwareScalingLevel;
  28191. /** @hidden */
  28192. _caps: EngineCapabilities;
  28193. private _pointerLockRequested;
  28194. private _isStencilEnable;
  28195. private _colorWrite;
  28196. private _loadingScreen;
  28197. /** @hidden */
  28198. _drawCalls: PerfCounter;
  28199. private _glVersion;
  28200. private _glRenderer;
  28201. private _glVendor;
  28202. private _videoTextureSupported;
  28203. private _renderingQueueLaunched;
  28204. private _activeRenderLoops;
  28205. private _deterministicLockstep;
  28206. private _lockstepMaxSteps;
  28207. /**
  28208. * Observable signaled when a context lost event is raised
  28209. */
  28210. onContextLostObservable: Observable<Engine>;
  28211. /**
  28212. * Observable signaled when a context restored event is raised
  28213. */
  28214. onContextRestoredObservable: Observable<Engine>;
  28215. private _onContextLost;
  28216. private _onContextRestored;
  28217. private _contextWasLost;
  28218. /** @hidden */
  28219. _doNotHandleContextLost: boolean;
  28220. /**
  28221. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28222. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28223. */
  28224. doNotHandleContextLost: boolean;
  28225. private _performanceMonitor;
  28226. private _fps;
  28227. private _deltaTime;
  28228. /**
  28229. * Turn this value on if you want to pause FPS computation when in background
  28230. */
  28231. disablePerformanceMonitorInBackground: boolean;
  28232. /**
  28233. * Gets the performance monitor attached to this engine
  28234. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28235. */
  28236. readonly performanceMonitor: PerformanceMonitor;
  28237. /**
  28238. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  28239. */
  28240. disableVertexArrayObjects: boolean;
  28241. /** @hidden */
  28242. protected _depthCullingState: _DepthCullingState;
  28243. /** @hidden */
  28244. protected _stencilState: _StencilState;
  28245. /** @hidden */
  28246. protected _alphaState: _AlphaState;
  28247. /** @hidden */
  28248. protected _alphaMode: number;
  28249. /** @hidden */
  28250. _internalTexturesCache: InternalTexture[];
  28251. /** @hidden */
  28252. protected _activeChannel: number;
  28253. private _currentTextureChannel;
  28254. /** @hidden */
  28255. protected _boundTexturesCache: {
  28256. [key: string]: Nullable<InternalTexture>;
  28257. };
  28258. /** @hidden */
  28259. protected _currentEffect: Nullable<Effect>;
  28260. /** @hidden */
  28261. protected _currentProgram: Nullable<WebGLProgram>;
  28262. private _compiledEffects;
  28263. private _vertexAttribArraysEnabled;
  28264. /** @hidden */
  28265. protected _cachedViewport: Nullable<Viewport>;
  28266. private _cachedVertexArrayObject;
  28267. /** @hidden */
  28268. protected _cachedVertexBuffers: any;
  28269. /** @hidden */
  28270. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  28271. /** @hidden */
  28272. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  28273. /** @hidden */
  28274. protected _currentRenderTarget: Nullable<InternalTexture>;
  28275. private _uintIndicesCurrentlySet;
  28276. private _currentBoundBuffer;
  28277. /** @hidden */
  28278. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  28279. private _currentBufferPointers;
  28280. private _currentInstanceLocations;
  28281. private _currentInstanceBuffers;
  28282. private _textureUnits;
  28283. private _workingCanvas;
  28284. private _workingContext;
  28285. private _rescalePostProcess;
  28286. private _dummyFramebuffer;
  28287. private _externalData;
  28288. private _bindedRenderFunction;
  28289. private _vaoRecordInProgress;
  28290. private _mustWipeVertexAttributes;
  28291. private _emptyTexture;
  28292. private _emptyCubeTexture;
  28293. private _emptyTexture3D;
  28294. /** @hidden */
  28295. _frameHandler: number;
  28296. private _nextFreeTextureSlots;
  28297. private _maxSimultaneousTextures;
  28298. private _activeRequests;
  28299. private _texturesSupported;
  28300. private _textureFormatInUse;
  28301. /**
  28302. * Gets the list of texture formats supported
  28303. */
  28304. readonly texturesSupported: Array<string>;
  28305. /**
  28306. * Gets the list of texture formats in use
  28307. */
  28308. readonly textureFormatInUse: Nullable<string>;
  28309. /**
  28310. * Gets the current viewport
  28311. */
  28312. readonly currentViewport: Nullable<Viewport>;
  28313. /**
  28314. * Gets the default empty texture
  28315. */
  28316. readonly emptyTexture: InternalTexture;
  28317. /**
  28318. * Gets the default empty 3D texture
  28319. */
  28320. readonly emptyTexture3D: InternalTexture;
  28321. /**
  28322. * Gets the default empty cube texture
  28323. */
  28324. readonly emptyCubeTexture: InternalTexture;
  28325. /**
  28326. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  28327. */
  28328. readonly premultipliedAlpha: boolean;
  28329. /**
  28330. * Creates a new engine
  28331. * @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
  28332. * @param antialias defines enable antialiasing (default: false)
  28333. * @param options defines further options to be sent to the getContext() function
  28334. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  28335. */
  28336. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  28337. private _disableTouchAction;
  28338. private _rebuildInternalTextures;
  28339. private _rebuildEffects;
  28340. /**
  28341. * Gets a boolean indicating if all created effects are ready
  28342. * @returns true if all effects are ready
  28343. */
  28344. areAllEffectsReady(): boolean;
  28345. private _rebuildBuffers;
  28346. private _initGLContext;
  28347. /**
  28348. * Gets version of the current webGL context
  28349. */
  28350. readonly webGLVersion: number;
  28351. /**
  28352. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28353. */
  28354. readonly isStencilEnable: boolean;
  28355. private _prepareWorkingCanvas;
  28356. /**
  28357. * Reset the texture cache to empty state
  28358. */
  28359. resetTextureCache(): void;
  28360. /**
  28361. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28362. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28363. * @returns true if engine is in deterministic lock step mode
  28364. */
  28365. isDeterministicLockStep(): boolean;
  28366. /**
  28367. * Gets the max steps when engine is running in deterministic lock step
  28368. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28369. * @returns the max steps
  28370. */
  28371. getLockstepMaxSteps(): number;
  28372. /**
  28373. * Gets an object containing information about the current webGL context
  28374. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28375. */
  28376. getGlInfo(): {
  28377. vendor: string;
  28378. renderer: string;
  28379. version: string;
  28380. };
  28381. /**
  28382. * Gets current aspect ratio
  28383. * @param camera defines the camera to use to get the aspect ratio
  28384. * @param useScreen defines if screen size must be used (or the current render target if any)
  28385. * @returns a number defining the aspect ratio
  28386. */
  28387. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  28388. /**
  28389. * Gets current screen aspect ratio
  28390. * @returns a number defining the aspect ratio
  28391. */
  28392. getScreenAspectRatio(): number;
  28393. /**
  28394. * Gets the current render width
  28395. * @param useScreen defines if screen size must be used (or the current render target if any)
  28396. * @returns a number defining the current render width
  28397. */
  28398. getRenderWidth(useScreen?: boolean): number;
  28399. /**
  28400. * Gets the current render height
  28401. * @param useScreen defines if screen size must be used (or the current render target if any)
  28402. * @returns a number defining the current render height
  28403. */
  28404. getRenderHeight(useScreen?: boolean): number;
  28405. /**
  28406. * Gets the HTML canvas attached with the current webGL context
  28407. * @returns a HTML canvas
  28408. */
  28409. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  28410. /**
  28411. * Gets the client rect of the HTML canvas attached with the current webGL context
  28412. * @returns a client rectanglee
  28413. */
  28414. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  28415. /**
  28416. * Defines the hardware scaling level.
  28417. * By default the hardware scaling level is computed from the window device ratio.
  28418. * 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.
  28419. * @param level defines the level to use
  28420. */
  28421. setHardwareScalingLevel(level: number): void;
  28422. /**
  28423. * Gets the current hardware scaling level.
  28424. * By default the hardware scaling level is computed from the window device ratio.
  28425. * 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.
  28426. * @returns a number indicating the current hardware scaling level
  28427. */
  28428. getHardwareScalingLevel(): number;
  28429. /**
  28430. * Gets the list of loaded textures
  28431. * @returns an array containing all loaded textures
  28432. */
  28433. getLoadedTexturesCache(): InternalTexture[];
  28434. /**
  28435. * Gets the object containing all engine capabilities
  28436. * @returns the EngineCapabilities object
  28437. */
  28438. getCaps(): EngineCapabilities;
  28439. /**
  28440. * Gets the current depth function
  28441. * @returns a number defining the depth function
  28442. */
  28443. getDepthFunction(): Nullable<number>;
  28444. /**
  28445. * Sets the current depth function
  28446. * @param depthFunc defines the function to use
  28447. */
  28448. setDepthFunction(depthFunc: number): void;
  28449. /**
  28450. * Sets the current depth function to GREATER
  28451. */
  28452. setDepthFunctionToGreater(): void;
  28453. /**
  28454. * Sets the current depth function to GEQUAL
  28455. */
  28456. setDepthFunctionToGreaterOrEqual(): void;
  28457. /**
  28458. * Sets the current depth function to LESS
  28459. */
  28460. setDepthFunctionToLess(): void;
  28461. private _cachedStencilBuffer;
  28462. private _cachedStencilFunction;
  28463. private _cachedStencilMask;
  28464. private _cachedStencilOperationPass;
  28465. private _cachedStencilOperationFail;
  28466. private _cachedStencilOperationDepthFail;
  28467. private _cachedStencilReference;
  28468. /**
  28469. * Caches the the state of the stencil buffer
  28470. */
  28471. cacheStencilState(): void;
  28472. /**
  28473. * Restores the state of the stencil buffer
  28474. */
  28475. restoreStencilState(): void;
  28476. /**
  28477. * Sets the current depth function to LEQUAL
  28478. */
  28479. setDepthFunctionToLessOrEqual(): void;
  28480. /**
  28481. * Gets a boolean indicating if stencil buffer is enabled
  28482. * @returns the current stencil buffer state
  28483. */
  28484. getStencilBuffer(): boolean;
  28485. /**
  28486. * Enable or disable the stencil buffer
  28487. * @param enable defines if the stencil buffer must be enabled or disabled
  28488. */
  28489. setStencilBuffer(enable: boolean): void;
  28490. /**
  28491. * Gets the current stencil mask
  28492. * @returns a number defining the new stencil mask to use
  28493. */
  28494. getStencilMask(): number;
  28495. /**
  28496. * Sets the current stencil mask
  28497. * @param mask defines the new stencil mask to use
  28498. */
  28499. setStencilMask(mask: number): void;
  28500. /**
  28501. * Gets the current stencil function
  28502. * @returns a number defining the stencil function to use
  28503. */
  28504. getStencilFunction(): number;
  28505. /**
  28506. * Gets the current stencil reference value
  28507. * @returns a number defining the stencil reference value to use
  28508. */
  28509. getStencilFunctionReference(): number;
  28510. /**
  28511. * Gets the current stencil mask
  28512. * @returns a number defining the stencil mask to use
  28513. */
  28514. getStencilFunctionMask(): number;
  28515. /**
  28516. * Sets the current stencil function
  28517. * @param stencilFunc defines the new stencil function to use
  28518. */
  28519. setStencilFunction(stencilFunc: number): void;
  28520. /**
  28521. * Sets the current stencil reference
  28522. * @param reference defines the new stencil reference to use
  28523. */
  28524. setStencilFunctionReference(reference: number): void;
  28525. /**
  28526. * Sets the current stencil mask
  28527. * @param mask defines the new stencil mask to use
  28528. */
  28529. setStencilFunctionMask(mask: number): void;
  28530. /**
  28531. * Gets the current stencil operation when stencil fails
  28532. * @returns a number defining stencil operation to use when stencil fails
  28533. */
  28534. getStencilOperationFail(): number;
  28535. /**
  28536. * Gets the current stencil operation when depth fails
  28537. * @returns a number defining stencil operation to use when depth fails
  28538. */
  28539. getStencilOperationDepthFail(): number;
  28540. /**
  28541. * Gets the current stencil operation when stencil passes
  28542. * @returns a number defining stencil operation to use when stencil passes
  28543. */
  28544. getStencilOperationPass(): number;
  28545. /**
  28546. * Sets the stencil operation to use when stencil fails
  28547. * @param operation defines the stencil operation to use when stencil fails
  28548. */
  28549. setStencilOperationFail(operation: number): void;
  28550. /**
  28551. * Sets the stencil operation to use when depth fails
  28552. * @param operation defines the stencil operation to use when depth fails
  28553. */
  28554. setStencilOperationDepthFail(operation: number): void;
  28555. /**
  28556. * Sets the stencil operation to use when stencil passes
  28557. * @param operation defines the stencil operation to use when stencil passes
  28558. */
  28559. setStencilOperationPass(operation: number): void;
  28560. /**
  28561. * Sets a boolean indicating if the dithering state is enabled or disabled
  28562. * @param value defines the dithering state
  28563. */
  28564. setDitheringState(value: boolean): void;
  28565. /**
  28566. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28567. * @param value defines the rasterizer state
  28568. */
  28569. setRasterizerState(value: boolean): void;
  28570. /**
  28571. * stop executing a render loop function and remove it from the execution array
  28572. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28573. */
  28574. stopRenderLoop(renderFunction?: () => void): void;
  28575. /** @hidden */
  28576. _renderLoop(): void;
  28577. /**
  28578. * Register and execute a render loop. The engine can have more than one render function
  28579. * @param renderFunction defines the function to continuously execute
  28580. */
  28581. runRenderLoop(renderFunction: () => void): void;
  28582. /**
  28583. * Toggle full screen mode
  28584. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28585. */
  28586. switchFullscreen(requestPointerLock: boolean): void;
  28587. /**
  28588. * Enters full screen mode
  28589. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28590. */
  28591. enterFullscreen(requestPointerLock: boolean): void;
  28592. /**
  28593. * Exits full screen mode
  28594. */
  28595. exitFullscreen(): void;
  28596. /**
  28597. * Clear the current render buffer or the current render target (if any is set up)
  28598. * @param color defines the color to use
  28599. * @param backBuffer defines if the back buffer must be cleared
  28600. * @param depth defines if the depth buffer must be cleared
  28601. * @param stencil defines if the stencil buffer must be cleared
  28602. */
  28603. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  28604. /**
  28605. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28606. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28607. * @param y defines the y-coordinate of the corner of the clear rectangle
  28608. * @param width defines the width of the clear rectangle
  28609. * @param height defines the height of the clear rectangle
  28610. * @param clearColor defines the clear color
  28611. */
  28612. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  28613. /**
  28614. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28615. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28616. * @param y defines the y-coordinate of the corner of the clear rectangle
  28617. * @param width defines the width of the clear rectangle
  28618. * @param height defines the height of the clear rectangle
  28619. */
  28620. enableScissor(x: number, y: number, width: number, height: number): void;
  28621. /**
  28622. * Disable previously set scissor test rectangle
  28623. */
  28624. disableScissor(): void;
  28625. private _viewportCached;
  28626. /** @hidden */
  28627. _viewport(x: number, y: number, width: number, height: number): void;
  28628. /**
  28629. * Set the WebGL's viewport
  28630. * @param viewport defines the viewport element to be used
  28631. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28632. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28633. */
  28634. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  28635. /**
  28636. * Directly set the WebGL Viewport
  28637. * @param x defines the x coordinate of the viewport (in screen space)
  28638. * @param y defines the y coordinate of the viewport (in screen space)
  28639. * @param width defines the width of the viewport (in screen space)
  28640. * @param height defines the height of the viewport (in screen space)
  28641. * @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
  28642. */
  28643. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  28644. /**
  28645. * Begin a new frame
  28646. */
  28647. beginFrame(): void;
  28648. /**
  28649. * Enf the current frame
  28650. */
  28651. endFrame(): void;
  28652. /**
  28653. * Resize the view according to the canvas' size
  28654. */
  28655. resize(): void;
  28656. /**
  28657. * Force a specific size of the canvas
  28658. * @param width defines the new canvas' width
  28659. * @param height defines the new canvas' height
  28660. */
  28661. setSize(width: number, height: number): void;
  28662. /**
  28663. * Gets a boolean indicating if a webVR device was detected
  28664. * @returns true if a webVR device was detected
  28665. */
  28666. isVRDevicePresent(): boolean;
  28667. /**
  28668. * Gets the current webVR device
  28669. * @returns the current webVR device (or null)
  28670. */
  28671. getVRDevice(): any;
  28672. /**
  28673. * Initializes a webVR display and starts listening to display change events
  28674. * The onVRDisplayChangedObservable will be notified upon these changes
  28675. * @returns The onVRDisplayChangedObservable
  28676. */
  28677. initWebVR(): Observable<IDisplayChangedEventArgs>;
  28678. /**
  28679. * Initializes a webVR display and starts listening to display change events
  28680. * The onVRDisplayChangedObservable will be notified upon these changes
  28681. * @returns A promise containing a VRDisplay and if vr is supported
  28682. */
  28683. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  28684. /**
  28685. * Call this function to switch to webVR mode
  28686. * Will do nothing if webVR is not supported or if there is no webVR device
  28687. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28688. */
  28689. enableVR(): void;
  28690. /**
  28691. * Call this function to leave webVR mode
  28692. * Will do nothing if webVR is not supported or if there is no webVR device
  28693. * @see http://doc.babylonjs.com/how_to/webvr_camera
  28694. */
  28695. disableVR(): void;
  28696. private _onVRFullScreenTriggered;
  28697. private _getVRDisplaysAsync;
  28698. /**
  28699. * Binds the frame buffer to the specified texture.
  28700. * @param texture The texture to render to or null for the default canvas
  28701. * @param faceIndex The face of the texture to render to in case of cube texture
  28702. * @param requiredWidth The width of the target to render to
  28703. * @param requiredHeight The height of the target to render to
  28704. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  28705. * @param depthStencilTexture The depth stencil texture to use to render
  28706. * @param lodLevel defines le lod level to bind to the frame buffer
  28707. */
  28708. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  28709. private bindUnboundFramebuffer;
  28710. /**
  28711. * Unbind the current render target texture from the webGL context
  28712. * @param texture defines the render target texture to unbind
  28713. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28714. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28715. */
  28716. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28717. /**
  28718. * Unbind a list of render target textures from the webGL context
  28719. * This is used only when drawBuffer extension or webGL2 are active
  28720. * @param textures defines the render target textures to unbind
  28721. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  28722. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  28723. */
  28724. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  28725. /**
  28726. * Force the mipmap generation for the given render target texture
  28727. * @param texture defines the render target texture to use
  28728. */
  28729. generateMipMapsForCubemap(texture: InternalTexture): void;
  28730. /**
  28731. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  28732. */
  28733. flushFramebuffer(): void;
  28734. /**
  28735. * Unbind the current render target and bind the default framebuffer
  28736. */
  28737. restoreDefaultFramebuffer(): void;
  28738. /**
  28739. * Create an uniform buffer
  28740. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28741. * @param elements defines the content of the uniform buffer
  28742. * @returns the webGL uniform buffer
  28743. */
  28744. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  28745. /**
  28746. * Create a dynamic uniform buffer
  28747. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28748. * @param elements defines the content of the uniform buffer
  28749. * @returns the webGL uniform buffer
  28750. */
  28751. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  28752. /**
  28753. * Update an existing uniform buffer
  28754. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28755. * @param uniformBuffer defines the target uniform buffer
  28756. * @param elements defines the content to update
  28757. * @param offset defines the offset in the uniform buffer where update should start
  28758. * @param count defines the size of the data to update
  28759. */
  28760. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  28761. private _resetVertexBufferBinding;
  28762. /**
  28763. * Creates a vertex buffer
  28764. * @param data the data for the vertex buffer
  28765. * @returns the new WebGL static buffer
  28766. */
  28767. createVertexBuffer(data: DataArray): WebGLBuffer;
  28768. /**
  28769. * Creates a dynamic vertex buffer
  28770. * @param data the data for the dynamic vertex buffer
  28771. * @returns the new WebGL dynamic buffer
  28772. */
  28773. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  28774. /**
  28775. * Update a dynamic index buffer
  28776. * @param indexBuffer defines the target index buffer
  28777. * @param indices defines the data to update
  28778. * @param offset defines the offset in the target index buffer where update should start
  28779. */
  28780. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  28781. /**
  28782. * Updates a dynamic vertex buffer.
  28783. * @param vertexBuffer the vertex buffer to update
  28784. * @param data the data used to update the vertex buffer
  28785. * @param byteOffset the byte offset of the data
  28786. * @param byteLength the byte length of the data
  28787. */
  28788. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  28789. private _resetIndexBufferBinding;
  28790. /**
  28791. * Creates a new index buffer
  28792. * @param indices defines the content of the index buffer
  28793. * @param updatable defines if the index buffer must be updatable
  28794. * @returns a new webGL buffer
  28795. */
  28796. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  28797. /**
  28798. * Bind a webGL buffer to the webGL context
  28799. * @param buffer defines the buffer to bind
  28800. */
  28801. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  28802. /**
  28803. * Bind an uniform buffer to the current webGL context
  28804. * @param buffer defines the buffer to bind
  28805. */
  28806. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  28807. /**
  28808. * Bind a buffer to the current webGL context at a given location
  28809. * @param buffer defines the buffer to bind
  28810. * @param location defines the index where to bind the buffer
  28811. */
  28812. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  28813. /**
  28814. * Bind a specific block at a given index in a specific shader program
  28815. * @param shaderProgram defines the shader program
  28816. * @param blockName defines the block name
  28817. * @param index defines the index where to bind the block
  28818. */
  28819. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  28820. private bindIndexBuffer;
  28821. private bindBuffer;
  28822. /**
  28823. * update the bound buffer with the given data
  28824. * @param data defines the data to update
  28825. */
  28826. updateArrayBuffer(data: Float32Array): void;
  28827. private _vertexAttribPointer;
  28828. private _bindIndexBufferWithCache;
  28829. private _bindVertexBuffersAttributes;
  28830. /**
  28831. * Records a vertex array object
  28832. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28833. * @param vertexBuffers defines the list of vertex buffers to store
  28834. * @param indexBuffer defines the index buffer to store
  28835. * @param effect defines the effect to store
  28836. * @returns the new vertex array object
  28837. */
  28838. recordVertexArrayObject(vertexBuffers: {
  28839. [key: string]: VertexBuffer;
  28840. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  28841. /**
  28842. * Bind a specific vertex array object
  28843. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  28844. * @param vertexArrayObject defines the vertex array object to bind
  28845. * @param indexBuffer defines the index buffer to bind
  28846. */
  28847. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  28848. /**
  28849. * Bind webGl buffers directly to the webGL context
  28850. * @param vertexBuffer defines the vertex buffer to bind
  28851. * @param indexBuffer defines the index buffer to bind
  28852. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  28853. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  28854. * @param effect defines the effect associated with the vertex buffer
  28855. */
  28856. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  28857. private _unbindVertexArrayObject;
  28858. /**
  28859. * Bind a list of vertex buffers to the webGL context
  28860. * @param vertexBuffers defines the list of vertex buffers to bind
  28861. * @param indexBuffer defines the index buffer to bind
  28862. * @param effect defines the effect associated with the vertex buffers
  28863. */
  28864. bindBuffers(vertexBuffers: {
  28865. [key: string]: Nullable<VertexBuffer>;
  28866. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  28867. /**
  28868. * Unbind all instance attributes
  28869. */
  28870. unbindInstanceAttributes(): void;
  28871. /**
  28872. * Release and free the memory of a vertex array object
  28873. * @param vao defines the vertex array object to delete
  28874. */
  28875. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  28876. /** @hidden */
  28877. _releaseBuffer(buffer: WebGLBuffer): boolean;
  28878. /**
  28879. * Creates a webGL buffer to use with instanciation
  28880. * @param capacity defines the size of the buffer
  28881. * @returns the webGL buffer
  28882. */
  28883. createInstancesBuffer(capacity: number): WebGLBuffer;
  28884. /**
  28885. * Delete a webGL buffer used with instanciation
  28886. * @param buffer defines the webGL buffer to delete
  28887. */
  28888. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  28889. /**
  28890. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  28891. * @param instancesBuffer defines the webGL buffer to update and bind
  28892. * @param data defines the data to store in the buffer
  28893. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  28894. */
  28895. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  28896. /**
  28897. * Apply all cached states (depth, culling, stencil and alpha)
  28898. */
  28899. applyStates(): void;
  28900. /**
  28901. * Send a draw order
  28902. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28903. * @param indexStart defines the starting index
  28904. * @param indexCount defines the number of index to draw
  28905. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28906. */
  28907. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  28908. /**
  28909. * Draw a list of points
  28910. * @param verticesStart defines the index of first vertex to draw
  28911. * @param verticesCount defines the count of vertices to draw
  28912. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28913. */
  28914. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28915. /**
  28916. * Draw a list of unindexed primitives
  28917. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  28918. * @param verticesStart defines the index of first vertex to draw
  28919. * @param verticesCount defines the count of vertices to draw
  28920. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28921. */
  28922. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28923. /**
  28924. * Draw a list of indexed primitives
  28925. * @param fillMode defines the primitive to use
  28926. * @param indexStart defines the starting index
  28927. * @param indexCount defines the number of index to draw
  28928. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28929. */
  28930. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  28931. /**
  28932. * Draw a list of unindexed primitives
  28933. * @param fillMode defines the primitive to use
  28934. * @param verticesStart defines the index of first vertex to draw
  28935. * @param verticesCount defines the count of vertices to draw
  28936. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  28937. */
  28938. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  28939. private _drawMode;
  28940. /** @hidden */
  28941. _releaseEffect(effect: Effect): void;
  28942. /** @hidden */
  28943. _deleteProgram(program: WebGLProgram): void;
  28944. /**
  28945. * Create a new effect (used to store vertex/fragment shaders)
  28946. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  28947. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  28948. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  28949. * @param samplers defines an array of string used to represent textures
  28950. * @param defines defines the string containing the defines to use to compile the shaders
  28951. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  28952. * @param onCompiled defines a function to call when the effect creation is successful
  28953. * @param onError defines a function to call when the effect creation has failed
  28954. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  28955. * @returns the new Effect
  28956. */
  28957. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  28958. private _compileShader;
  28959. private _compileRawShader;
  28960. /**
  28961. * Directly creates a webGL program
  28962. * @param vertexCode defines the vertex shader code to use
  28963. * @param fragmentCode defines the fragment shader code to use
  28964. * @param context defines the webGL context to use (if not set, the current one will be used)
  28965. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28966. * @returns the new webGL program
  28967. */
  28968. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28969. /**
  28970. * Creates a webGL program
  28971. * @param vertexCode defines the vertex shader code to use
  28972. * @param fragmentCode defines the fragment shader code to use
  28973. * @param defines defines the string containing the defines to use to compile the shaders
  28974. * @param context defines the webGL context to use (if not set, the current one will be used)
  28975. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  28976. * @returns the new webGL program
  28977. */
  28978. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  28979. private _createShaderProgram;
  28980. private _finalizeProgram;
  28981. /** @hidden */
  28982. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  28983. /** @hidden */
  28984. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  28985. /**
  28986. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  28987. * @param shaderProgram defines the webGL program to use
  28988. * @param uniformsNames defines the list of uniform names
  28989. * @returns an array of webGL uniform locations
  28990. */
  28991. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  28992. /**
  28993. * Gets the lsit of active attributes for a given webGL program
  28994. * @param shaderProgram defines the webGL program to use
  28995. * @param attributesNames defines the list of attribute names to get
  28996. * @returns an array of indices indicating the offset of each attribute
  28997. */
  28998. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  28999. /**
  29000. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  29001. * @param effect defines the effect to activate
  29002. */
  29003. enableEffect(effect: Nullable<Effect>): void;
  29004. /**
  29005. * Set the value of an uniform to an array of int32
  29006. * @param uniform defines the webGL uniform location where to store the value
  29007. * @param array defines the array of int32 to store
  29008. */
  29009. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29010. /**
  29011. * Set the value of an uniform to an array of int32 (stored as vec2)
  29012. * @param uniform defines the webGL uniform location where to store the value
  29013. * @param array defines the array of int32 to store
  29014. */
  29015. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29016. /**
  29017. * Set the value of an uniform to an array of int32 (stored as vec3)
  29018. * @param uniform defines the webGL uniform location where to store the value
  29019. * @param array defines the array of int32 to store
  29020. */
  29021. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29022. /**
  29023. * Set the value of an uniform to an array of int32 (stored as vec4)
  29024. * @param uniform defines the webGL uniform location where to store the value
  29025. * @param array defines the array of int32 to store
  29026. */
  29027. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  29028. /**
  29029. * Set the value of an uniform to an array of float32
  29030. * @param uniform defines the webGL uniform location where to store the value
  29031. * @param array defines the array of float32 to store
  29032. */
  29033. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29034. /**
  29035. * Set the value of an uniform to an array of float32 (stored as vec2)
  29036. * @param uniform defines the webGL uniform location where to store the value
  29037. * @param array defines the array of float32 to store
  29038. */
  29039. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29040. /**
  29041. * Set the value of an uniform to an array of float32 (stored as vec3)
  29042. * @param uniform defines the webGL uniform location where to store the value
  29043. * @param array defines the array of float32 to store
  29044. */
  29045. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29046. /**
  29047. * Set the value of an uniform to an array of float32 (stored as vec4)
  29048. * @param uniform defines the webGL uniform location where to store the value
  29049. * @param array defines the array of float32 to store
  29050. */
  29051. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  29052. /**
  29053. * Set the value of an uniform to an array of number
  29054. * @param uniform defines the webGL uniform location where to store the value
  29055. * @param array defines the array of number to store
  29056. */
  29057. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29058. /**
  29059. * Set the value of an uniform to an array of number (stored as vec2)
  29060. * @param uniform defines the webGL uniform location where to store the value
  29061. * @param array defines the array of number to store
  29062. */
  29063. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29064. /**
  29065. * Set the value of an uniform to an array of number (stored as vec3)
  29066. * @param uniform defines the webGL uniform location where to store the value
  29067. * @param array defines the array of number to store
  29068. */
  29069. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29070. /**
  29071. * Set the value of an uniform to an array of number (stored as vec4)
  29072. * @param uniform defines the webGL uniform location where to store the value
  29073. * @param array defines the array of number to store
  29074. */
  29075. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  29076. /**
  29077. * Set the value of an uniform to an array of float32 (stored as matrices)
  29078. * @param uniform defines the webGL uniform location where to store the value
  29079. * @param matrices defines the array of float32 to store
  29080. */
  29081. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  29082. /**
  29083. * Set the value of an uniform to a matrix
  29084. * @param uniform defines the webGL uniform location where to store the value
  29085. * @param matrix defines the matrix to store
  29086. */
  29087. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  29088. /**
  29089. * Set the value of an uniform to a matrix (3x3)
  29090. * @param uniform defines the webGL uniform location where to store the value
  29091. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  29092. */
  29093. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29094. /**
  29095. * Set the value of an uniform to a matrix (2x2)
  29096. * @param uniform defines the webGL uniform location where to store the value
  29097. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  29098. */
  29099. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  29100. /**
  29101. * Set the value of an uniform to a number (int)
  29102. * @param uniform defines the webGL uniform location where to store the value
  29103. * @param value defines the int number to store
  29104. */
  29105. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29106. /**
  29107. * Set the value of an uniform to a number (float)
  29108. * @param uniform defines the webGL uniform location where to store the value
  29109. * @param value defines the float number to store
  29110. */
  29111. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  29112. /**
  29113. * Set the value of an uniform to a vec2
  29114. * @param uniform defines the webGL uniform location where to store the value
  29115. * @param x defines the 1st component of the value
  29116. * @param y defines the 2nd component of the value
  29117. */
  29118. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  29119. /**
  29120. * Set the value of an uniform to a vec3
  29121. * @param uniform defines the webGL uniform location where to store the value
  29122. * @param x defines the 1st component of the value
  29123. * @param y defines the 2nd component of the value
  29124. * @param z defines the 3rd component of the value
  29125. */
  29126. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  29127. /**
  29128. * Set the value of an uniform to a boolean
  29129. * @param uniform defines the webGL uniform location where to store the value
  29130. * @param bool defines the boolean to store
  29131. */
  29132. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  29133. /**
  29134. * Set the value of an uniform to a vec4
  29135. * @param uniform defines the webGL uniform location where to store the value
  29136. * @param x defines the 1st component of the value
  29137. * @param y defines the 2nd component of the value
  29138. * @param z defines the 3rd component of the value
  29139. * @param w defines the 4th component of the value
  29140. */
  29141. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  29142. /**
  29143. * Set the value of an uniform to a Color3
  29144. * @param uniform defines the webGL uniform location where to store the value
  29145. * @param color3 defines the color to store
  29146. */
  29147. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  29148. /**
  29149. * Set the value of an uniform to a Color3 and an alpha value
  29150. * @param uniform defines the webGL uniform location where to store the value
  29151. * @param color3 defines the color to store
  29152. * @param alpha defines the alpha component to store
  29153. */
  29154. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  29155. /**
  29156. * Sets a Color4 on a uniform variable
  29157. * @param uniform defines the uniform location
  29158. * @param color4 defines the value to be set
  29159. */
  29160. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  29161. /**
  29162. * Set various states to the webGL context
  29163. * @param culling defines backface culling state
  29164. * @param zOffset defines the value to apply to zOffset (0 by default)
  29165. * @param force defines if states must be applied even if cache is up to date
  29166. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  29167. */
  29168. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  29169. /**
  29170. * Set the z offset to apply to current rendering
  29171. * @param value defines the offset to apply
  29172. */
  29173. setZOffset(value: number): void;
  29174. /**
  29175. * Gets the current value of the zOffset
  29176. * @returns the current zOffset state
  29177. */
  29178. getZOffset(): number;
  29179. /**
  29180. * Enable or disable depth buffering
  29181. * @param enable defines the state to set
  29182. */
  29183. setDepthBuffer(enable: boolean): void;
  29184. /**
  29185. * Gets a boolean indicating if depth writing is enabled
  29186. * @returns the current depth writing state
  29187. */
  29188. getDepthWrite(): boolean;
  29189. /**
  29190. * Enable or disable depth writing
  29191. * @param enable defines the state to set
  29192. */
  29193. setDepthWrite(enable: boolean): void;
  29194. /**
  29195. * Enable or disable color writing
  29196. * @param enable defines the state to set
  29197. */
  29198. setColorWrite(enable: boolean): void;
  29199. /**
  29200. * Gets a boolean indicating if color writing is enabled
  29201. * @returns the current color writing state
  29202. */
  29203. getColorWrite(): boolean;
  29204. /**
  29205. * Sets alpha constants used by some alpha blending modes
  29206. * @param r defines the red component
  29207. * @param g defines the green component
  29208. * @param b defines the blue component
  29209. * @param a defines the alpha component
  29210. */
  29211. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  29212. /**
  29213. * Sets the current alpha mode
  29214. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  29215. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  29216. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29217. */
  29218. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  29219. /**
  29220. * Gets the current alpha mode
  29221. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  29222. * @returns the current alpha mode
  29223. */
  29224. getAlphaMode(): number;
  29225. /**
  29226. * Clears the list of texture accessible through engine.
  29227. * This can help preventing texture load conflict due to name collision.
  29228. */
  29229. clearInternalTexturesCache(): void;
  29230. /**
  29231. * Force the entire cache to be cleared
  29232. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  29233. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  29234. */
  29235. wipeCaches(bruteForce?: boolean): void;
  29236. /**
  29237. * Set the compressed texture format to use, based on the formats you have, and the formats
  29238. * supported by the hardware / browser.
  29239. *
  29240. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  29241. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  29242. * to API arguments needed to compressed textures. This puts the burden on the container
  29243. * generator to house the arcane code for determining these for current & future formats.
  29244. *
  29245. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  29246. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  29247. *
  29248. * Note: The result of this call is not taken into account when a texture is base64.
  29249. *
  29250. * @param formatsAvailable defines the list of those format families you have created
  29251. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  29252. *
  29253. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  29254. * @returns The extension selected.
  29255. */
  29256. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  29257. /** @hidden */
  29258. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  29259. min: number;
  29260. mag: number;
  29261. };
  29262. private _partialLoadImg;
  29263. private _cascadeLoadImgs;
  29264. /** @hidden */
  29265. _createTexture(): WebGLTexture;
  29266. /**
  29267. * Usually called from Texture.ts.
  29268. * Passed information to create a WebGLTexture
  29269. * @param urlArg defines a value which contains one of the following:
  29270. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  29271. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  29272. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  29273. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  29274. * @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)
  29275. * @param scene needed for loading to the correct scene
  29276. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  29277. * @param onLoad optional callback to be called upon successful completion
  29278. * @param onError optional callback to be called upon failure
  29279. * @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
  29280. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  29281. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  29282. * @param forcedExtension defines the extension to use to pick the right loader
  29283. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  29284. * @returns a InternalTexture for assignment back into BABYLON.Texture
  29285. */
  29286. 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;
  29287. private _rescaleTexture;
  29288. private _unpackFlipYCached;
  29289. /**
  29290. * In case you are sharing the context with other applications, it might
  29291. * be interested to not cache the unpack flip y state to ensure a consistent
  29292. * value would be set.
  29293. */
  29294. enableUnpackFlipYCached: boolean;
  29295. /** @hidden */
  29296. _unpackFlipY(value: boolean): void;
  29297. /** @hidden */
  29298. _getUnpackAlignement(): number;
  29299. /**
  29300. * Creates a dynamic texture
  29301. * @param width defines the width of the texture
  29302. * @param height defines the height of the texture
  29303. * @param generateMipMaps defines if the engine should generate the mip levels
  29304. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  29305. * @returns the dynamic texture inside an InternalTexture
  29306. */
  29307. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  29308. /**
  29309. * Update the sampling mode of a given texture
  29310. * @param samplingMode defines the required sampling mode
  29311. * @param texture defines the texture to update
  29312. */
  29313. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  29314. /**
  29315. * Update the content of a dynamic texture
  29316. * @param texture defines the texture to update
  29317. * @param canvas defines the canvas containing the source
  29318. * @param invertY defines if data must be stored with Y axis inverted
  29319. * @param premulAlpha defines if alpha is stored as premultiplied
  29320. * @param format defines the format of the data
  29321. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  29322. */
  29323. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  29324. /**
  29325. * Update a video texture
  29326. * @param texture defines the texture to update
  29327. * @param video defines the video element to use
  29328. * @param invertY defines if data must be stored with Y axis inverted
  29329. */
  29330. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  29331. /**
  29332. * Updates a depth texture Comparison Mode and Function.
  29333. * If the comparison Function is equal to 0, the mode will be set to none.
  29334. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  29335. * @param texture The texture to set the comparison function for
  29336. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  29337. */
  29338. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  29339. private _setupDepthStencilTexture;
  29340. /**
  29341. * Creates a depth stencil texture.
  29342. * This is only available in WebGL 2 or with the depth texture extension available.
  29343. * @param size The size of face edge in the texture.
  29344. * @param options The options defining the texture.
  29345. * @returns The texture
  29346. */
  29347. createDepthStencilTexture(size: number | {
  29348. width: number;
  29349. height: number;
  29350. }, options: DepthTextureCreationOptions): InternalTexture;
  29351. /**
  29352. * Creates a depth stencil texture.
  29353. * This is only available in WebGL 2 or with the depth texture extension available.
  29354. * @param size The size of face edge in the texture.
  29355. * @param options The options defining the texture.
  29356. * @returns The texture
  29357. */
  29358. private _createDepthStencilTexture;
  29359. /**
  29360. * Creates a depth stencil cube texture.
  29361. * This is only available in WebGL 2.
  29362. * @param size The size of face edge in the cube texture.
  29363. * @param options The options defining the cube texture.
  29364. * @returns The cube texture
  29365. */
  29366. private _createDepthStencilCubeTexture;
  29367. /**
  29368. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  29369. * @param renderTarget The render target to set the frame buffer for
  29370. */
  29371. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  29372. /**
  29373. * Creates a new render target texture
  29374. * @param size defines the size of the texture
  29375. * @param options defines the options used to create the texture
  29376. * @returns a new render target texture stored in an InternalTexture
  29377. */
  29378. createRenderTargetTexture(size: number | {
  29379. width: number;
  29380. height: number;
  29381. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  29382. /**
  29383. * Create a multi render target texture
  29384. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  29385. * @param size defines the size of the texture
  29386. * @param options defines the creation options
  29387. * @returns the cube texture as an InternalTexture
  29388. */
  29389. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  29390. private _setupFramebufferDepthAttachments;
  29391. /**
  29392. * Updates the sample count of a render target texture
  29393. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29394. * @param texture defines the texture to update
  29395. * @param samples defines the sample count to set
  29396. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29397. */
  29398. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  29399. /**
  29400. * Update the sample count for a given multiple render target texture
  29401. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  29402. * @param textures defines the textures to update
  29403. * @param samples defines the sample count to set
  29404. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  29405. */
  29406. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  29407. /** @hidden */
  29408. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29409. /** @hidden */
  29410. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29411. /** @hidden */
  29412. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  29413. /** @hidden */
  29414. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  29415. /**
  29416. * Creates a new render target cube texture
  29417. * @param size defines the size of the texture
  29418. * @param options defines the options used to create the texture
  29419. * @returns a new render target cube texture stored in an InternalTexture
  29420. */
  29421. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  29422. /**
  29423. * Creates a cube texture
  29424. * @param rootUrl defines the url where the files to load is located
  29425. * @param scene defines the current scene
  29426. * @param files defines the list of files to load (1 per face)
  29427. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  29428. * @param onLoad defines an optional callback raised when the texture is loaded
  29429. * @param onError defines an optional callback raised if there is an issue to load the texture
  29430. * @param format defines the format of the data
  29431. * @param forcedExtension defines the extension to use to pick the right loader
  29432. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  29433. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  29434. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  29435. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  29436. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  29437. * @returns the cube texture as an InternalTexture
  29438. */
  29439. 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;
  29440. /**
  29441. * @hidden
  29442. */
  29443. _setCubeMapTextureParams(loadMipmap: boolean): void;
  29444. private _prepareWebGLTextureContinuation;
  29445. private _prepareWebGLTexture;
  29446. /** @hidden */
  29447. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  29448. /** @hidden */
  29449. _releaseFramebufferObjects(texture: InternalTexture): void;
  29450. /** @hidden */
  29451. _releaseTexture(texture: InternalTexture): void;
  29452. private setProgram;
  29453. private _boundUniforms;
  29454. /**
  29455. * Binds an effect to the webGL context
  29456. * @param effect defines the effect to bind
  29457. */
  29458. bindSamplers(effect: Effect): void;
  29459. private _activateCurrentTexture;
  29460. /** @hidden */
  29461. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  29462. /** @hidden */
  29463. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  29464. /**
  29465. * Sets a texture to the webGL context from a postprocess
  29466. * @param channel defines the channel to use
  29467. * @param postProcess defines the source postprocess
  29468. */
  29469. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  29470. /**
  29471. * Binds the output of the passed in post process to the texture channel specified
  29472. * @param channel The channel the texture should be bound to
  29473. * @param postProcess The post process which's output should be bound
  29474. */
  29475. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  29476. /**
  29477. * Unbind all textures from the webGL context
  29478. */
  29479. unbindAllTextures(): void;
  29480. /**
  29481. * Sets a texture to the according uniform.
  29482. * @param channel The texture channel
  29483. * @param uniform The uniform to set
  29484. * @param texture The texture to apply
  29485. */
  29486. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  29487. /**
  29488. * Sets a depth stencil texture from a render target to the according uniform.
  29489. * @param channel The texture channel
  29490. * @param uniform The uniform to set
  29491. * @param texture The render target texture containing the depth stencil texture to apply
  29492. */
  29493. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  29494. private _bindSamplerUniformToChannel;
  29495. private _getTextureWrapMode;
  29496. private _setTexture;
  29497. /**
  29498. * Sets an array of texture to the webGL context
  29499. * @param channel defines the channel where the texture array must be set
  29500. * @param uniform defines the associated uniform location
  29501. * @param textures defines the array of textures to bind
  29502. */
  29503. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  29504. /** @hidden */
  29505. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  29506. private _setTextureParameterFloat;
  29507. private _setTextureParameterInteger;
  29508. /**
  29509. * Reads pixels from the current frame buffer. Please note that this function can be slow
  29510. * @param x defines the x coordinate of the rectangle where pixels must be read
  29511. * @param y defines the y coordinate of the rectangle where pixels must be read
  29512. * @param width defines the width of the rectangle where pixels must be read
  29513. * @param height defines the height of the rectangle where pixels must be read
  29514. * @returns a Uint8Array containing RGBA colors
  29515. */
  29516. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  29517. /**
  29518. * Add an externaly attached data from its key.
  29519. * This method call will fail and return false, if such key already exists.
  29520. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  29521. * @param key the unique key that identifies the data
  29522. * @param data the data object to associate to the key for this Engine instance
  29523. * @return true if no such key were already present and the data was added successfully, false otherwise
  29524. */
  29525. addExternalData<T>(key: string, data: T): boolean;
  29526. /**
  29527. * Get an externaly attached data from its key
  29528. * @param key the unique key that identifies the data
  29529. * @return the associated data, if present (can be null), or undefined if not present
  29530. */
  29531. getExternalData<T>(key: string): T;
  29532. /**
  29533. * Get an externaly attached data from its key, create it using a factory if it's not already present
  29534. * @param key the unique key that identifies the data
  29535. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  29536. * @return the associated data, can be null if the factory returned null.
  29537. */
  29538. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  29539. /**
  29540. * Remove an externaly attached data from the Engine instance
  29541. * @param key the unique key that identifies the data
  29542. * @return true if the data was successfully removed, false if it doesn't exist
  29543. */
  29544. removeExternalData(key: string): boolean;
  29545. /**
  29546. * Unbind all vertex attributes from the webGL context
  29547. */
  29548. unbindAllAttributes(): void;
  29549. /**
  29550. * 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
  29551. */
  29552. releaseEffects(): void;
  29553. /**
  29554. * Dispose and release all associated resources
  29555. */
  29556. dispose(): void;
  29557. /**
  29558. * Display the loading screen
  29559. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29560. */
  29561. displayLoadingUI(): void;
  29562. /**
  29563. * Hide the loading screen
  29564. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29565. */
  29566. hideLoadingUI(): void;
  29567. /**
  29568. * Gets the current loading screen object
  29569. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29570. */
  29571. /**
  29572. * Sets the current loading screen object
  29573. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29574. */
  29575. loadingScreen: ILoadingScreen;
  29576. /**
  29577. * Sets the current loading screen text
  29578. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29579. */
  29580. loadingUIText: string;
  29581. /**
  29582. * Sets the current loading screen background color
  29583. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  29584. */
  29585. loadingUIBackgroundColor: string;
  29586. /**
  29587. * Attach a new callback raised when context lost event is fired
  29588. * @param callback defines the callback to call
  29589. */
  29590. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29591. /**
  29592. * Attach a new callback raised when context restored event is fired
  29593. * @param callback defines the callback to call
  29594. */
  29595. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  29596. /**
  29597. * Gets the source code of the vertex shader associated with a specific webGL program
  29598. * @param program defines the program to use
  29599. * @returns a string containing the source code of the vertex shader associated with the program
  29600. */
  29601. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  29602. /**
  29603. * Gets the source code of the fragment shader associated with a specific webGL program
  29604. * @param program defines the program to use
  29605. * @returns a string containing the source code of the fragment shader associated with the program
  29606. */
  29607. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  29608. /**
  29609. * Get the current error code of the webGL context
  29610. * @returns the error code
  29611. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  29612. */
  29613. getError(): number;
  29614. /**
  29615. * Gets the current framerate
  29616. * @returns a number representing the framerate
  29617. */
  29618. getFps(): number;
  29619. /**
  29620. * Gets the time spent between current and previous frame
  29621. * @returns a number representing the delta time in ms
  29622. */
  29623. getDeltaTime(): number;
  29624. private _measureFps;
  29625. /** @hidden */
  29626. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  29627. private _canRenderToFloatFramebuffer;
  29628. private _canRenderToHalfFloatFramebuffer;
  29629. private _canRenderToFramebuffer;
  29630. /** @hidden */
  29631. _getWebGLTextureType(type: number): number;
  29632. /** @hidden */
  29633. _getInternalFormat(format: number): number;
  29634. /** @hidden */
  29635. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  29636. /** @hidden */
  29637. _getRGBAMultiSampleBufferFormat(type: number): number;
  29638. /** @hidden */
  29639. _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;
  29640. /** @hidden */
  29641. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  29642. private _partialLoadFile;
  29643. private _cascadeLoadFiles;
  29644. /**
  29645. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  29646. * @returns true if the engine can be created
  29647. * @ignorenaming
  29648. */
  29649. static isSupported(): boolean;
  29650. }
  29651. }
  29652. declare module "babylonjs/Materials/effect" {
  29653. import { Observable } from "babylonjs/Misc/observable";
  29654. import { Nullable } from "babylonjs/types";
  29655. import { Matrix, Vector3, Vector2, Color3, Color4, Vector4 } from "babylonjs/Maths/math";
  29656. import { IDisposable } from "babylonjs/scene";
  29657. import { Engine } from "babylonjs/Engines/engine";
  29658. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  29659. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  29660. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  29661. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  29662. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29663. /**
  29664. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  29665. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  29666. */
  29667. export class EffectFallbacks {
  29668. private _defines;
  29669. private _currentRank;
  29670. private _maxRank;
  29671. private _mesh;
  29672. /**
  29673. * Removes the fallback from the bound mesh.
  29674. */
  29675. unBindMesh(): void;
  29676. /**
  29677. * Adds a fallback on the specified property.
  29678. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29679. * @param define The name of the define in the shader
  29680. */
  29681. addFallback(rank: number, define: string): void;
  29682. /**
  29683. * Sets the mesh to use CPU skinning when needing to fallback.
  29684. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  29685. * @param mesh The mesh to use the fallbacks.
  29686. */
  29687. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  29688. /**
  29689. * Checks to see if more fallbacks are still availible.
  29690. */
  29691. readonly isMoreFallbacks: boolean;
  29692. /**
  29693. * Removes the defines that shoould be removed when falling back.
  29694. * @param currentDefines defines the current define statements for the shader.
  29695. * @param effect defines the current effect we try to compile
  29696. * @returns The resulting defines with defines of the current rank removed.
  29697. */
  29698. reduce(currentDefines: string, effect: Effect): string;
  29699. }
  29700. /**
  29701. * Options to be used when creating an effect.
  29702. */
  29703. export class EffectCreationOptions {
  29704. /**
  29705. * Atrributes that will be used in the shader.
  29706. */
  29707. attributes: string[];
  29708. /**
  29709. * Uniform varible names that will be set in the shader.
  29710. */
  29711. uniformsNames: string[];
  29712. /**
  29713. * Uniform buffer varible names that will be set in the shader.
  29714. */
  29715. uniformBuffersNames: string[];
  29716. /**
  29717. * Sampler texture variable names that will be set in the shader.
  29718. */
  29719. samplers: string[];
  29720. /**
  29721. * Define statements that will be set in the shader.
  29722. */
  29723. defines: any;
  29724. /**
  29725. * Possible fallbacks for this effect to improve performance when needed.
  29726. */
  29727. fallbacks: Nullable<EffectFallbacks>;
  29728. /**
  29729. * Callback that will be called when the shader is compiled.
  29730. */
  29731. onCompiled: Nullable<(effect: Effect) => void>;
  29732. /**
  29733. * Callback that will be called if an error occurs during shader compilation.
  29734. */
  29735. onError: Nullable<(effect: Effect, errors: string) => void>;
  29736. /**
  29737. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29738. */
  29739. indexParameters: any;
  29740. /**
  29741. * Max number of lights that can be used in the shader.
  29742. */
  29743. maxSimultaneousLights: number;
  29744. /**
  29745. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  29746. */
  29747. transformFeedbackVaryings: Nullable<string[]>;
  29748. }
  29749. /**
  29750. * Effect containing vertex and fragment shader that can be executed on an object.
  29751. */
  29752. export class Effect implements IDisposable {
  29753. /**
  29754. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  29755. */
  29756. static ShadersRepository: string;
  29757. /**
  29758. * Name of the effect.
  29759. */
  29760. name: any;
  29761. /**
  29762. * String container all the define statements that should be set on the shader.
  29763. */
  29764. defines: string;
  29765. /**
  29766. * Callback that will be called when the shader is compiled.
  29767. */
  29768. onCompiled: Nullable<(effect: Effect) => void>;
  29769. /**
  29770. * Callback that will be called if an error occurs during shader compilation.
  29771. */
  29772. onError: Nullable<(effect: Effect, errors: string) => void>;
  29773. /**
  29774. * Callback that will be called when effect is bound.
  29775. */
  29776. onBind: Nullable<(effect: Effect) => void>;
  29777. /**
  29778. * Unique ID of the effect.
  29779. */
  29780. uniqueId: number;
  29781. /**
  29782. * Observable that will be called when the shader is compiled.
  29783. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  29784. */
  29785. onCompileObservable: Observable<Effect>;
  29786. /**
  29787. * Observable that will be called if an error occurs during shader compilation.
  29788. */
  29789. onErrorObservable: Observable<Effect>;
  29790. /** @hidden */
  29791. _onBindObservable: Nullable<Observable<Effect>>;
  29792. /**
  29793. * Observable that will be called when effect is bound.
  29794. */
  29795. readonly onBindObservable: Observable<Effect>;
  29796. /** @hidden */
  29797. _bonesComputationForcedToCPU: boolean;
  29798. private static _uniqueIdSeed;
  29799. private _engine;
  29800. private _uniformBuffersNames;
  29801. private _uniformsNames;
  29802. private _samplerList;
  29803. private _samplers;
  29804. private _isReady;
  29805. private _compilationError;
  29806. private _attributesNames;
  29807. private _attributes;
  29808. private _uniforms;
  29809. /**
  29810. * Key for the effect.
  29811. * @hidden
  29812. */
  29813. _key: string;
  29814. private _indexParameters;
  29815. private _fallbacks;
  29816. private _vertexSourceCode;
  29817. private _fragmentSourceCode;
  29818. private _vertexSourceCodeOverride;
  29819. private _fragmentSourceCodeOverride;
  29820. private _transformFeedbackVaryings;
  29821. /**
  29822. * Compiled shader to webGL program.
  29823. * @hidden
  29824. */
  29825. _program: WebGLProgram;
  29826. private _valueCache;
  29827. private static _baseCache;
  29828. /**
  29829. * Instantiates an effect.
  29830. * An effect can be used to create/manage/execute vertex and fragment shaders.
  29831. * @param baseName Name of the effect.
  29832. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  29833. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  29834. * @param samplers List of sampler variables that will be passed to the shader.
  29835. * @param engine Engine to be used to render the effect
  29836. * @param defines Define statements to be added to the shader.
  29837. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  29838. * @param onCompiled Callback that will be called when the shader is compiled.
  29839. * @param onError Callback that will be called if an error occurs during shader compilation.
  29840. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  29841. */
  29842. 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);
  29843. /**
  29844. * Unique key for this effect
  29845. */
  29846. readonly key: string;
  29847. /**
  29848. * If the effect has been compiled and prepared.
  29849. * @returns if the effect is compiled and prepared.
  29850. */
  29851. isReady(): boolean;
  29852. /**
  29853. * The engine the effect was initialized with.
  29854. * @returns the engine.
  29855. */
  29856. getEngine(): Engine;
  29857. /**
  29858. * The compiled webGL program for the effect
  29859. * @returns the webGL program.
  29860. */
  29861. getProgram(): WebGLProgram;
  29862. /**
  29863. * The set of names of attribute variables for the shader.
  29864. * @returns An array of attribute names.
  29865. */
  29866. getAttributesNames(): string[];
  29867. /**
  29868. * Returns the attribute at the given index.
  29869. * @param index The index of the attribute.
  29870. * @returns The location of the attribute.
  29871. */
  29872. getAttributeLocation(index: number): number;
  29873. /**
  29874. * Returns the attribute based on the name of the variable.
  29875. * @param name of the attribute to look up.
  29876. * @returns the attribute location.
  29877. */
  29878. getAttributeLocationByName(name: string): number;
  29879. /**
  29880. * The number of attributes.
  29881. * @returns the numnber of attributes.
  29882. */
  29883. getAttributesCount(): number;
  29884. /**
  29885. * Gets the index of a uniform variable.
  29886. * @param uniformName of the uniform to look up.
  29887. * @returns the index.
  29888. */
  29889. getUniformIndex(uniformName: string): number;
  29890. /**
  29891. * Returns the attribute based on the name of the variable.
  29892. * @param uniformName of the uniform to look up.
  29893. * @returns the location of the uniform.
  29894. */
  29895. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  29896. /**
  29897. * Returns an array of sampler variable names
  29898. * @returns The array of sampler variable neames.
  29899. */
  29900. getSamplers(): string[];
  29901. /**
  29902. * The error from the last compilation.
  29903. * @returns the error string.
  29904. */
  29905. getCompilationError(): string;
  29906. /**
  29907. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  29908. * @param func The callback to be used.
  29909. */
  29910. executeWhenCompiled(func: (effect: Effect) => void): void;
  29911. private _checkIsReady;
  29912. /** @hidden */
  29913. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  29914. /** @hidden */
  29915. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  29916. /** @hidden */
  29917. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  29918. private _processShaderConversion;
  29919. private _processIncludes;
  29920. private _processPrecision;
  29921. /**
  29922. * Recompiles the webGL program
  29923. * @param vertexSourceCode The source code for the vertex shader.
  29924. * @param fragmentSourceCode The source code for the fragment shader.
  29925. * @param onCompiled Callback called when completed.
  29926. * @param onError Callback called on error.
  29927. * @hidden
  29928. */
  29929. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  29930. /**
  29931. * Gets the uniform locations of the the specified variable names
  29932. * @param names THe names of the variables to lookup.
  29933. * @returns Array of locations in the same order as variable names.
  29934. */
  29935. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  29936. /**
  29937. * Prepares the effect
  29938. * @hidden
  29939. */
  29940. _prepareEffect(): void;
  29941. /**
  29942. * Checks if the effect is supported. (Must be called after compilation)
  29943. */
  29944. readonly isSupported: boolean;
  29945. /**
  29946. * Binds a texture to the engine to be used as output of the shader.
  29947. * @param channel Name of the output variable.
  29948. * @param texture Texture to bind.
  29949. * @hidden
  29950. */
  29951. _bindTexture(channel: string, texture: InternalTexture): void;
  29952. /**
  29953. * Sets a texture on the engine to be used in the shader.
  29954. * @param channel Name of the sampler variable.
  29955. * @param texture Texture to set.
  29956. */
  29957. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  29958. /**
  29959. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  29960. * @param channel Name of the sampler variable.
  29961. * @param texture Texture to set.
  29962. */
  29963. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  29964. /**
  29965. * Sets an array of textures on the engine to be used in the shader.
  29966. * @param channel Name of the variable.
  29967. * @param textures Textures to set.
  29968. */
  29969. setTextureArray(channel: string, textures: BaseTexture[]): void;
  29970. /**
  29971. * 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)
  29972. * @param channel Name of the sampler variable.
  29973. * @param postProcess Post process to get the input texture from.
  29974. */
  29975. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  29976. /**
  29977. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  29978. * 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)
  29979. * @param channel Name of the sampler variable.
  29980. * @param postProcess Post process to get the output texture from.
  29981. */
  29982. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  29983. /** @hidden */
  29984. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  29985. /** @hidden */
  29986. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  29987. /** @hidden */
  29988. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  29989. /** @hidden */
  29990. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  29991. /**
  29992. * Binds a buffer to a uniform.
  29993. * @param buffer Buffer to bind.
  29994. * @param name Name of the uniform variable to bind to.
  29995. */
  29996. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  29997. /**
  29998. * Binds block to a uniform.
  29999. * @param blockName Name of the block to bind.
  30000. * @param index Index to bind.
  30001. */
  30002. bindUniformBlock(blockName: string, index: number): void;
  30003. /**
  30004. * Sets an interger value on a uniform variable.
  30005. * @param uniformName Name of the variable.
  30006. * @param value Value to be set.
  30007. * @returns this effect.
  30008. */
  30009. setInt(uniformName: string, value: number): Effect;
  30010. /**
  30011. * Sets an int array on a uniform variable.
  30012. * @param uniformName Name of the variable.
  30013. * @param array array to be set.
  30014. * @returns this effect.
  30015. */
  30016. setIntArray(uniformName: string, array: Int32Array): Effect;
  30017. /**
  30018. * 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)
  30019. * @param uniformName Name of the variable.
  30020. * @param array array to be set.
  30021. * @returns this effect.
  30022. */
  30023. setIntArray2(uniformName: string, array: Int32Array): Effect;
  30024. /**
  30025. * 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)
  30026. * @param uniformName Name of the variable.
  30027. * @param array array to be set.
  30028. * @returns this effect.
  30029. */
  30030. setIntArray3(uniformName: string, array: Int32Array): Effect;
  30031. /**
  30032. * 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)
  30033. * @param uniformName Name of the variable.
  30034. * @param array array to be set.
  30035. * @returns this effect.
  30036. */
  30037. setIntArray4(uniformName: string, array: Int32Array): Effect;
  30038. /**
  30039. * Sets an float array on a uniform variable.
  30040. * @param uniformName Name of the variable.
  30041. * @param array array to be set.
  30042. * @returns this effect.
  30043. */
  30044. setFloatArray(uniformName: string, array: Float32Array): Effect;
  30045. /**
  30046. * 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)
  30047. * @param uniformName Name of the variable.
  30048. * @param array array to be set.
  30049. * @returns this effect.
  30050. */
  30051. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  30052. /**
  30053. * 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)
  30054. * @param uniformName Name of the variable.
  30055. * @param array array to be set.
  30056. * @returns this effect.
  30057. */
  30058. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  30059. /**
  30060. * 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)
  30061. * @param uniformName Name of the variable.
  30062. * @param array array to be set.
  30063. * @returns this effect.
  30064. */
  30065. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  30066. /**
  30067. * Sets an array on a uniform variable.
  30068. * @param uniformName Name of the variable.
  30069. * @param array array to be set.
  30070. * @returns this effect.
  30071. */
  30072. setArray(uniformName: string, array: number[]): Effect;
  30073. /**
  30074. * 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)
  30075. * @param uniformName Name of the variable.
  30076. * @param array array to be set.
  30077. * @returns this effect.
  30078. */
  30079. setArray2(uniformName: string, array: number[]): Effect;
  30080. /**
  30081. * 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)
  30082. * @param uniformName Name of the variable.
  30083. * @param array array to be set.
  30084. * @returns this effect.
  30085. */
  30086. setArray3(uniformName: string, array: number[]): Effect;
  30087. /**
  30088. * 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)
  30089. * @param uniformName Name of the variable.
  30090. * @param array array to be set.
  30091. * @returns this effect.
  30092. */
  30093. setArray4(uniformName: string, array: number[]): Effect;
  30094. /**
  30095. * Sets matrices on a uniform variable.
  30096. * @param uniformName Name of the variable.
  30097. * @param matrices matrices to be set.
  30098. * @returns this effect.
  30099. */
  30100. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  30101. /**
  30102. * Sets matrix on a uniform variable.
  30103. * @param uniformName Name of the variable.
  30104. * @param matrix matrix to be set.
  30105. * @returns this effect.
  30106. */
  30107. setMatrix(uniformName: string, matrix: Matrix): Effect;
  30108. /**
  30109. * 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)
  30110. * @param uniformName Name of the variable.
  30111. * @param matrix matrix to be set.
  30112. * @returns this effect.
  30113. */
  30114. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  30115. /**
  30116. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  30117. * @param uniformName Name of the variable.
  30118. * @param matrix matrix to be set.
  30119. * @returns this effect.
  30120. */
  30121. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  30122. /**
  30123. * Sets a float on a uniform variable.
  30124. * @param uniformName Name of the variable.
  30125. * @param value value to be set.
  30126. * @returns this effect.
  30127. */
  30128. setFloat(uniformName: string, value: number): Effect;
  30129. /**
  30130. * Sets a boolean on a uniform variable.
  30131. * @param uniformName Name of the variable.
  30132. * @param bool value to be set.
  30133. * @returns this effect.
  30134. */
  30135. setBool(uniformName: string, bool: boolean): Effect;
  30136. /**
  30137. * Sets a Vector2 on a uniform variable.
  30138. * @param uniformName Name of the variable.
  30139. * @param vector2 vector2 to be set.
  30140. * @returns this effect.
  30141. */
  30142. setVector2(uniformName: string, vector2: Vector2): Effect;
  30143. /**
  30144. * Sets a float2 on a uniform variable.
  30145. * @param uniformName Name of the variable.
  30146. * @param x First float in float2.
  30147. * @param y Second float in float2.
  30148. * @returns this effect.
  30149. */
  30150. setFloat2(uniformName: string, x: number, y: number): Effect;
  30151. /**
  30152. * Sets a Vector3 on a uniform variable.
  30153. * @param uniformName Name of the variable.
  30154. * @param vector3 Value to be set.
  30155. * @returns this effect.
  30156. */
  30157. setVector3(uniformName: string, vector3: Vector3): Effect;
  30158. /**
  30159. * Sets a float3 on a uniform variable.
  30160. * @param uniformName Name of the variable.
  30161. * @param x First float in float3.
  30162. * @param y Second float in float3.
  30163. * @param z Third float in float3.
  30164. * @returns this effect.
  30165. */
  30166. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  30167. /**
  30168. * Sets a Vector4 on a uniform variable.
  30169. * @param uniformName Name of the variable.
  30170. * @param vector4 Value to be set.
  30171. * @returns this effect.
  30172. */
  30173. setVector4(uniformName: string, vector4: Vector4): Effect;
  30174. /**
  30175. * Sets a float4 on a uniform variable.
  30176. * @param uniformName Name of the variable.
  30177. * @param x First float in float4.
  30178. * @param y Second float in float4.
  30179. * @param z Third float in float4.
  30180. * @param w Fourth float in float4.
  30181. * @returns this effect.
  30182. */
  30183. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  30184. /**
  30185. * Sets a Color3 on a uniform variable.
  30186. * @param uniformName Name of the variable.
  30187. * @param color3 Value to be set.
  30188. * @returns this effect.
  30189. */
  30190. setColor3(uniformName: string, color3: Color3): Effect;
  30191. /**
  30192. * Sets a Color4 on a uniform variable.
  30193. * @param uniformName Name of the variable.
  30194. * @param color3 Value to be set.
  30195. * @param alpha Alpha value to be set.
  30196. * @returns this effect.
  30197. */
  30198. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  30199. /**
  30200. * Sets a Color4 on a uniform variable
  30201. * @param uniformName defines the name of the variable
  30202. * @param color4 defines the value to be set
  30203. * @returns this effect.
  30204. */
  30205. setDirectColor4(uniformName: string, color4: Color4): Effect;
  30206. /** Release all associated resources */
  30207. dispose(): void;
  30208. /**
  30209. * This function will add a new shader to the shader store
  30210. * @param name the name of the shader
  30211. * @param pixelShader optional pixel shader content
  30212. * @param vertexShader optional vertex shader content
  30213. */
  30214. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  30215. /**
  30216. * Store of each shader (The can be looked up using effect.key)
  30217. */
  30218. static ShadersStore: {
  30219. [key: string]: string;
  30220. };
  30221. /**
  30222. * Store of each included file for a shader (The can be looked up using effect.key)
  30223. */
  30224. static IncludesShadersStore: {
  30225. [key: string]: string;
  30226. };
  30227. /**
  30228. * Resets the cache of effects.
  30229. */
  30230. static ResetCache(): void;
  30231. }
  30232. }
  30233. declare module "babylonjs/Materials/colorCurves" {
  30234. import { Effect } from "babylonjs/Materials/effect";
  30235. /**
  30236. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  30237. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  30238. * 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;
  30239. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  30240. */
  30241. export class ColorCurves {
  30242. private _dirty;
  30243. private _tempColor;
  30244. private _globalCurve;
  30245. private _highlightsCurve;
  30246. private _midtonesCurve;
  30247. private _shadowsCurve;
  30248. private _positiveCurve;
  30249. private _negativeCurve;
  30250. private _globalHue;
  30251. private _globalDensity;
  30252. private _globalSaturation;
  30253. private _globalExposure;
  30254. /**
  30255. * Gets the global Hue value.
  30256. * 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).
  30257. */
  30258. /**
  30259. * Sets the global Hue value.
  30260. * 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).
  30261. */
  30262. globalHue: number;
  30263. /**
  30264. * Gets the global Density value.
  30265. * 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.
  30266. * Values less than zero provide a filter of opposite hue.
  30267. */
  30268. /**
  30269. * Sets the global Density value.
  30270. * 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.
  30271. * Values less than zero provide a filter of opposite hue.
  30272. */
  30273. globalDensity: number;
  30274. /**
  30275. * Gets the global Saturation value.
  30276. * 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.
  30277. */
  30278. /**
  30279. * Sets the global Saturation value.
  30280. * 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.
  30281. */
  30282. globalSaturation: number;
  30283. /**
  30284. * Gets the global Exposure value.
  30285. * 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.
  30286. */
  30287. /**
  30288. * Sets the global Exposure value.
  30289. * 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.
  30290. */
  30291. globalExposure: number;
  30292. private _highlightsHue;
  30293. private _highlightsDensity;
  30294. private _highlightsSaturation;
  30295. private _highlightsExposure;
  30296. /**
  30297. * Gets the highlights Hue value.
  30298. * 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).
  30299. */
  30300. /**
  30301. * Sets the highlights Hue value.
  30302. * 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).
  30303. */
  30304. highlightsHue: number;
  30305. /**
  30306. * Gets the highlights Density value.
  30307. * 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.
  30308. * Values less than zero provide a filter of opposite hue.
  30309. */
  30310. /**
  30311. * Sets the highlights Density value.
  30312. * 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.
  30313. * Values less than zero provide a filter of opposite hue.
  30314. */
  30315. highlightsDensity: number;
  30316. /**
  30317. * Gets the highlights Saturation value.
  30318. * 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.
  30319. */
  30320. /**
  30321. * Sets the highlights Saturation value.
  30322. * 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.
  30323. */
  30324. highlightsSaturation: number;
  30325. /**
  30326. * Gets the highlights Exposure value.
  30327. * 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.
  30328. */
  30329. /**
  30330. * Sets the highlights Exposure value.
  30331. * 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.
  30332. */
  30333. highlightsExposure: number;
  30334. private _midtonesHue;
  30335. private _midtonesDensity;
  30336. private _midtonesSaturation;
  30337. private _midtonesExposure;
  30338. /**
  30339. * Gets the midtones Hue value.
  30340. * 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).
  30341. */
  30342. /**
  30343. * Sets the midtones Hue value.
  30344. * 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).
  30345. */
  30346. midtonesHue: number;
  30347. /**
  30348. * Gets the midtones Density value.
  30349. * 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.
  30350. * Values less than zero provide a filter of opposite hue.
  30351. */
  30352. /**
  30353. * Sets the midtones Density value.
  30354. * 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.
  30355. * Values less than zero provide a filter of opposite hue.
  30356. */
  30357. midtonesDensity: number;
  30358. /**
  30359. * Gets the midtones Saturation value.
  30360. * 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.
  30361. */
  30362. /**
  30363. * Sets the midtones Saturation value.
  30364. * 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.
  30365. */
  30366. midtonesSaturation: number;
  30367. /**
  30368. * Gets the midtones Exposure value.
  30369. * 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.
  30370. */
  30371. /**
  30372. * Sets the midtones Exposure value.
  30373. * 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.
  30374. */
  30375. midtonesExposure: number;
  30376. private _shadowsHue;
  30377. private _shadowsDensity;
  30378. private _shadowsSaturation;
  30379. private _shadowsExposure;
  30380. /**
  30381. * Gets the shadows Hue value.
  30382. * 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).
  30383. */
  30384. /**
  30385. * Sets the shadows Hue value.
  30386. * 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).
  30387. */
  30388. shadowsHue: number;
  30389. /**
  30390. * Gets the shadows Density value.
  30391. * 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.
  30392. * Values less than zero provide a filter of opposite hue.
  30393. */
  30394. /**
  30395. * Sets the shadows Density value.
  30396. * 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.
  30397. * Values less than zero provide a filter of opposite hue.
  30398. */
  30399. shadowsDensity: number;
  30400. /**
  30401. * Gets the shadows Saturation value.
  30402. * 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.
  30403. */
  30404. /**
  30405. * Sets the shadows Saturation value.
  30406. * 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.
  30407. */
  30408. shadowsSaturation: number;
  30409. /**
  30410. * Gets the shadows Exposure value.
  30411. * 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.
  30412. */
  30413. /**
  30414. * Sets the shadows Exposure value.
  30415. * 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.
  30416. */
  30417. shadowsExposure: number;
  30418. /**
  30419. * Returns the class name
  30420. * @returns The class name
  30421. */
  30422. getClassName(): string;
  30423. /**
  30424. * Binds the color curves to the shader.
  30425. * @param colorCurves The color curve to bind
  30426. * @param effect The effect to bind to
  30427. * @param positiveUniform The positive uniform shader parameter
  30428. * @param neutralUniform The neutral uniform shader parameter
  30429. * @param negativeUniform The negative uniform shader parameter
  30430. */
  30431. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  30432. /**
  30433. * Prepare the list of uniforms associated with the ColorCurves effects.
  30434. * @param uniformsList The list of uniforms used in the effect
  30435. */
  30436. static PrepareUniforms(uniformsList: string[]): void;
  30437. /**
  30438. * Returns color grading data based on a hue, density, saturation and exposure value.
  30439. * @param filterHue The hue of the color filter.
  30440. * @param filterDensity The density of the color filter.
  30441. * @param saturation The saturation.
  30442. * @param exposure The exposure.
  30443. * @param result The result data container.
  30444. */
  30445. private getColorGradingDataToRef;
  30446. /**
  30447. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  30448. * @param value The input slider value in range [-100,100].
  30449. * @returns Adjusted value.
  30450. */
  30451. private static applyColorGradingSliderNonlinear;
  30452. /**
  30453. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  30454. * @param hue The hue (H) input.
  30455. * @param saturation The saturation (S) input.
  30456. * @param brightness The brightness (B) input.
  30457. * @result An RGBA color represented as Vector4.
  30458. */
  30459. private static fromHSBToRef;
  30460. /**
  30461. * Returns a value clamped between min and max
  30462. * @param value The value to clamp
  30463. * @param min The minimum of value
  30464. * @param max The maximum of value
  30465. * @returns The clamped value.
  30466. */
  30467. private static clamp;
  30468. /**
  30469. * Clones the current color curve instance.
  30470. * @return The cloned curves
  30471. */
  30472. clone(): ColorCurves;
  30473. /**
  30474. * Serializes the current color curve instance to a json representation.
  30475. * @return a JSON representation
  30476. */
  30477. serialize(): any;
  30478. /**
  30479. * Parses the color curve from a json representation.
  30480. * @param source the JSON source to parse
  30481. * @return The parsed curves
  30482. */
  30483. static Parse(source: any): ColorCurves;
  30484. }
  30485. }
  30486. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  30487. import { Observable } from "babylonjs/Misc/observable";
  30488. import { Nullable } from "babylonjs/types";
  30489. import { Color4 } from "babylonjs/Maths/math";
  30490. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  30491. import { Effect } from "babylonjs/Materials/effect";
  30492. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  30493. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  30494. /**
  30495. * Interface to follow in your material defines to integrate easily the
  30496. * Image proccessing functions.
  30497. * @hidden
  30498. */
  30499. export interface IImageProcessingConfigurationDefines {
  30500. IMAGEPROCESSING: boolean;
  30501. VIGNETTE: boolean;
  30502. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30503. VIGNETTEBLENDMODEOPAQUE: boolean;
  30504. TONEMAPPING: boolean;
  30505. TONEMAPPING_ACES: boolean;
  30506. CONTRAST: boolean;
  30507. EXPOSURE: boolean;
  30508. COLORCURVES: boolean;
  30509. COLORGRADING: boolean;
  30510. COLORGRADING3D: boolean;
  30511. SAMPLER3DGREENDEPTH: boolean;
  30512. SAMPLER3DBGRMAP: boolean;
  30513. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30514. }
  30515. /**
  30516. * @hidden
  30517. */
  30518. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  30519. IMAGEPROCESSING: boolean;
  30520. VIGNETTE: boolean;
  30521. VIGNETTEBLENDMODEMULTIPLY: boolean;
  30522. VIGNETTEBLENDMODEOPAQUE: boolean;
  30523. TONEMAPPING: boolean;
  30524. TONEMAPPING_ACES: boolean;
  30525. CONTRAST: boolean;
  30526. COLORCURVES: boolean;
  30527. COLORGRADING: boolean;
  30528. COLORGRADING3D: boolean;
  30529. SAMPLER3DGREENDEPTH: boolean;
  30530. SAMPLER3DBGRMAP: boolean;
  30531. IMAGEPROCESSINGPOSTPROCESS: boolean;
  30532. EXPOSURE: boolean;
  30533. constructor();
  30534. }
  30535. /**
  30536. * This groups together the common properties used for image processing either in direct forward pass
  30537. * or through post processing effect depending on the use of the image processing pipeline in your scene
  30538. * or not.
  30539. */
  30540. export class ImageProcessingConfiguration {
  30541. /**
  30542. * Default tone mapping applied in BabylonJS.
  30543. */
  30544. static readonly TONEMAPPING_STANDARD: number;
  30545. /**
  30546. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  30547. * to other engines rendering to increase portability.
  30548. */
  30549. static readonly TONEMAPPING_ACES: number;
  30550. /**
  30551. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  30552. */
  30553. colorCurves: Nullable<ColorCurves>;
  30554. private _colorCurvesEnabled;
  30555. /**
  30556. * Gets wether the color curves effect is enabled.
  30557. */
  30558. /**
  30559. * Sets wether the color curves effect is enabled.
  30560. */
  30561. colorCurvesEnabled: boolean;
  30562. private _colorGradingTexture;
  30563. /**
  30564. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30565. */
  30566. /**
  30567. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  30568. */
  30569. colorGradingTexture: Nullable<BaseTexture>;
  30570. private _colorGradingEnabled;
  30571. /**
  30572. * Gets wether the color grading effect is enabled.
  30573. */
  30574. /**
  30575. * Sets wether the color grading effect is enabled.
  30576. */
  30577. colorGradingEnabled: boolean;
  30578. private _colorGradingWithGreenDepth;
  30579. /**
  30580. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  30581. */
  30582. /**
  30583. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  30584. */
  30585. colorGradingWithGreenDepth: boolean;
  30586. private _colorGradingBGR;
  30587. /**
  30588. * Gets wether the color grading texture contains BGR values.
  30589. */
  30590. /**
  30591. * Sets wether the color grading texture contains BGR values.
  30592. */
  30593. colorGradingBGR: boolean;
  30594. /** @hidden */
  30595. _exposure: number;
  30596. /**
  30597. * Gets the Exposure used in the effect.
  30598. */
  30599. /**
  30600. * Sets the Exposure used in the effect.
  30601. */
  30602. exposure: number;
  30603. private _toneMappingEnabled;
  30604. /**
  30605. * Gets wether the tone mapping effect is enabled.
  30606. */
  30607. /**
  30608. * Sets wether the tone mapping effect is enabled.
  30609. */
  30610. toneMappingEnabled: boolean;
  30611. private _toneMappingType;
  30612. /**
  30613. * Gets the type of tone mapping effect.
  30614. */
  30615. /**
  30616. * Sets the type of tone mapping effect used in BabylonJS.
  30617. */
  30618. toneMappingType: number;
  30619. protected _contrast: number;
  30620. /**
  30621. * Gets the contrast used in the effect.
  30622. */
  30623. /**
  30624. * Sets the contrast used in the effect.
  30625. */
  30626. contrast: number;
  30627. /**
  30628. * Vignette stretch size.
  30629. */
  30630. vignetteStretch: number;
  30631. /**
  30632. * Vignette centre X Offset.
  30633. */
  30634. vignetteCentreX: number;
  30635. /**
  30636. * Vignette centre Y Offset.
  30637. */
  30638. vignetteCentreY: number;
  30639. /**
  30640. * Vignette weight or intensity of the vignette effect.
  30641. */
  30642. vignetteWeight: number;
  30643. /**
  30644. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  30645. * if vignetteEnabled is set to true.
  30646. */
  30647. vignetteColor: Color4;
  30648. /**
  30649. * Camera field of view used by the Vignette effect.
  30650. */
  30651. vignetteCameraFov: number;
  30652. private _vignetteBlendMode;
  30653. /**
  30654. * Gets the vignette blend mode allowing different kind of effect.
  30655. */
  30656. /**
  30657. * Sets the vignette blend mode allowing different kind of effect.
  30658. */
  30659. vignetteBlendMode: number;
  30660. private _vignetteEnabled;
  30661. /**
  30662. * Gets wether the vignette effect is enabled.
  30663. */
  30664. /**
  30665. * Sets wether the vignette effect is enabled.
  30666. */
  30667. vignetteEnabled: boolean;
  30668. private _applyByPostProcess;
  30669. /**
  30670. * Gets wether the image processing is applied through a post process or not.
  30671. */
  30672. /**
  30673. * Sets wether the image processing is applied through a post process or not.
  30674. */
  30675. applyByPostProcess: boolean;
  30676. private _isEnabled;
  30677. /**
  30678. * Gets wether the image processing is enabled or not.
  30679. */
  30680. /**
  30681. * Sets wether the image processing is enabled or not.
  30682. */
  30683. isEnabled: boolean;
  30684. /**
  30685. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  30686. */
  30687. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  30688. /**
  30689. * Method called each time the image processing information changes requires to recompile the effect.
  30690. */
  30691. protected _updateParameters(): void;
  30692. /**
  30693. * Gets the current class name.
  30694. * @return "ImageProcessingConfiguration"
  30695. */
  30696. getClassName(): string;
  30697. /**
  30698. * Prepare the list of uniforms associated with the Image Processing effects.
  30699. * @param uniforms The list of uniforms used in the effect
  30700. * @param defines the list of defines currently in use
  30701. */
  30702. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  30703. /**
  30704. * Prepare the list of samplers associated with the Image Processing effects.
  30705. * @param samplersList The list of uniforms used in the effect
  30706. * @param defines the list of defines currently in use
  30707. */
  30708. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  30709. /**
  30710. * Prepare the list of defines associated to the shader.
  30711. * @param defines the list of defines to complete
  30712. * @param forPostProcess Define if we are currently in post process mode or not
  30713. */
  30714. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  30715. /**
  30716. * Returns true if all the image processing information are ready.
  30717. * @returns True if ready, otherwise, false
  30718. */
  30719. isReady(): boolean;
  30720. /**
  30721. * Binds the image processing to the shader.
  30722. * @param effect The effect to bind to
  30723. * @param aspectRatio Define the current aspect ratio of the effect
  30724. */
  30725. bind(effect: Effect, aspectRatio?: number): void;
  30726. /**
  30727. * Clones the current image processing instance.
  30728. * @return The cloned image processing
  30729. */
  30730. clone(): ImageProcessingConfiguration;
  30731. /**
  30732. * Serializes the current image processing instance to a json representation.
  30733. * @return a JSON representation
  30734. */
  30735. serialize(): any;
  30736. /**
  30737. * Parses the image processing from a json representation.
  30738. * @param source the JSON source to parse
  30739. * @return The parsed image processing
  30740. */
  30741. static Parse(source: any): ImageProcessingConfiguration;
  30742. private static _VIGNETTEMODE_MULTIPLY;
  30743. private static _VIGNETTEMODE_OPAQUE;
  30744. /**
  30745. * Used to apply the vignette as a mix with the pixel color.
  30746. */
  30747. static readonly VIGNETTEMODE_MULTIPLY: number;
  30748. /**
  30749. * Used to apply the vignette as a replacement of the pixel color.
  30750. */
  30751. static readonly VIGNETTEMODE_OPAQUE: number;
  30752. }
  30753. }
  30754. declare module "babylonjs/Materials/fresnelParameters" {
  30755. import { Color3 } from "babylonjs/Maths/math";
  30756. /**
  30757. * This represents all the required information to add a fresnel effect on a material:
  30758. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  30759. */
  30760. export class FresnelParameters {
  30761. private _isEnabled;
  30762. /**
  30763. * Define if the fresnel effect is enable or not.
  30764. */
  30765. isEnabled: boolean;
  30766. /**
  30767. * Define the color used on edges (grazing angle)
  30768. */
  30769. leftColor: Color3;
  30770. /**
  30771. * Define the color used on center
  30772. */
  30773. rightColor: Color3;
  30774. /**
  30775. * Define bias applied to computed fresnel term
  30776. */
  30777. bias: number;
  30778. /**
  30779. * Defined the power exponent applied to fresnel term
  30780. */
  30781. power: number;
  30782. /**
  30783. * Clones the current fresnel and its valuues
  30784. * @returns a clone fresnel configuration
  30785. */
  30786. clone(): FresnelParameters;
  30787. /**
  30788. * Serializes the current fresnel parameters to a JSON representation.
  30789. * @return the JSON serialization
  30790. */
  30791. serialize(): any;
  30792. /**
  30793. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  30794. * @param parsedFresnelParameters Define the JSON representation
  30795. * @returns the parsed parameters
  30796. */
  30797. static Parse(parsedFresnelParameters: any): FresnelParameters;
  30798. }
  30799. }
  30800. declare module "babylonjs/Misc/decorators" {
  30801. import { Nullable } from "babylonjs/types";
  30802. import { Scene } from "babylonjs/scene";
  30803. import { IAnimatable } from "babylonjs/Misc/tools";
  30804. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  30805. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30806. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30807. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30808. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30809. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30810. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30811. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30812. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30813. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30814. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30815. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30816. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30817. /**
  30818. * Decorator used to define property that can be serialized as reference to a camera
  30819. * @param sourceName defines the name of the property to decorate
  30820. */
  30821. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  30822. /**
  30823. * Class used to help serialization objects
  30824. */
  30825. export class SerializationHelper {
  30826. /** hidden */
  30827. static _ImageProcessingConfigurationParser: (sourceProperty: any) => import("babylonjs/Materials/imageProcessingConfiguration").ImageProcessingConfiguration;
  30828. /** hidden */
  30829. static _FresnelParametersParser: (sourceProperty: any) => import("babylonjs/Materials/fresnelParameters").FresnelParameters;
  30830. /** hidden */
  30831. static _ColorCurvesParser: (sourceProperty: any) => import("babylonjs/Materials/colorCurves").ColorCurves;
  30832. /** hidden */
  30833. static _TextureParser: (sourceProperty: any, scene: import("babylonjs/scene").Scene, rootUrl: string) => Nullable<import("babylonjs/Materials/Textures/baseTexture").BaseTexture>;
  30834. /**
  30835. * Appends the serialized animations from the source animations
  30836. * @param source Source containing the animations
  30837. * @param destination Target to store the animations
  30838. */
  30839. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  30840. /**
  30841. * Static function used to serialized a specific entity
  30842. * @param entity defines the entity to serialize
  30843. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  30844. * @returns a JSON compatible object representing the serialization of the entity
  30845. */
  30846. static Serialize<T>(entity: T, serializationObject?: any): any;
  30847. /**
  30848. * Creates a new entity from a serialization data object
  30849. * @param creationFunction defines a function used to instanciated the new entity
  30850. * @param source defines the source serialization data
  30851. * @param scene defines the hosting scene
  30852. * @param rootUrl defines the root url for resources
  30853. * @returns a new entity
  30854. */
  30855. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  30856. /**
  30857. * Clones an object
  30858. * @param creationFunction defines the function used to instanciate the new object
  30859. * @param source defines the source object
  30860. * @returns the cloned object
  30861. */
  30862. static Clone<T>(creationFunction: () => T, source: T): T;
  30863. /**
  30864. * Instanciates a new object based on a source one (some data will be shared between both object)
  30865. * @param creationFunction defines the function used to instanciate the new object
  30866. * @param source defines the source object
  30867. * @returns the new object
  30868. */
  30869. static Instanciate<T>(creationFunction: () => T, source: T): T;
  30870. }
  30871. }
  30872. declare module "babylonjs/Cameras/camera" {
  30873. import { SmartArray } from "babylonjs/Misc/smartArray";
  30874. import { Observable } from "babylonjs/Misc/observable";
  30875. import { Nullable } from "babylonjs/types";
  30876. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30877. import { Scene } from "babylonjs/scene";
  30878. import { Matrix, Vector3, Viewport } from "babylonjs/Maths/math";
  30879. import { Node } from "babylonjs/node";
  30880. import { Mesh } from "babylonjs/Meshes/mesh";
  30881. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30882. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30883. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30884. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30885. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30886. import { Ray } from "babylonjs/Culling/ray";
  30887. /**
  30888. * This is the base class of all the camera used in the application.
  30889. * @see http://doc.babylonjs.com/features/cameras
  30890. */
  30891. export class Camera extends Node {
  30892. /** @hidden */
  30893. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30894. /**
  30895. * This is the default projection mode used by the cameras.
  30896. * It helps recreating a feeling of perspective and better appreciate depth.
  30897. * This is the best way to simulate real life cameras.
  30898. */
  30899. static readonly PERSPECTIVE_CAMERA: number;
  30900. /**
  30901. * This helps creating camera with an orthographic mode.
  30902. * 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.
  30903. */
  30904. static readonly ORTHOGRAPHIC_CAMERA: number;
  30905. /**
  30906. * This is the default FOV mode for perspective cameras.
  30907. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30908. */
  30909. static readonly FOVMODE_VERTICAL_FIXED: number;
  30910. /**
  30911. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30912. */
  30913. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30914. /**
  30915. * This specifies ther is no need for a camera rig.
  30916. * Basically only one eye is rendered corresponding to the camera.
  30917. */
  30918. static readonly RIG_MODE_NONE: number;
  30919. /**
  30920. * Simulates a camera Rig with one blue eye and one red eye.
  30921. * This can be use with 3d blue and red glasses.
  30922. */
  30923. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30924. /**
  30925. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30926. */
  30927. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30928. /**
  30929. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30930. */
  30931. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30932. /**
  30933. * Defines that both eyes of the camera will be rendered over under each other.
  30934. */
  30935. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30936. /**
  30937. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30938. */
  30939. static readonly RIG_MODE_VR: number;
  30940. /**
  30941. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30942. */
  30943. static readonly RIG_MODE_WEBVR: number;
  30944. /**
  30945. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30946. */
  30947. static readonly RIG_MODE_CUSTOM: number;
  30948. /**
  30949. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30950. */
  30951. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30952. /**
  30953. * Define the input manager associated with the camera.
  30954. */
  30955. inputs: CameraInputsManager<Camera>;
  30956. /** @hidden */
  30957. _position: Vector3;
  30958. /**
  30959. * Define the current local position of the camera in the scene
  30960. */
  30961. position: Vector3;
  30962. /**
  30963. * The vector the camera should consider as up.
  30964. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30965. */
  30966. upVector: Vector3;
  30967. /**
  30968. * Define the current limit on the left side for an orthographic camera
  30969. * In scene unit
  30970. */
  30971. orthoLeft: Nullable<number>;
  30972. /**
  30973. * Define the current limit on the right side for an orthographic camera
  30974. * In scene unit
  30975. */
  30976. orthoRight: Nullable<number>;
  30977. /**
  30978. * Define the current limit on the bottom side for an orthographic camera
  30979. * In scene unit
  30980. */
  30981. orthoBottom: Nullable<number>;
  30982. /**
  30983. * Define the current limit on the top side for an orthographic camera
  30984. * In scene unit
  30985. */
  30986. orthoTop: Nullable<number>;
  30987. /**
  30988. * Field Of View is set in Radians. (default is 0.8)
  30989. */
  30990. fov: number;
  30991. /**
  30992. * Define the minimum distance the camera can see from.
  30993. * This is important to note that the depth buffer are not infinite and the closer it starts
  30994. * the more your scene might encounter depth fighting issue.
  30995. */
  30996. minZ: number;
  30997. /**
  30998. * Define the maximum distance the camera can see to.
  30999. * This is important to note that the depth buffer are not infinite and the further it end
  31000. * the more your scene might encounter depth fighting issue.
  31001. */
  31002. maxZ: number;
  31003. /**
  31004. * Define the default inertia of the camera.
  31005. * This helps giving a smooth feeling to the camera movement.
  31006. */
  31007. inertia: number;
  31008. /**
  31009. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  31010. */
  31011. mode: number;
  31012. /**
  31013. * Define wether the camera is intermediate.
  31014. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  31015. */
  31016. isIntermediate: boolean;
  31017. /**
  31018. * Define the viewport of the camera.
  31019. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  31020. */
  31021. viewport: Viewport;
  31022. /**
  31023. * Restricts the camera to viewing objects with the same layerMask.
  31024. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  31025. */
  31026. layerMask: number;
  31027. /**
  31028. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  31029. */
  31030. fovMode: number;
  31031. /**
  31032. * Rig mode of the camera.
  31033. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  31034. * This is normally controlled byt the camera themselves as internal use.
  31035. */
  31036. cameraRigMode: number;
  31037. /**
  31038. * Defines the distance between both "eyes" in case of a RIG
  31039. */
  31040. interaxialDistance: number;
  31041. /**
  31042. * Defines if stereoscopic rendering is done side by side or over under.
  31043. */
  31044. isStereoscopicSideBySide: boolean;
  31045. /**
  31046. * 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
  31047. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  31048. * else in the scene.
  31049. */
  31050. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  31051. /**
  31052. * When set, the camera will render to this render target instead of the default canvas
  31053. */
  31054. outputRenderTarget: Nullable<RenderTargetTexture>;
  31055. /**
  31056. * Observable triggered when the camera view matrix has changed.
  31057. */
  31058. onViewMatrixChangedObservable: Observable<Camera>;
  31059. /**
  31060. * Observable triggered when the camera Projection matrix has changed.
  31061. */
  31062. onProjectionMatrixChangedObservable: Observable<Camera>;
  31063. /**
  31064. * Observable triggered when the inputs have been processed.
  31065. */
  31066. onAfterCheckInputsObservable: Observable<Camera>;
  31067. /**
  31068. * Observable triggered when reset has been called and applied to the camera.
  31069. */
  31070. onRestoreStateObservable: Observable<Camera>;
  31071. /** @hidden */
  31072. _cameraRigParams: any;
  31073. /** @hidden */
  31074. _rigCameras: Camera[];
  31075. /** @hidden */
  31076. _rigPostProcess: Nullable<PostProcess>;
  31077. protected _webvrViewMatrix: Matrix;
  31078. /** @hidden */
  31079. _skipRendering: boolean;
  31080. /** @hidden */
  31081. _projectionMatrix: Matrix;
  31082. /** @hidden */
  31083. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  31084. /** @hidden */
  31085. _activeMeshes: SmartArray<AbstractMesh>;
  31086. protected _globalPosition: Vector3;
  31087. /** hidden */
  31088. _computedViewMatrix: Matrix;
  31089. private _doNotComputeProjectionMatrix;
  31090. private _transformMatrix;
  31091. private _frustumPlanes;
  31092. private _refreshFrustumPlanes;
  31093. private _storedFov;
  31094. private _stateStored;
  31095. /**
  31096. * Instantiates a new camera object.
  31097. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  31098. * @see http://doc.babylonjs.com/features/cameras
  31099. * @param name Defines the name of the camera in the scene
  31100. * @param position Defines the position of the camera
  31101. * @param scene Defines the scene the camera belongs too
  31102. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  31103. */
  31104. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  31105. /**
  31106. * Store current camera state (fov, position, etc..)
  31107. * @returns the camera
  31108. */
  31109. storeState(): Camera;
  31110. /**
  31111. * Restores the camera state values if it has been stored. You must call storeState() first
  31112. */
  31113. protected _restoreStateValues(): boolean;
  31114. /**
  31115. * Restored camera state. You must call storeState() first.
  31116. * @returns true if restored and false otherwise
  31117. */
  31118. restoreState(): boolean;
  31119. /**
  31120. * Gets the class name of the camera.
  31121. * @returns the class name
  31122. */
  31123. getClassName(): string;
  31124. /** @hidden */
  31125. readonly _isCamera: boolean;
  31126. /**
  31127. * Gets a string representation of the camera useful for debug purpose.
  31128. * @param fullDetails Defines that a more verboe level of logging is required
  31129. * @returns the string representation
  31130. */
  31131. toString(fullDetails?: boolean): string;
  31132. /**
  31133. * Gets the current world space position of the camera.
  31134. */
  31135. readonly globalPosition: Vector3;
  31136. /**
  31137. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  31138. * @returns the active meshe list
  31139. */
  31140. getActiveMeshes(): SmartArray<AbstractMesh>;
  31141. /**
  31142. * Check wether a mesh is part of the current active mesh list of the camera
  31143. * @param mesh Defines the mesh to check
  31144. * @returns true if active, false otherwise
  31145. */
  31146. isActiveMesh(mesh: Mesh): boolean;
  31147. /**
  31148. * Is this camera ready to be used/rendered
  31149. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  31150. * @return true if the camera is ready
  31151. */
  31152. isReady(completeCheck?: boolean): boolean;
  31153. /** @hidden */
  31154. _initCache(): void;
  31155. /** @hidden */
  31156. _updateCache(ignoreParentClass?: boolean): void;
  31157. /** @hidden */
  31158. _isSynchronized(): boolean;
  31159. /** @hidden */
  31160. _isSynchronizedViewMatrix(): boolean;
  31161. /** @hidden */
  31162. _isSynchronizedProjectionMatrix(): boolean;
  31163. /**
  31164. * Attach the input controls to a specific dom element to get the input from.
  31165. * @param element Defines the element the controls should be listened from
  31166. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  31167. */
  31168. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  31169. /**
  31170. * Detach the current controls from the specified dom element.
  31171. * @param element Defines the element to stop listening the inputs from
  31172. */
  31173. detachControl(element: HTMLElement): void;
  31174. /**
  31175. * Update the camera state according to the different inputs gathered during the frame.
  31176. */
  31177. update(): void;
  31178. /** @hidden */
  31179. _checkInputs(): void;
  31180. /** @hidden */
  31181. readonly rigCameras: Camera[];
  31182. /**
  31183. * Gets the post process used by the rig cameras
  31184. */
  31185. readonly rigPostProcess: Nullable<PostProcess>;
  31186. /**
  31187. * Internal, gets the first post proces.
  31188. * @returns the first post process to be run on this camera.
  31189. */
  31190. _getFirstPostProcess(): Nullable<PostProcess>;
  31191. private _cascadePostProcessesToRigCams;
  31192. /**
  31193. * Attach a post process to the camera.
  31194. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31195. * @param postProcess The post process to attach to the camera
  31196. * @param insertAt The position of the post process in case several of them are in use in the scene
  31197. * @returns the position the post process has been inserted at
  31198. */
  31199. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  31200. /**
  31201. * Detach a post process to the camera.
  31202. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  31203. * @param postProcess The post process to detach from the camera
  31204. */
  31205. detachPostProcess(postProcess: PostProcess): void;
  31206. /**
  31207. * Gets the current world matrix of the camera
  31208. */
  31209. getWorldMatrix(): Matrix;
  31210. /** @hidden */
  31211. _getViewMatrix(): Matrix;
  31212. /**
  31213. * Gets the current view matrix of the camera.
  31214. * @param force forces the camera to recompute the matrix without looking at the cached state
  31215. * @returns the view matrix
  31216. */
  31217. getViewMatrix(force?: boolean): Matrix;
  31218. /**
  31219. * Freeze the projection matrix.
  31220. * It will prevent the cache check of the camera projection compute and can speed up perf
  31221. * if no parameter of the camera are meant to change
  31222. * @param projection Defines manually a projection if necessary
  31223. */
  31224. freezeProjectionMatrix(projection?: Matrix): void;
  31225. /**
  31226. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  31227. */
  31228. unfreezeProjectionMatrix(): void;
  31229. /**
  31230. * Gets the current projection matrix of the camera.
  31231. * @param force forces the camera to recompute the matrix without looking at the cached state
  31232. * @returns the projection matrix
  31233. */
  31234. getProjectionMatrix(force?: boolean): Matrix;
  31235. /**
  31236. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  31237. * @returns a Matrix
  31238. */
  31239. getTransformationMatrix(): Matrix;
  31240. private _updateFrustumPlanes;
  31241. /**
  31242. * Checks if a cullable object (mesh...) is in the camera frustum
  31243. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  31244. * @param target The object to check
  31245. * @returns true if the object is in frustum otherwise false
  31246. */
  31247. isInFrustum(target: ICullable): boolean;
  31248. /**
  31249. * Checks if a cullable object (mesh...) is in the camera frustum
  31250. * Unlike isInFrustum this cheks the full bounding box
  31251. * @param target The object to check
  31252. * @returns true if the object is in frustum otherwise false
  31253. */
  31254. isCompletelyInFrustum(target: ICullable): boolean;
  31255. /**
  31256. * Gets a ray in the forward direction from the camera.
  31257. * @param length Defines the length of the ray to create
  31258. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  31259. * @param origin Defines the start point of the ray which defaults to the camera position
  31260. * @returns the forward ray
  31261. */
  31262. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  31263. /**
  31264. * Releases resources associated with this node.
  31265. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  31266. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  31267. */
  31268. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  31269. /** @hidden */
  31270. _isLeftCamera: boolean;
  31271. /**
  31272. * Gets the left camera of a rig setup in case of Rigged Camera
  31273. */
  31274. readonly isLeftCamera: boolean;
  31275. /** @hidden */
  31276. _isRightCamera: boolean;
  31277. /**
  31278. * Gets the right camera of a rig setup in case of Rigged Camera
  31279. */
  31280. readonly isRightCamera: boolean;
  31281. /**
  31282. * Gets the left camera of a rig setup in case of Rigged Camera
  31283. */
  31284. readonly leftCamera: Nullable<FreeCamera>;
  31285. /**
  31286. * Gets the right camera of a rig setup in case of Rigged Camera
  31287. */
  31288. readonly rightCamera: Nullable<FreeCamera>;
  31289. /**
  31290. * Gets the left camera target of a rig setup in case of Rigged Camera
  31291. * @returns the target position
  31292. */
  31293. getLeftTarget(): Nullable<Vector3>;
  31294. /**
  31295. * Gets the right camera target of a rig setup in case of Rigged Camera
  31296. * @returns the target position
  31297. */
  31298. getRightTarget(): Nullable<Vector3>;
  31299. /**
  31300. * @hidden
  31301. */
  31302. setCameraRigMode(mode: number, rigParams: any): void;
  31303. /** @hidden */
  31304. static _setStereoscopicRigMode(camera: Camera): void;
  31305. /** @hidden */
  31306. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  31307. /** @hidden */
  31308. static _setVRRigMode(camera: Camera, rigParams: any): void;
  31309. /** @hidden */
  31310. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  31311. /** @hidden */
  31312. _getVRProjectionMatrix(): Matrix;
  31313. protected _updateCameraRotationMatrix(): void;
  31314. protected _updateWebVRCameraRotationMatrix(): void;
  31315. /**
  31316. * This function MUST be overwritten by the different WebVR cameras available.
  31317. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31318. * @hidden
  31319. */
  31320. _getWebVRProjectionMatrix(): Matrix;
  31321. /**
  31322. * This function MUST be overwritten by the different WebVR cameras available.
  31323. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  31324. * @hidden
  31325. */
  31326. _getWebVRViewMatrix(): Matrix;
  31327. /** @hidden */
  31328. setCameraRigParameter(name: string, value: any): void;
  31329. /**
  31330. * needs to be overridden by children so sub has required properties to be copied
  31331. * @hidden
  31332. */
  31333. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  31334. /**
  31335. * May need to be overridden by children
  31336. * @hidden
  31337. */
  31338. _updateRigCameras(): void;
  31339. /** @hidden */
  31340. _setupInputs(): void;
  31341. /**
  31342. * Serialiaze the camera setup to a json represention
  31343. * @returns the JSON representation
  31344. */
  31345. serialize(): any;
  31346. /**
  31347. * Clones the current camera.
  31348. * @param name The cloned camera name
  31349. * @returns the cloned camera
  31350. */
  31351. clone(name: string): Camera;
  31352. /**
  31353. * Gets the direction of the camera relative to a given local axis.
  31354. * @param localAxis Defines the reference axis to provide a relative direction.
  31355. * @return the direction
  31356. */
  31357. getDirection(localAxis: Vector3): Vector3;
  31358. /**
  31359. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31360. * @param localAxis Defines the reference axis to provide a relative direction.
  31361. * @param result Defines the vector to store the result in
  31362. */
  31363. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31364. /**
  31365. * Gets a camera constructor for a given camera type
  31366. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31367. * @param name The name of the camera the result will be able to instantiate
  31368. * @param scene The scene the result will construct the camera in
  31369. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31370. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31371. * @returns a factory method to construc the camera
  31372. */
  31373. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31374. /**
  31375. * Compute the world matrix of the camera.
  31376. * @returns the camera workd matrix
  31377. */
  31378. computeWorldMatrix(): Matrix;
  31379. /**
  31380. * Parse a JSON and creates the camera from the parsed information
  31381. * @param parsedCamera The JSON to parse
  31382. * @param scene The scene to instantiate the camera in
  31383. * @returns the newly constructed camera
  31384. */
  31385. static Parse(parsedCamera: any, scene: Scene): Camera;
  31386. }
  31387. }
  31388. declare module "babylonjs/Misc/tools" {
  31389. import { FloatArray, IndicesArray, Nullable } from "babylonjs/types";
  31390. import { Color4, Color3, Vector2, Vector3 } from "babylonjs/Maths/math";
  31391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  31392. import { Observable } from "babylonjs/Misc/observable";
  31393. import { DomManagement } from "babylonjs/Misc/domManagement";
  31394. import { WebRequest } from "babylonjs/Misc/webRequest";
  31395. import { Camera } from "babylonjs/Cameras/camera";
  31396. import { Engine } from "babylonjs/Engines/engine";
  31397. import { Animation } from "babylonjs/Animations/animation";
  31398. /**
  31399. * Interface for any object that can request an animation frame
  31400. */
  31401. export interface ICustomAnimationFrameRequester {
  31402. /**
  31403. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  31404. */
  31405. renderFunction?: Function;
  31406. /**
  31407. * Called to request the next frame to render to
  31408. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  31409. */
  31410. requestAnimationFrame: Function;
  31411. /**
  31412. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  31413. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  31414. */
  31415. requestID?: number;
  31416. }
  31417. /**
  31418. * Interface containing an array of animations
  31419. */
  31420. export interface IAnimatable {
  31421. /**
  31422. * Array of animations
  31423. */
  31424. animations: Nullable<Array<Animation>>;
  31425. }
  31426. /** Interface used by value gradients (color, factor, ...) */
  31427. export interface IValueGradient {
  31428. /**
  31429. * Gets or sets the gradient value (between 0 and 1)
  31430. */
  31431. gradient: number;
  31432. }
  31433. /** Class used to store color4 gradient */
  31434. export class ColorGradient implements IValueGradient {
  31435. /**
  31436. * Gets or sets the gradient value (between 0 and 1)
  31437. */
  31438. gradient: number;
  31439. /**
  31440. * Gets or sets first associated color
  31441. */
  31442. color1: Color4;
  31443. /**
  31444. * Gets or sets second associated color
  31445. */
  31446. color2?: Color4;
  31447. /**
  31448. * Will get a color picked randomly between color1 and color2.
  31449. * If color2 is undefined then color1 will be used
  31450. * @param result defines the target Color4 to store the result in
  31451. */
  31452. getColorToRef(result: Color4): void;
  31453. }
  31454. /** Class used to store color 3 gradient */
  31455. export class Color3Gradient implements IValueGradient {
  31456. /**
  31457. * Gets or sets the gradient value (between 0 and 1)
  31458. */
  31459. gradient: number;
  31460. /**
  31461. * Gets or sets the associated color
  31462. */
  31463. color: Color3;
  31464. }
  31465. /** Class used to store factor gradient */
  31466. export class FactorGradient implements IValueGradient {
  31467. /**
  31468. * Gets or sets the gradient value (between 0 and 1)
  31469. */
  31470. gradient: number;
  31471. /**
  31472. * Gets or sets first associated factor
  31473. */
  31474. factor1: number;
  31475. /**
  31476. * Gets or sets second associated factor
  31477. */
  31478. factor2?: number;
  31479. /**
  31480. * Will get a number picked randomly between factor1 and factor2.
  31481. * If factor2 is undefined then factor1 will be used
  31482. * @returns the picked number
  31483. */
  31484. getFactor(): number;
  31485. }
  31486. /**
  31487. * @ignore
  31488. * Application error to support additional information when loading a file
  31489. */
  31490. export class LoadFileError extends Error {
  31491. /** defines the optional web request */
  31492. request?: WebRequest | undefined;
  31493. private static _setPrototypeOf;
  31494. /**
  31495. * Creates a new LoadFileError
  31496. * @param message defines the message of the error
  31497. * @param request defines the optional web request
  31498. */
  31499. constructor(message: string,
  31500. /** defines the optional web request */
  31501. request?: WebRequest | undefined);
  31502. }
  31503. /**
  31504. * Class used to define a retry strategy when error happens while loading assets
  31505. */
  31506. export class RetryStrategy {
  31507. /**
  31508. * Function used to defines an exponential back off strategy
  31509. * @param maxRetries defines the maximum number of retries (3 by default)
  31510. * @param baseInterval defines the interval between retries
  31511. * @returns the strategy function to use
  31512. */
  31513. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  31514. }
  31515. /**
  31516. * File request interface
  31517. */
  31518. export interface IFileRequest {
  31519. /**
  31520. * Raised when the request is complete (success or error).
  31521. */
  31522. onCompleteObservable: Observable<IFileRequest>;
  31523. /**
  31524. * Aborts the request for a file.
  31525. */
  31526. abort: () => void;
  31527. }
  31528. /**
  31529. * Class containing a set of static utilities functions
  31530. */
  31531. export class Tools {
  31532. /**
  31533. * Gets or sets the base URL to use to load assets
  31534. */
  31535. static BaseUrl: string;
  31536. /**
  31537. * Enable/Disable Custom HTTP Request Headers globally.
  31538. * default = false
  31539. * @see CustomRequestHeaders
  31540. */
  31541. static UseCustomRequestHeaders: boolean;
  31542. /**
  31543. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  31544. * i.e. when loading files, where the server/service expects an Authorization header
  31545. */
  31546. static CustomRequestHeaders: {
  31547. [key: string]: string;
  31548. };
  31549. /**
  31550. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  31551. */
  31552. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  31553. /**
  31554. * Default behaviour for cors in the application.
  31555. * It can be a string if the expected behavior is identical in the entire app.
  31556. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  31557. */
  31558. static CorsBehavior: string | ((url: string | string[]) => string);
  31559. /**
  31560. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  31561. * @ignorenaming
  31562. */
  31563. static UseFallbackTexture: boolean;
  31564. /**
  31565. * Use this object to register external classes like custom textures or material
  31566. * to allow the laoders to instantiate them
  31567. */
  31568. static RegisteredExternalClasses: {
  31569. [key: string]: Object;
  31570. };
  31571. /**
  31572. * Texture content used if a texture cannot loaded
  31573. * @ignorenaming
  31574. */
  31575. static fallbackTexture: string;
  31576. /**
  31577. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  31578. * @param u defines the coordinate on X axis
  31579. * @param v defines the coordinate on Y axis
  31580. * @param width defines the width of the source data
  31581. * @param height defines the height of the source data
  31582. * @param pixels defines the source byte array
  31583. * @param color defines the output color
  31584. */
  31585. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  31586. /**
  31587. * Interpolates between a and b via alpha
  31588. * @param a The lower value (returned when alpha = 0)
  31589. * @param b The upper value (returned when alpha = 1)
  31590. * @param alpha The interpolation-factor
  31591. * @return The mixed value
  31592. */
  31593. static Mix(a: number, b: number, alpha: number): number;
  31594. /**
  31595. * Tries to instantiate a new object from a given class name
  31596. * @param className defines the class name to instantiate
  31597. * @returns the new object or null if the system was not able to do the instantiation
  31598. */
  31599. static Instantiate(className: string): any;
  31600. /**
  31601. * Provides a slice function that will work even on IE
  31602. * @param data defines the array to slice
  31603. * @param start defines the start of the data (optional)
  31604. * @param end defines the end of the data (optional)
  31605. * @returns the new sliced array
  31606. */
  31607. static Slice<T>(data: T, start?: number, end?: number): T;
  31608. /**
  31609. * Polyfill for setImmediate
  31610. * @param action defines the action to execute after the current execution block
  31611. */
  31612. static SetImmediate(action: () => void): void;
  31613. /**
  31614. * Function indicating if a number is an exponent of 2
  31615. * @param value defines the value to test
  31616. * @returns true if the value is an exponent of 2
  31617. */
  31618. static IsExponentOfTwo(value: number): boolean;
  31619. private static _tmpFloatArray;
  31620. /**
  31621. * Returns the nearest 32-bit single precision float representation of a Number
  31622. * @param value A Number. If the parameter is of a different type, it will get converted
  31623. * to a number or to NaN if it cannot be converted
  31624. * @returns number
  31625. */
  31626. static FloatRound(value: number): number;
  31627. /**
  31628. * Find the next highest power of two.
  31629. * @param x Number to start search from.
  31630. * @return Next highest power of two.
  31631. */
  31632. static CeilingPOT(x: number): number;
  31633. /**
  31634. * Find the next lowest power of two.
  31635. * @param x Number to start search from.
  31636. * @return Next lowest power of two.
  31637. */
  31638. static FloorPOT(x: number): number;
  31639. /**
  31640. * Find the nearest power of two.
  31641. * @param x Number to start search from.
  31642. * @return Next nearest power of two.
  31643. */
  31644. static NearestPOT(x: number): number;
  31645. /**
  31646. * Get the closest exponent of two
  31647. * @param value defines the value to approximate
  31648. * @param max defines the maximum value to return
  31649. * @param mode defines how to define the closest value
  31650. * @returns closest exponent of two of the given value
  31651. */
  31652. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  31653. /**
  31654. * Extracts the filename from a path
  31655. * @param path defines the path to use
  31656. * @returns the filename
  31657. */
  31658. static GetFilename(path: string): string;
  31659. /**
  31660. * Extracts the "folder" part of a path (everything before the filename).
  31661. * @param uri The URI to extract the info from
  31662. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  31663. * @returns The "folder" part of the path
  31664. */
  31665. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  31666. /**
  31667. * Extracts text content from a DOM element hierarchy
  31668. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  31669. */
  31670. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  31671. /**
  31672. * Convert an angle in radians to degrees
  31673. * @param angle defines the angle to convert
  31674. * @returns the angle in degrees
  31675. */
  31676. static ToDegrees(angle: number): number;
  31677. /**
  31678. * Convert an angle in degrees to radians
  31679. * @param angle defines the angle to convert
  31680. * @returns the angle in radians
  31681. */
  31682. static ToRadians(angle: number): number;
  31683. /**
  31684. * Encode a buffer to a base64 string
  31685. * @param buffer defines the buffer to encode
  31686. * @returns the encoded string
  31687. */
  31688. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  31689. /**
  31690. * Extracts minimum and maximum values from a list of indexed positions
  31691. * @param positions defines the positions to use
  31692. * @param indices defines the indices to the positions
  31693. * @param indexStart defines the start index
  31694. * @param indexCount defines the end index
  31695. * @param bias defines bias value to add to the result
  31696. * @return minimum and maximum values
  31697. */
  31698. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  31699. minimum: Vector3;
  31700. maximum: Vector3;
  31701. };
  31702. /**
  31703. * Extracts minimum and maximum values from a list of positions
  31704. * @param positions defines the positions to use
  31705. * @param start defines the start index in the positions array
  31706. * @param count defines the number of positions to handle
  31707. * @param bias defines bias value to add to the result
  31708. * @param stride defines the stride size to use (distance between two positions in the positions array)
  31709. * @return minimum and maximum values
  31710. */
  31711. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  31712. minimum: Vector3;
  31713. maximum: Vector3;
  31714. };
  31715. /**
  31716. * Returns an array if obj is not an array
  31717. * @param obj defines the object to evaluate as an array
  31718. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  31719. * @returns either obj directly if obj is an array or a new array containing obj
  31720. */
  31721. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  31722. /**
  31723. * Gets the pointer prefix to use
  31724. * @returns "pointer" if touch is enabled. Else returns "mouse"
  31725. */
  31726. static GetPointerPrefix(): string;
  31727. /**
  31728. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  31729. * @param func - the function to be called
  31730. * @param requester - the object that will request the next frame. Falls back to window.
  31731. * @returns frame number
  31732. */
  31733. static QueueNewFrame(func: () => void, requester?: any): number;
  31734. /**
  31735. * Ask the browser to promote the current element to fullscreen rendering mode
  31736. * @param element defines the DOM element to promote
  31737. */
  31738. static RequestFullscreen(element: HTMLElement): void;
  31739. /**
  31740. * Asks the browser to exit fullscreen mode
  31741. */
  31742. static ExitFullscreen(): void;
  31743. /**
  31744. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  31745. * @param url define the url we are trying
  31746. * @param element define the dom element where to configure the cors policy
  31747. */
  31748. static SetCorsBehavior(url: string | string[], element: {
  31749. crossOrigin: string | null;
  31750. }): void;
  31751. /**
  31752. * Removes unwanted characters from an url
  31753. * @param url defines the url to clean
  31754. * @returns the cleaned url
  31755. */
  31756. static CleanUrl(url: string): string;
  31757. /**
  31758. * Gets or sets a function used to pre-process url before using them to load assets
  31759. */
  31760. static PreprocessUrl: (url: string) => string;
  31761. /**
  31762. * Loads an image as an HTMLImageElement.
  31763. * @param input url string, ArrayBuffer, or Blob to load
  31764. * @param onLoad callback called when the image successfully loads
  31765. * @param onError callback called when the image fails to load
  31766. * @param offlineProvider offline provider for caching
  31767. * @returns the HTMLImageElement of the loaded image
  31768. */
  31769. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  31770. /**
  31771. * Loads a file
  31772. * @param url url string, ArrayBuffer, or Blob to load
  31773. * @param onSuccess callback called when the file successfully loads
  31774. * @param onProgress callback called while file is loading (if the server supports this mode)
  31775. * @param offlineProvider defines the offline provider for caching
  31776. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  31777. * @param onError callback called when the file fails to load
  31778. * @returns a file request object
  31779. */
  31780. 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;
  31781. /**
  31782. * Load a script (identified by an url). When the url returns, the
  31783. * content of this file is added into a new script element, attached to the DOM (body element)
  31784. * @param scriptUrl defines the url of the script to laod
  31785. * @param onSuccess defines the callback called when the script is loaded
  31786. * @param onError defines the callback to call if an error occurs
  31787. * @param scriptId defines the id of the script element
  31788. */
  31789. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  31790. /**
  31791. * Load an asynchronous script (identified by an url). When the url returns, the
  31792. * content of this file is added into a new script element, attached to the DOM (body element)
  31793. * @param scriptUrl defines the url of the script to laod
  31794. * @param scriptId defines the id of the script element
  31795. * @returns a promise request object
  31796. */
  31797. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  31798. /**
  31799. * Loads a file from a blob
  31800. * @param fileToLoad defines the blob to use
  31801. * @param callback defines the callback to call when data is loaded
  31802. * @param progressCallback defines the callback to call during loading process
  31803. * @returns a file request object
  31804. */
  31805. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  31806. /**
  31807. * Loads a file
  31808. * @param fileToLoad defines the file to load
  31809. * @param callback defines the callback to call when data is loaded
  31810. * @param progressCallBack defines the callback to call during loading process
  31811. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  31812. * @returns a file request object
  31813. */
  31814. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  31815. /**
  31816. * Creates a data url from a given string content
  31817. * @param content defines the content to convert
  31818. * @returns the new data url link
  31819. */
  31820. static FileAsURL(content: string): string;
  31821. /**
  31822. * Format the given number to a specific decimal format
  31823. * @param value defines the number to format
  31824. * @param decimals defines the number of decimals to use
  31825. * @returns the formatted string
  31826. */
  31827. static Format(value: number, decimals?: number): string;
  31828. /**
  31829. * Checks if a given vector is inside a specific range
  31830. * @param v defines the vector to test
  31831. * @param min defines the minimum range
  31832. * @param max defines the maximum range
  31833. */
  31834. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  31835. /**
  31836. * Tries to copy an object by duplicating every property
  31837. * @param source defines the source object
  31838. * @param destination defines the target object
  31839. * @param doNotCopyList defines a list of properties to avoid
  31840. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  31841. */
  31842. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  31843. /**
  31844. * Gets a boolean indicating if the given object has no own property
  31845. * @param obj defines the object to test
  31846. * @returns true if object has no own property
  31847. */
  31848. static IsEmpty(obj: any): boolean;
  31849. /**
  31850. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  31851. * @param str Source string
  31852. * @param suffix Suffix to search for in the source string
  31853. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  31854. */
  31855. static EndsWith(str: string, suffix: string): boolean;
  31856. /**
  31857. * Function used to register events at window level
  31858. * @param events defines the events to register
  31859. */
  31860. static RegisterTopRootEvents(events: {
  31861. name: string;
  31862. handler: Nullable<(e: FocusEvent) => any>;
  31863. }[]): void;
  31864. /**
  31865. * Function used to unregister events from window level
  31866. * @param events defines the events to unregister
  31867. */
  31868. static UnregisterTopRootEvents(events: {
  31869. name: string;
  31870. handler: Nullable<(e: FocusEvent) => any>;
  31871. }[]): void;
  31872. /**
  31873. * @ignore
  31874. */
  31875. static _ScreenshotCanvas: HTMLCanvasElement;
  31876. /**
  31877. * Dumps the current bound framebuffer
  31878. * @param width defines the rendering width
  31879. * @param height defines the rendering height
  31880. * @param engine defines the hosting engine
  31881. * @param successCallback defines the callback triggered once the data are available
  31882. * @param mimeType defines the mime type of the result
  31883. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  31884. */
  31885. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31886. /**
  31887. * Converts the canvas data to blob.
  31888. * This acts as a polyfill for browsers not supporting the to blob function.
  31889. * @param canvas Defines the canvas to extract the data from
  31890. * @param successCallback Defines the callback triggered once the data are available
  31891. * @param mimeType Defines the mime type of the result
  31892. */
  31893. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  31894. /**
  31895. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  31896. * @param successCallback defines the callback triggered once the data are available
  31897. * @param mimeType defines the mime type of the result
  31898. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  31899. */
  31900. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  31901. /**
  31902. * Downloads a blob in the browser
  31903. * @param blob defines the blob to download
  31904. * @param fileName defines the name of the downloaded file
  31905. */
  31906. static Download(blob: Blob, fileName: string): void;
  31907. /**
  31908. * Captures a screenshot of the current rendering
  31909. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31910. * @param engine defines the rendering engine
  31911. * @param camera defines the source camera
  31912. * @param size This parameter can be set to a single number or to an object with the
  31913. * following (optional) properties: precision, width, height. If a single number is passed,
  31914. * it will be used for both width and height. If an object is passed, the screenshot size
  31915. * will be derived from the parameters. The precision property is a multiplier allowing
  31916. * rendering at a higher or lower resolution
  31917. * @param successCallback defines the callback receives a single parameter which contains the
  31918. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31919. * src parameter of an <img> to display it
  31920. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  31921. * Check your browser for supported MIME types
  31922. */
  31923. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  31924. /**
  31925. * Generates an image screenshot from the specified camera.
  31926. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  31927. * @param engine The engine to use for rendering
  31928. * @param camera The camera to use for rendering
  31929. * @param size This parameter can be set to a single number or to an object with the
  31930. * following (optional) properties: precision, width, height. If a single number is passed,
  31931. * it will be used for both width and height. If an object is passed, the screenshot size
  31932. * will be derived from the parameters. The precision property is a multiplier allowing
  31933. * rendering at a higher or lower resolution
  31934. * @param successCallback The callback receives a single parameter which contains the
  31935. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  31936. * src parameter of an <img> to display it
  31937. * @param mimeType The MIME type of the screenshot image (default: image/png).
  31938. * Check your browser for supported MIME types
  31939. * @param samples Texture samples (default: 1)
  31940. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  31941. * @param fileName A name for for the downloaded file.
  31942. */
  31943. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  31944. /**
  31945. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  31946. * Be aware Math.random() could cause collisions, but:
  31947. * "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"
  31948. * @returns a pseudo random id
  31949. */
  31950. static RandomId(): string;
  31951. /**
  31952. * Test if the given uri is a base64 string
  31953. * @param uri The uri to test
  31954. * @return True if the uri is a base64 string or false otherwise
  31955. */
  31956. static IsBase64(uri: string): boolean;
  31957. /**
  31958. * Decode the given base64 uri.
  31959. * @param uri The uri to decode
  31960. * @return The decoded base64 data.
  31961. */
  31962. static DecodeBase64(uri: string): ArrayBuffer;
  31963. /**
  31964. * Gets the absolute url.
  31965. * @param url the input url
  31966. * @return the absolute url
  31967. */
  31968. static GetAbsoluteUrl(url: string): string;
  31969. /**
  31970. * No log
  31971. */
  31972. static readonly NoneLogLevel: number;
  31973. /**
  31974. * Only message logs
  31975. */
  31976. static readonly MessageLogLevel: number;
  31977. /**
  31978. * Only warning logs
  31979. */
  31980. static readonly WarningLogLevel: number;
  31981. /**
  31982. * Only error logs
  31983. */
  31984. static readonly ErrorLogLevel: number;
  31985. /**
  31986. * All logs
  31987. */
  31988. static readonly AllLogLevel: number;
  31989. /**
  31990. * Gets a value indicating the number of loading errors
  31991. * @ignorenaming
  31992. */
  31993. static readonly errorsCount: number;
  31994. /**
  31995. * Callback called when a new log is added
  31996. */
  31997. static OnNewCacheEntry: (entry: string) => void;
  31998. /**
  31999. * Log a message to the console
  32000. * @param message defines the message to log
  32001. */
  32002. static Log(message: string): void;
  32003. /**
  32004. * Write a warning message to the console
  32005. * @param message defines the message to log
  32006. */
  32007. static Warn(message: string): void;
  32008. /**
  32009. * Write an error message to the console
  32010. * @param message defines the message to log
  32011. */
  32012. static Error(message: string): void;
  32013. /**
  32014. * Gets current log cache (list of logs)
  32015. */
  32016. static readonly LogCache: string;
  32017. /**
  32018. * Clears the log cache
  32019. */
  32020. static ClearLogCache(): void;
  32021. /**
  32022. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  32023. */
  32024. static LogLevels: number;
  32025. /**
  32026. * Checks if the loaded document was accessed via `file:`-Protocol.
  32027. * @returns boolean
  32028. */
  32029. static IsFileURL(): boolean;
  32030. /**
  32031. * Checks if the window object exists
  32032. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  32033. */
  32034. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  32035. /**
  32036. * No performance log
  32037. */
  32038. static readonly PerformanceNoneLogLevel: number;
  32039. /**
  32040. * Use user marks to log performance
  32041. */
  32042. static readonly PerformanceUserMarkLogLevel: number;
  32043. /**
  32044. * Log performance to the console
  32045. */
  32046. static readonly PerformanceConsoleLogLevel: number;
  32047. private static _performance;
  32048. /**
  32049. * Sets the current performance log level
  32050. */
  32051. static PerformanceLogLevel: number;
  32052. private static _StartPerformanceCounterDisabled;
  32053. private static _EndPerformanceCounterDisabled;
  32054. private static _StartUserMark;
  32055. private static _EndUserMark;
  32056. private static _StartPerformanceConsole;
  32057. private static _EndPerformanceConsole;
  32058. /**
  32059. * Starts a performance counter
  32060. */
  32061. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32062. /**
  32063. * Ends a specific performance coutner
  32064. */
  32065. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  32066. /**
  32067. * Gets either window.performance.now() if supported or Date.now() else
  32068. */
  32069. static readonly Now: number;
  32070. /**
  32071. * This method will return the name of the class used to create the instance of the given object.
  32072. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  32073. * @param object the object to get the class name from
  32074. * @param isType defines if the object is actually a type
  32075. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  32076. */
  32077. static GetClassName(object: any, isType?: boolean): string;
  32078. /**
  32079. * Gets the first element of an array satisfying a given predicate
  32080. * @param array defines the array to browse
  32081. * @param predicate defines the predicate to use
  32082. * @returns null if not found or the element
  32083. */
  32084. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  32085. /**
  32086. * This method will return the name of the full name of the class, including its owning module (if any).
  32087. * 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).
  32088. * @param object the object to get the class name from
  32089. * @param isType defines if the object is actually a type
  32090. * @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.
  32091. * @ignorenaming
  32092. */
  32093. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  32094. /**
  32095. * Returns a promise that resolves after the given amount of time.
  32096. * @param delay Number of milliseconds to delay
  32097. * @returns Promise that resolves after the given amount of time
  32098. */
  32099. static DelayAsync(delay: number): Promise<void>;
  32100. /**
  32101. * Gets the current gradient from an array of IValueGradient
  32102. * @param ratio defines the current ratio to get
  32103. * @param gradients defines the array of IValueGradient
  32104. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  32105. */
  32106. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  32107. }
  32108. /**
  32109. * This class is used to track a performance counter which is number based.
  32110. * The user has access to many properties which give statistics of different nature.
  32111. *
  32112. * The implementer can track two kinds of Performance Counter: time and count.
  32113. * 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.
  32114. * 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.
  32115. */
  32116. export class PerfCounter {
  32117. /**
  32118. * Gets or sets a global boolean to turn on and off all the counters
  32119. */
  32120. static Enabled: boolean;
  32121. /**
  32122. * Returns the smallest value ever
  32123. */
  32124. readonly min: number;
  32125. /**
  32126. * Returns the biggest value ever
  32127. */
  32128. readonly max: number;
  32129. /**
  32130. * Returns the average value since the performance counter is running
  32131. */
  32132. readonly average: number;
  32133. /**
  32134. * Returns the average value of the last second the counter was monitored
  32135. */
  32136. readonly lastSecAverage: number;
  32137. /**
  32138. * Returns the current value
  32139. */
  32140. readonly current: number;
  32141. /**
  32142. * Gets the accumulated total
  32143. */
  32144. readonly total: number;
  32145. /**
  32146. * Gets the total value count
  32147. */
  32148. readonly count: number;
  32149. /**
  32150. * Creates a new counter
  32151. */
  32152. constructor();
  32153. /**
  32154. * Call this method to start monitoring a new frame.
  32155. * 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.
  32156. */
  32157. fetchNewFrame(): void;
  32158. /**
  32159. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  32160. * @param newCount the count value to add to the monitored count
  32161. * @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.
  32162. */
  32163. addCount(newCount: number, fetchResult: boolean): void;
  32164. /**
  32165. * Start monitoring this performance counter
  32166. */
  32167. beginMonitoring(): void;
  32168. /**
  32169. * Compute the time lapsed since the previous beginMonitoring() call.
  32170. * @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
  32171. */
  32172. endMonitoring(newFrame?: boolean): void;
  32173. private _fetchResult;
  32174. private _startMonitoringTime;
  32175. private _min;
  32176. private _max;
  32177. private _average;
  32178. private _current;
  32179. private _totalValueCount;
  32180. private _totalAccumulated;
  32181. private _lastSecAverage;
  32182. private _lastSecAccumulated;
  32183. private _lastSecTime;
  32184. private _lastSecValueCount;
  32185. }
  32186. /**
  32187. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  32188. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  32189. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  32190. * @param name The name of the class, case should be preserved
  32191. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  32192. */
  32193. export function className(name: string, module?: string): (target: Object) => void;
  32194. /**
  32195. * An implementation of a loop for asynchronous functions.
  32196. */
  32197. export class AsyncLoop {
  32198. /**
  32199. * Defines the number of iterations for the loop
  32200. */
  32201. iterations: number;
  32202. /**
  32203. * Defines the current index of the loop.
  32204. */
  32205. index: number;
  32206. private _done;
  32207. private _fn;
  32208. private _successCallback;
  32209. /**
  32210. * Constructor.
  32211. * @param iterations the number of iterations.
  32212. * @param func the function to run each iteration
  32213. * @param successCallback the callback that will be called upon succesful execution
  32214. * @param offset starting offset.
  32215. */
  32216. constructor(
  32217. /**
  32218. * Defines the number of iterations for the loop
  32219. */
  32220. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  32221. /**
  32222. * Execute the next iteration. Must be called after the last iteration was finished.
  32223. */
  32224. executeNext(): void;
  32225. /**
  32226. * Break the loop and run the success callback.
  32227. */
  32228. breakLoop(): void;
  32229. /**
  32230. * Create and run an async loop.
  32231. * @param iterations the number of iterations.
  32232. * @param fn the function to run each iteration
  32233. * @param successCallback the callback that will be called upon succesful execution
  32234. * @param offset starting offset.
  32235. * @returns the created async loop object
  32236. */
  32237. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  32238. /**
  32239. * A for-loop that will run a given number of iterations synchronous and the rest async.
  32240. * @param iterations total number of iterations
  32241. * @param syncedIterations number of synchronous iterations in each async iteration.
  32242. * @param fn the function to call each iteration.
  32243. * @param callback a success call back that will be called when iterating stops.
  32244. * @param breakFunction a break condition (optional)
  32245. * @param timeout timeout settings for the setTimeout function. default - 0.
  32246. * @returns the created async loop object
  32247. */
  32248. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  32249. }
  32250. }
  32251. declare module "babylonjs/Collisions/collisionCoordinator" {
  32252. import { Nullable } from "babylonjs/types";
  32253. import { Scene } from "babylonjs/scene";
  32254. import { Vector3 } from "babylonjs/Maths/math";
  32255. import { Collider } from "babylonjs/Collisions/collider";
  32256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32257. /** @hidden */
  32258. export interface ICollisionCoordinator {
  32259. createCollider(): Collider;
  32260. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32261. init(scene: Scene): void;
  32262. }
  32263. /** @hidden */
  32264. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  32265. private _scene;
  32266. private _scaledPosition;
  32267. private _scaledVelocity;
  32268. private _finalPosition;
  32269. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  32270. createCollider(): Collider;
  32271. init(scene: Scene): void;
  32272. private _collideWithWorld;
  32273. }
  32274. }
  32275. declare module "babylonjs/Animations/animationGroup" {
  32276. import { Animatable } from "babylonjs/Animations/animatable";
  32277. import { Animation } from "babylonjs/Animations/animation";
  32278. import { Scene, IDisposable } from "babylonjs/scene";
  32279. import { Observable } from "babylonjs/Misc/observable";
  32280. import { Nullable } from "babylonjs/types";
  32281. /**
  32282. * This class defines the direct association between an animation and a target
  32283. */
  32284. export class TargetedAnimation {
  32285. /**
  32286. * Animation to perform
  32287. */
  32288. animation: Animation;
  32289. /**
  32290. * Target to animate
  32291. */
  32292. target: any;
  32293. }
  32294. /**
  32295. * Use this class to create coordinated animations on multiple targets
  32296. */
  32297. export class AnimationGroup implements IDisposable {
  32298. /** The name of the animation group */
  32299. name: string;
  32300. private _scene;
  32301. private _targetedAnimations;
  32302. private _animatables;
  32303. private _from;
  32304. private _to;
  32305. private _isStarted;
  32306. private _isPaused;
  32307. private _speedRatio;
  32308. /**
  32309. * Gets or sets the unique id of the node
  32310. */
  32311. uniqueId: number;
  32312. /**
  32313. * This observable will notify when one animation have ended
  32314. */
  32315. onAnimationEndObservable: Observable<TargetedAnimation>;
  32316. /**
  32317. * Observer raised when one animation loops
  32318. */
  32319. onAnimationLoopObservable: Observable<TargetedAnimation>;
  32320. /**
  32321. * This observable will notify when all animations have ended.
  32322. */
  32323. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  32324. /**
  32325. * This observable will notify when all animations have paused.
  32326. */
  32327. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  32328. /**
  32329. * This observable will notify when all animations are playing.
  32330. */
  32331. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  32332. /**
  32333. * Gets the first frame
  32334. */
  32335. readonly from: number;
  32336. /**
  32337. * Gets the last frame
  32338. */
  32339. readonly to: number;
  32340. /**
  32341. * Define if the animations are started
  32342. */
  32343. readonly isStarted: boolean;
  32344. /**
  32345. * Gets a value indicating that the current group is playing
  32346. */
  32347. readonly isPlaying: boolean;
  32348. /**
  32349. * Gets or sets the speed ratio to use for all animations
  32350. */
  32351. /**
  32352. * Gets or sets the speed ratio to use for all animations
  32353. */
  32354. speedRatio: number;
  32355. /**
  32356. * Gets the targeted animations for this animation group
  32357. */
  32358. readonly targetedAnimations: Array<TargetedAnimation>;
  32359. /**
  32360. * returning the list of animatables controlled by this animation group.
  32361. */
  32362. readonly animatables: Array<Animatable>;
  32363. /**
  32364. * Instantiates a new Animation Group.
  32365. * This helps managing several animations at once.
  32366. * @see http://doc.babylonjs.com/how_to/group
  32367. * @param name Defines the name of the group
  32368. * @param scene Defines the scene the group belongs to
  32369. */
  32370. constructor(
  32371. /** The name of the animation group */
  32372. name: string, scene?: Nullable<Scene>);
  32373. /**
  32374. * Add an animation (with its target) in the group
  32375. * @param animation defines the animation we want to add
  32376. * @param target defines the target of the animation
  32377. * @returns the TargetedAnimation object
  32378. */
  32379. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  32380. /**
  32381. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  32382. * It can add constant keys at begin or end
  32383. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  32384. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  32385. * @returns the animation group
  32386. */
  32387. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  32388. /**
  32389. * Start all animations on given targets
  32390. * @param loop defines if animations must loop
  32391. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  32392. * @param from defines the from key (optional)
  32393. * @param to defines the to key (optional)
  32394. * @returns the current animation group
  32395. */
  32396. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  32397. /**
  32398. * Pause all animations
  32399. * @returns the animation group
  32400. */
  32401. pause(): AnimationGroup;
  32402. /**
  32403. * Play all animations to initial state
  32404. * This function will start() the animations if they were not started or will restart() them if they were paused
  32405. * @param loop defines if animations must loop
  32406. * @returns the animation group
  32407. */
  32408. play(loop?: boolean): AnimationGroup;
  32409. /**
  32410. * Reset all animations to initial state
  32411. * @returns the animation group
  32412. */
  32413. reset(): AnimationGroup;
  32414. /**
  32415. * Restart animations from key 0
  32416. * @returns the animation group
  32417. */
  32418. restart(): AnimationGroup;
  32419. /**
  32420. * Stop all animations
  32421. * @returns the animation group
  32422. */
  32423. stop(): AnimationGroup;
  32424. /**
  32425. * Set animation weight for all animatables
  32426. * @param weight defines the weight to use
  32427. * @return the animationGroup
  32428. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32429. */
  32430. setWeightForAllAnimatables(weight: number): AnimationGroup;
  32431. /**
  32432. * Synchronize and normalize all animatables with a source animatable
  32433. * @param root defines the root animatable to synchronize with
  32434. * @return the animationGroup
  32435. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  32436. */
  32437. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  32438. /**
  32439. * Goes to a specific frame in this animation group
  32440. * @param frame the frame number to go to
  32441. * @return the animationGroup
  32442. */
  32443. goToFrame(frame: number): AnimationGroup;
  32444. /**
  32445. * Dispose all associated resources
  32446. */
  32447. dispose(): void;
  32448. private _checkAnimationGroupEnded;
  32449. /**
  32450. * Clone the current animation group and returns a copy
  32451. * @param newName defines the name of the new group
  32452. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  32453. * @returns the new aniamtion group
  32454. */
  32455. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  32456. /**
  32457. * Returns a new AnimationGroup object parsed from the source provided.
  32458. * @param parsedAnimationGroup defines the source
  32459. * @param scene defines the scene that will receive the animationGroup
  32460. * @returns a new AnimationGroup
  32461. */
  32462. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  32463. /**
  32464. * Returns the string "AnimationGroup"
  32465. * @returns "AnimationGroup"
  32466. */
  32467. getClassName(): string;
  32468. /**
  32469. * Creates a detailled string about the object
  32470. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  32471. * @returns a string representing the object
  32472. */
  32473. toString(fullDetails?: boolean): string;
  32474. }
  32475. }
  32476. declare module "babylonjs/scene" {
  32477. import { Nullable } from "babylonjs/types";
  32478. import { IAnimatable, IFileRequest, PerfCounter } from "babylonjs/Misc/tools";
  32479. import { Observable } from "babylonjs/Misc/observable";
  32480. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  32481. import { Color4, Color3, Plane, Vector2, Vector3, Matrix } from "babylonjs/Maths/math";
  32482. import { Geometry } from "babylonjs/Meshes/geometry";
  32483. import { TransformNode } from "babylonjs/Meshes/transformNode";
  32484. import { SubMesh } from "babylonjs/Meshes/subMesh";
  32485. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  32486. import { Mesh } from "babylonjs/Meshes/mesh";
  32487. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  32488. import { Bone } from "babylonjs/Bones/bone";
  32489. import { Skeleton } from "babylonjs/Bones/skeleton";
  32490. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  32491. import { Camera } from "babylonjs/Cameras/camera";
  32492. import { AbstractScene } from "babylonjs/abstractScene";
  32493. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  32494. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  32495. import { Material } from "babylonjs/Materials/material";
  32496. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  32497. import { Effect } from "babylonjs/Materials/effect";
  32498. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  32499. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32500. import { Light } from "babylonjs/Lights/light";
  32501. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32502. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  32503. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  32504. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  32505. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  32506. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  32507. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  32508. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  32509. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  32510. import { Engine } from "babylonjs/Engines/engine";
  32511. import { Node } from "babylonjs/node";
  32512. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  32513. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  32514. import { WebRequest } from "babylonjs/Misc/webRequest";
  32515. import { Ray } from "babylonjs/Culling/ray";
  32516. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  32517. import { Animation } from "babylonjs/Animations/animation";
  32518. import { Animatable } from "babylonjs/Animations/animatable";
  32519. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  32520. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  32521. import { Collider } from "babylonjs/Collisions/collider";
  32522. /**
  32523. * Define an interface for all classes that will hold resources
  32524. */
  32525. export interface IDisposable {
  32526. /**
  32527. * Releases all held resources
  32528. */
  32529. dispose(): void;
  32530. }
  32531. /** Interface defining initialization parameters for Scene class */
  32532. export interface SceneOptions {
  32533. /**
  32534. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  32535. * It will improve performance when the number of geometries becomes important.
  32536. */
  32537. useGeometryUniqueIdsMap?: boolean;
  32538. /**
  32539. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  32540. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32541. */
  32542. useMaterialMeshMap?: boolean;
  32543. /**
  32544. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  32545. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  32546. */
  32547. useClonedMeshhMap?: boolean;
  32548. }
  32549. /**
  32550. * Represents a scene to be rendered by the engine.
  32551. * @see http://doc.babylonjs.com/features/scene
  32552. */
  32553. export class Scene extends AbstractScene implements IAnimatable {
  32554. private static _uniqueIdCounter;
  32555. /** The fog is deactivated */
  32556. static readonly FOGMODE_NONE: number;
  32557. /** The fog density is following an exponential function */
  32558. static readonly FOGMODE_EXP: number;
  32559. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  32560. static readonly FOGMODE_EXP2: number;
  32561. /** The fog density is following a linear function. */
  32562. static readonly FOGMODE_LINEAR: number;
  32563. /**
  32564. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  32565. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32566. */
  32567. static MinDeltaTime: number;
  32568. /**
  32569. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  32570. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32571. */
  32572. static MaxDeltaTime: number;
  32573. /**
  32574. * Factory used to create the default material.
  32575. * @param name The name of the material to create
  32576. * @param scene The scene to create the material for
  32577. * @returns The default material
  32578. */
  32579. static DefaultMaterialFactory(scene: Scene): Material;
  32580. /**
  32581. * Factory used to create the a collision coordinator.
  32582. * @returns The collision coordinator
  32583. */
  32584. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  32585. /** @hidden */
  32586. readonly _isScene: boolean;
  32587. /**
  32588. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  32589. */
  32590. autoClear: boolean;
  32591. /**
  32592. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  32593. */
  32594. autoClearDepthAndStencil: boolean;
  32595. /**
  32596. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  32597. */
  32598. clearColor: Color4;
  32599. /**
  32600. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  32601. */
  32602. ambientColor: Color3;
  32603. /**
  32604. * This is use to store the default BRDF lookup for PBR materials in your scene.
  32605. * It should only be one of the following (if not the default embedded one):
  32606. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  32607. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  32608. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  32609. * The material properties need to be setup according to the type of texture in use.
  32610. */
  32611. environmentBRDFTexture: BaseTexture;
  32612. /** @hidden */
  32613. protected _environmentTexture: Nullable<BaseTexture>;
  32614. /**
  32615. * Texture used in all pbr material as the reflection texture.
  32616. * As in the majority of the scene they are the same (exception for multi room and so on),
  32617. * this is easier to reference from here than from all the materials.
  32618. */
  32619. /**
  32620. * Texture used in all pbr material as the reflection texture.
  32621. * As in the majority of the scene they are the same (exception for multi room and so on),
  32622. * this is easier to set here than in all the materials.
  32623. */
  32624. environmentTexture: Nullable<BaseTexture>;
  32625. /** @hidden */
  32626. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32627. /**
  32628. * Default image processing configuration used either in the rendering
  32629. * Forward main pass or through the imageProcessingPostProcess if present.
  32630. * As in the majority of the scene they are the same (exception for multi camera),
  32631. * this is easier to reference from here than from all the materials and post process.
  32632. *
  32633. * No setter as we it is a shared configuration, you can set the values instead.
  32634. */
  32635. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  32636. private _forceWireframe;
  32637. /**
  32638. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  32639. */
  32640. forceWireframe: boolean;
  32641. private _forcePointsCloud;
  32642. /**
  32643. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  32644. */
  32645. forcePointsCloud: boolean;
  32646. /**
  32647. * Gets or sets the active clipplane 1
  32648. */
  32649. clipPlane: Nullable<Plane>;
  32650. /**
  32651. * Gets or sets the active clipplane 2
  32652. */
  32653. clipPlane2: Nullable<Plane>;
  32654. /**
  32655. * Gets or sets the active clipplane 3
  32656. */
  32657. clipPlane3: Nullable<Plane>;
  32658. /**
  32659. * Gets or sets the active clipplane 4
  32660. */
  32661. clipPlane4: Nullable<Plane>;
  32662. /**
  32663. * Gets or sets a boolean indicating if animations are enabled
  32664. */
  32665. animationsEnabled: boolean;
  32666. private _animationPropertiesOverride;
  32667. /**
  32668. * Gets or sets the animation properties override
  32669. */
  32670. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  32671. /**
  32672. * Gets or sets a boolean indicating if a constant deltatime has to be used
  32673. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  32674. */
  32675. useConstantAnimationDeltaTime: boolean;
  32676. /**
  32677. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  32678. * Please note that it requires to run a ray cast through the scene on every frame
  32679. */
  32680. constantlyUpdateMeshUnderPointer: boolean;
  32681. /**
  32682. * Defines the HTML cursor to use when hovering over interactive elements
  32683. */
  32684. hoverCursor: string;
  32685. /**
  32686. * Defines the HTML default cursor to use (empty by default)
  32687. */
  32688. defaultCursor: string;
  32689. /**
  32690. * This is used to call preventDefault() on pointer down
  32691. * in order to block unwanted artifacts like system double clicks
  32692. */
  32693. preventDefaultOnPointerDown: boolean;
  32694. /**
  32695. * This is used to call preventDefault() on pointer up
  32696. * in order to block unwanted artifacts like system double clicks
  32697. */
  32698. preventDefaultOnPointerUp: boolean;
  32699. /**
  32700. * Gets or sets user defined metadata
  32701. */
  32702. metadata: any;
  32703. /**
  32704. * For internal use only. Please do not use.
  32705. */
  32706. reservedDataStore: any;
  32707. /**
  32708. * Gets the name of the plugin used to load this scene (null by default)
  32709. */
  32710. loadingPluginName: string;
  32711. /**
  32712. * Use this array to add regular expressions used to disable offline support for specific urls
  32713. */
  32714. disableOfflineSupportExceptionRules: RegExp[];
  32715. /**
  32716. * An event triggered when the scene is disposed.
  32717. */
  32718. onDisposeObservable: Observable<Scene>;
  32719. private _onDisposeObserver;
  32720. /** Sets a function to be executed when this scene is disposed. */
  32721. onDispose: () => void;
  32722. /**
  32723. * An event triggered before rendering the scene (right after animations and physics)
  32724. */
  32725. onBeforeRenderObservable: Observable<Scene>;
  32726. private _onBeforeRenderObserver;
  32727. /** Sets a function to be executed before rendering this scene */
  32728. beforeRender: Nullable<() => void>;
  32729. /**
  32730. * An event triggered after rendering the scene
  32731. */
  32732. onAfterRenderObservable: Observable<Scene>;
  32733. private _onAfterRenderObserver;
  32734. /** Sets a function to be executed after rendering this scene */
  32735. afterRender: Nullable<() => void>;
  32736. /**
  32737. * An event triggered before animating the scene
  32738. */
  32739. onBeforeAnimationsObservable: Observable<Scene>;
  32740. /**
  32741. * An event triggered after animations processing
  32742. */
  32743. onAfterAnimationsObservable: Observable<Scene>;
  32744. /**
  32745. * An event triggered before draw calls are ready to be sent
  32746. */
  32747. onBeforeDrawPhaseObservable: Observable<Scene>;
  32748. /**
  32749. * An event triggered after draw calls have been sent
  32750. */
  32751. onAfterDrawPhaseObservable: Observable<Scene>;
  32752. /**
  32753. * An event triggered when the scene is ready
  32754. */
  32755. onReadyObservable: Observable<Scene>;
  32756. /**
  32757. * An event triggered before rendering a camera
  32758. */
  32759. onBeforeCameraRenderObservable: Observable<Camera>;
  32760. private _onBeforeCameraRenderObserver;
  32761. /** Sets a function to be executed before rendering a camera*/
  32762. beforeCameraRender: () => void;
  32763. /**
  32764. * An event triggered after rendering a camera
  32765. */
  32766. onAfterCameraRenderObservable: Observable<Camera>;
  32767. private _onAfterCameraRenderObserver;
  32768. /** Sets a function to be executed after rendering a camera*/
  32769. afterCameraRender: () => void;
  32770. /**
  32771. * An event triggered when active meshes evaluation is about to start
  32772. */
  32773. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  32774. /**
  32775. * An event triggered when active meshes evaluation is done
  32776. */
  32777. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  32778. /**
  32779. * An event triggered when particles rendering is about to start
  32780. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32781. */
  32782. onBeforeParticlesRenderingObservable: Observable<Scene>;
  32783. /**
  32784. * An event triggered when particles rendering is done
  32785. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  32786. */
  32787. onAfterParticlesRenderingObservable: Observable<Scene>;
  32788. /**
  32789. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  32790. */
  32791. onDataLoadedObservable: Observable<Scene>;
  32792. /**
  32793. * An event triggered when a camera is created
  32794. */
  32795. onNewCameraAddedObservable: Observable<Camera>;
  32796. /**
  32797. * An event triggered when a camera is removed
  32798. */
  32799. onCameraRemovedObservable: Observable<Camera>;
  32800. /**
  32801. * An event triggered when a light is created
  32802. */
  32803. onNewLightAddedObservable: Observable<Light>;
  32804. /**
  32805. * An event triggered when a light is removed
  32806. */
  32807. onLightRemovedObservable: Observable<Light>;
  32808. /**
  32809. * An event triggered when a geometry is created
  32810. */
  32811. onNewGeometryAddedObservable: Observable<Geometry>;
  32812. /**
  32813. * An event triggered when a geometry is removed
  32814. */
  32815. onGeometryRemovedObservable: Observable<Geometry>;
  32816. /**
  32817. * An event triggered when a transform node is created
  32818. */
  32819. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  32820. /**
  32821. * An event triggered when a transform node is removed
  32822. */
  32823. onTransformNodeRemovedObservable: Observable<TransformNode>;
  32824. /**
  32825. * An event triggered when a mesh is created
  32826. */
  32827. onNewMeshAddedObservable: Observable<AbstractMesh>;
  32828. /**
  32829. * An event triggered when a mesh is removed
  32830. */
  32831. onMeshRemovedObservable: Observable<AbstractMesh>;
  32832. /**
  32833. * An event triggered when a skeleton is created
  32834. */
  32835. onNewSkeletonAddedObservable: Observable<Skeleton>;
  32836. /**
  32837. * An event triggered when a skeleton is removed
  32838. */
  32839. onSkeletonRemovedObservable: Observable<Skeleton>;
  32840. /**
  32841. * An event triggered when a material is created
  32842. */
  32843. onNewMaterialAddedObservable: Observable<Material>;
  32844. /**
  32845. * An event triggered when a material is removed
  32846. */
  32847. onMaterialRemovedObservable: Observable<Material>;
  32848. /**
  32849. * An event triggered when a texture is created
  32850. */
  32851. onNewTextureAddedObservable: Observable<BaseTexture>;
  32852. /**
  32853. * An event triggered when a texture is removed
  32854. */
  32855. onTextureRemovedObservable: Observable<BaseTexture>;
  32856. /**
  32857. * An event triggered when render targets are about to be rendered
  32858. * Can happen multiple times per frame.
  32859. */
  32860. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  32861. /**
  32862. * An event triggered when render targets were rendered.
  32863. * Can happen multiple times per frame.
  32864. */
  32865. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  32866. /**
  32867. * An event triggered before calculating deterministic simulation step
  32868. */
  32869. onBeforeStepObservable: Observable<Scene>;
  32870. /**
  32871. * An event triggered after calculating deterministic simulation step
  32872. */
  32873. onAfterStepObservable: Observable<Scene>;
  32874. /**
  32875. * An event triggered when the activeCamera property is updated
  32876. */
  32877. onActiveCameraChanged: Observable<Scene>;
  32878. /**
  32879. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  32880. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32881. * 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)
  32882. */
  32883. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32884. /**
  32885. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  32886. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  32887. * 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)
  32888. */
  32889. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  32890. /**
  32891. * This Observable will when a mesh has been imported into the scene.
  32892. */
  32893. onMeshImportedObservable: Observable<AbstractMesh>;
  32894. /**
  32895. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  32896. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  32897. */
  32898. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  32899. /** @hidden */
  32900. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  32901. /**
  32902. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  32903. */
  32904. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  32905. /**
  32906. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  32907. */
  32908. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  32909. /**
  32910. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  32911. */
  32912. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  32913. private _onPointerMove;
  32914. private _onPointerDown;
  32915. private _onPointerUp;
  32916. /** Callback called when a pointer move is detected */
  32917. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32918. /** Callback called when a pointer down is detected */
  32919. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  32920. /** Callback called when a pointer up is detected */
  32921. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  32922. /** Callback called when a pointer pick is detected */
  32923. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  32924. /**
  32925. * 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).
  32926. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  32927. */
  32928. onPrePointerObservable: Observable<PointerInfoPre>;
  32929. /**
  32930. * Observable event triggered each time an input event is received from the rendering canvas
  32931. */
  32932. onPointerObservable: Observable<PointerInfo>;
  32933. /**
  32934. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  32935. */
  32936. readonly unTranslatedPointer: Vector2;
  32937. /** The distance in pixel that you have to move to prevent some events */
  32938. static DragMovementThreshold: number;
  32939. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  32940. static LongPressDelay: number;
  32941. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  32942. static DoubleClickDelay: number;
  32943. /** If you need to check double click without raising a single click at first click, enable this flag */
  32944. static ExclusiveDoubleClickMode: boolean;
  32945. private _initClickEvent;
  32946. private _initActionManager;
  32947. private _delayedSimpleClick;
  32948. private _delayedSimpleClickTimeout;
  32949. private _previousDelayedSimpleClickTimeout;
  32950. private _meshPickProceed;
  32951. private _previousButtonPressed;
  32952. private _currentPickResult;
  32953. private _previousPickResult;
  32954. private _totalPointersPressed;
  32955. private _doubleClickOccured;
  32956. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  32957. cameraToUseForPointers: Nullable<Camera>;
  32958. private _pointerX;
  32959. private _pointerY;
  32960. private _unTranslatedPointerX;
  32961. private _unTranslatedPointerY;
  32962. private _startingPointerPosition;
  32963. private _previousStartingPointerPosition;
  32964. private _startingPointerTime;
  32965. private _previousStartingPointerTime;
  32966. private _pointerCaptures;
  32967. private _timeAccumulator;
  32968. private _currentStepId;
  32969. private _currentInternalStep;
  32970. /** @hidden */
  32971. _mirroredCameraPosition: Nullable<Vector3>;
  32972. /**
  32973. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  32974. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  32975. */
  32976. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  32977. /**
  32978. * Observable event triggered each time an keyboard event is received from the hosting window
  32979. */
  32980. onKeyboardObservable: Observable<KeyboardInfo>;
  32981. private _onKeyDown;
  32982. private _onKeyUp;
  32983. private _onCanvasFocusObserver;
  32984. private _onCanvasBlurObserver;
  32985. private _useRightHandedSystem;
  32986. /**
  32987. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  32988. */
  32989. useRightHandedSystem: boolean;
  32990. /**
  32991. * Sets the step Id used by deterministic lock step
  32992. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32993. * @param newStepId defines the step Id
  32994. */
  32995. setStepId(newStepId: number): void;
  32996. /**
  32997. * Gets the step Id used by deterministic lock step
  32998. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  32999. * @returns the step Id
  33000. */
  33001. getStepId(): number;
  33002. /**
  33003. * Gets the internal step used by deterministic lock step
  33004. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33005. * @returns the internal step
  33006. */
  33007. getInternalStep(): number;
  33008. private _fogEnabled;
  33009. /**
  33010. * Gets or sets a boolean indicating if fog is enabled on this scene
  33011. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33012. * (Default is true)
  33013. */
  33014. fogEnabled: boolean;
  33015. private _fogMode;
  33016. /**
  33017. * Gets or sets the fog mode to use
  33018. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33019. * | mode | value |
  33020. * | --- | --- |
  33021. * | FOGMODE_NONE | 0 |
  33022. * | FOGMODE_EXP | 1 |
  33023. * | FOGMODE_EXP2 | 2 |
  33024. * | FOGMODE_LINEAR | 3 |
  33025. */
  33026. fogMode: number;
  33027. /**
  33028. * Gets or sets the fog color to use
  33029. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33030. * (Default is Color3(0.2, 0.2, 0.3))
  33031. */
  33032. fogColor: Color3;
  33033. /**
  33034. * Gets or sets the fog density to use
  33035. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33036. * (Default is 0.1)
  33037. */
  33038. fogDensity: number;
  33039. /**
  33040. * Gets or sets the fog start distance to use
  33041. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33042. * (Default is 0)
  33043. */
  33044. fogStart: number;
  33045. /**
  33046. * Gets or sets the fog end distance to use
  33047. * @see http://doc.babylonjs.com/babylon101/environment#fog
  33048. * (Default is 1000)
  33049. */
  33050. fogEnd: number;
  33051. private _shadowsEnabled;
  33052. /**
  33053. * Gets or sets a boolean indicating if shadows are enabled on this scene
  33054. */
  33055. shadowsEnabled: boolean;
  33056. private _lightsEnabled;
  33057. /**
  33058. * Gets or sets a boolean indicating if lights are enabled on this scene
  33059. */
  33060. lightsEnabled: boolean;
  33061. /** All of the active cameras added to this scene. */
  33062. activeCameras: Camera[];
  33063. /** @hidden */
  33064. _activeCamera: Nullable<Camera>;
  33065. /** Gets or sets the current active camera */
  33066. activeCamera: Nullable<Camera>;
  33067. private _defaultMaterial;
  33068. /** The default material used on meshes when no material is affected */
  33069. /** The default material used on meshes when no material is affected */
  33070. defaultMaterial: Material;
  33071. private _texturesEnabled;
  33072. /**
  33073. * Gets or sets a boolean indicating if textures are enabled on this scene
  33074. */
  33075. texturesEnabled: boolean;
  33076. /**
  33077. * Gets or sets a boolean indicating if particles are enabled on this scene
  33078. */
  33079. particlesEnabled: boolean;
  33080. /**
  33081. * Gets or sets a boolean indicating if sprites are enabled on this scene
  33082. */
  33083. spritesEnabled: boolean;
  33084. private _skeletonsEnabled;
  33085. /**
  33086. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  33087. */
  33088. skeletonsEnabled: boolean;
  33089. /**
  33090. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  33091. */
  33092. lensFlaresEnabled: boolean;
  33093. /**
  33094. * Gets or sets a boolean indicating if collisions are enabled on this scene
  33095. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33096. */
  33097. collisionsEnabled: boolean;
  33098. private _collisionCoordinator;
  33099. /** @hidden */
  33100. readonly collisionCoordinator: ICollisionCoordinator;
  33101. /**
  33102. * Defines the gravity applied to this scene (used only for collisions)
  33103. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33104. */
  33105. gravity: Vector3;
  33106. /**
  33107. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  33108. */
  33109. postProcessesEnabled: boolean;
  33110. /**
  33111. * The list of postprocesses added to the scene
  33112. */
  33113. postProcesses: PostProcess[];
  33114. /**
  33115. * Gets the current postprocess manager
  33116. */
  33117. postProcessManager: PostProcessManager;
  33118. /**
  33119. * Gets or sets a boolean indicating if render targets are enabled on this scene
  33120. */
  33121. renderTargetsEnabled: boolean;
  33122. /**
  33123. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  33124. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  33125. */
  33126. dumpNextRenderTargets: boolean;
  33127. /**
  33128. * The list of user defined render targets added to the scene
  33129. */
  33130. customRenderTargets: RenderTargetTexture[];
  33131. /**
  33132. * Defines if texture loading must be delayed
  33133. * If true, textures will only be loaded when they need to be rendered
  33134. */
  33135. useDelayedTextureLoading: boolean;
  33136. /**
  33137. * Gets the list of meshes imported to the scene through SceneLoader
  33138. */
  33139. importedMeshesFiles: String[];
  33140. /**
  33141. * Gets or sets a boolean indicating if probes are enabled on this scene
  33142. */
  33143. probesEnabled: boolean;
  33144. /**
  33145. * Gets or sets the current offline provider to use to store scene data
  33146. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  33147. */
  33148. offlineProvider: IOfflineProvider;
  33149. /**
  33150. * Gets or sets the action manager associated with the scene
  33151. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  33152. */
  33153. actionManager: AbstractActionManager;
  33154. private _meshesForIntersections;
  33155. /**
  33156. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  33157. */
  33158. proceduralTexturesEnabled: boolean;
  33159. private _engine;
  33160. private _totalVertices;
  33161. /** @hidden */
  33162. _activeIndices: PerfCounter;
  33163. /** @hidden */
  33164. _activeParticles: PerfCounter;
  33165. /** @hidden */
  33166. _activeBones: PerfCounter;
  33167. private _animationRatio;
  33168. /** @hidden */
  33169. _animationTimeLast: number;
  33170. /** @hidden */
  33171. _animationTime: number;
  33172. /**
  33173. * Gets or sets a general scale for animation speed
  33174. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  33175. */
  33176. animationTimeScale: number;
  33177. /** @hidden */
  33178. _cachedMaterial: Nullable<Material>;
  33179. /** @hidden */
  33180. _cachedEffect: Nullable<Effect>;
  33181. /** @hidden */
  33182. _cachedVisibility: Nullable<number>;
  33183. private _renderId;
  33184. private _frameId;
  33185. private _executeWhenReadyTimeoutId;
  33186. private _intermediateRendering;
  33187. private _viewUpdateFlag;
  33188. private _projectionUpdateFlag;
  33189. /** @hidden */
  33190. _toBeDisposed: Nullable<IDisposable>[];
  33191. private _activeRequests;
  33192. /** @hidden */
  33193. _pendingData: any[];
  33194. private _isDisposed;
  33195. /**
  33196. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  33197. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  33198. */
  33199. dispatchAllSubMeshesOfActiveMeshes: boolean;
  33200. private _activeMeshes;
  33201. private _processedMaterials;
  33202. private _renderTargets;
  33203. /** @hidden */
  33204. _activeParticleSystems: SmartArray<IParticleSystem>;
  33205. private _activeSkeletons;
  33206. private _softwareSkinnedMeshes;
  33207. private _renderingManager;
  33208. /** @hidden */
  33209. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  33210. private _transformMatrix;
  33211. private _sceneUbo;
  33212. /** @hidden */
  33213. _viewMatrix: Matrix;
  33214. private _projectionMatrix;
  33215. private _wheelEventName;
  33216. /** @hidden */
  33217. _forcedViewPosition: Nullable<Vector3>;
  33218. /** @hidden */
  33219. _frustumPlanes: Plane[];
  33220. /**
  33221. * Gets the list of frustum planes (built from the active camera)
  33222. */
  33223. readonly frustumPlanes: Plane[];
  33224. /**
  33225. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  33226. * This is useful if there are more lights that the maximum simulteanous authorized
  33227. */
  33228. requireLightSorting: boolean;
  33229. /** @hidden */
  33230. readonly useMaterialMeshMap: boolean;
  33231. /** @hidden */
  33232. readonly useClonedMeshhMap: boolean;
  33233. private _pointerOverMesh;
  33234. private _pickedDownMesh;
  33235. private _pickedUpMesh;
  33236. private _externalData;
  33237. private _uid;
  33238. /**
  33239. * @hidden
  33240. * Backing store of defined scene components.
  33241. */
  33242. _components: ISceneComponent[];
  33243. /**
  33244. * @hidden
  33245. * Backing store of defined scene components.
  33246. */
  33247. _serializableComponents: ISceneSerializableComponent[];
  33248. /**
  33249. * List of components to register on the next registration step.
  33250. */
  33251. private _transientComponents;
  33252. /**
  33253. * Registers the transient components if needed.
  33254. */
  33255. private _registerTransientComponents;
  33256. /**
  33257. * @hidden
  33258. * Add a component to the scene.
  33259. * Note that the ccomponent could be registered on th next frame if this is called after
  33260. * the register component stage.
  33261. * @param component Defines the component to add to the scene
  33262. */
  33263. _addComponent(component: ISceneComponent): void;
  33264. /**
  33265. * @hidden
  33266. * Gets a component from the scene.
  33267. * @param name defines the name of the component to retrieve
  33268. * @returns the component or null if not present
  33269. */
  33270. _getComponent(name: string): Nullable<ISceneComponent>;
  33271. /**
  33272. * @hidden
  33273. * Defines the actions happening before camera updates.
  33274. */
  33275. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  33276. /**
  33277. * @hidden
  33278. * Defines the actions happening before clear the canvas.
  33279. */
  33280. _beforeClearStage: Stage<SimpleStageAction>;
  33281. /**
  33282. * @hidden
  33283. * Defines the actions when collecting render targets for the frame.
  33284. */
  33285. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33286. /**
  33287. * @hidden
  33288. * Defines the actions happening for one camera in the frame.
  33289. */
  33290. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  33291. /**
  33292. * @hidden
  33293. * Defines the actions happening during the per mesh ready checks.
  33294. */
  33295. _isReadyForMeshStage: Stage<MeshStageAction>;
  33296. /**
  33297. * @hidden
  33298. * Defines the actions happening before evaluate active mesh checks.
  33299. */
  33300. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  33301. /**
  33302. * @hidden
  33303. * Defines the actions happening during the evaluate sub mesh checks.
  33304. */
  33305. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  33306. /**
  33307. * @hidden
  33308. * Defines the actions happening during the active mesh stage.
  33309. */
  33310. _activeMeshStage: Stage<ActiveMeshStageAction>;
  33311. /**
  33312. * @hidden
  33313. * Defines the actions happening during the per camera render target step.
  33314. */
  33315. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  33316. /**
  33317. * @hidden
  33318. * Defines the actions happening just before the active camera is drawing.
  33319. */
  33320. _beforeCameraDrawStage: Stage<CameraStageAction>;
  33321. /**
  33322. * @hidden
  33323. * Defines the actions happening just before a render target is drawing.
  33324. */
  33325. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33326. /**
  33327. * @hidden
  33328. * Defines the actions happening just before a rendering group is drawing.
  33329. */
  33330. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33331. /**
  33332. * @hidden
  33333. * Defines the actions happening just before a mesh is drawing.
  33334. */
  33335. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33336. /**
  33337. * @hidden
  33338. * Defines the actions happening just after a mesh has been drawn.
  33339. */
  33340. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  33341. /**
  33342. * @hidden
  33343. * Defines the actions happening just after a rendering group has been drawn.
  33344. */
  33345. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  33346. /**
  33347. * @hidden
  33348. * Defines the actions happening just after the active camera has been drawn.
  33349. */
  33350. _afterCameraDrawStage: Stage<CameraStageAction>;
  33351. /**
  33352. * @hidden
  33353. * Defines the actions happening just after a render target has been drawn.
  33354. */
  33355. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  33356. /**
  33357. * @hidden
  33358. * Defines the actions happening just after rendering all cameras and computing intersections.
  33359. */
  33360. _afterRenderStage: Stage<SimpleStageAction>;
  33361. /**
  33362. * @hidden
  33363. * Defines the actions happening when a pointer move event happens.
  33364. */
  33365. _pointerMoveStage: Stage<PointerMoveStageAction>;
  33366. /**
  33367. * @hidden
  33368. * Defines the actions happening when a pointer down event happens.
  33369. */
  33370. _pointerDownStage: Stage<PointerUpDownStageAction>;
  33371. /**
  33372. * @hidden
  33373. * Defines the actions happening when a pointer up event happens.
  33374. */
  33375. _pointerUpStage: Stage<PointerUpDownStageAction>;
  33376. /**
  33377. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  33378. */
  33379. private geometriesByUniqueId;
  33380. /**
  33381. * Creates a new Scene
  33382. * @param engine defines the engine to use to render this scene
  33383. * @param options defines the scene options
  33384. */
  33385. constructor(engine: Engine, options?: SceneOptions);
  33386. /**
  33387. * Gets a string idenfifying the name of the class
  33388. * @returns "Scene" string
  33389. */
  33390. getClassName(): string;
  33391. private _defaultMeshCandidates;
  33392. /**
  33393. * @hidden
  33394. */
  33395. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  33396. private _defaultSubMeshCandidates;
  33397. /**
  33398. * @hidden
  33399. */
  33400. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  33401. /**
  33402. * Sets the default candidate providers for the scene.
  33403. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  33404. * and getCollidingSubMeshCandidates to their default function
  33405. */
  33406. setDefaultCandidateProviders(): void;
  33407. /**
  33408. * Gets the mesh that is currently under the pointer
  33409. */
  33410. readonly meshUnderPointer: Nullable<AbstractMesh>;
  33411. /**
  33412. * Gets or sets the current on-screen X position of the pointer
  33413. */
  33414. pointerX: number;
  33415. /**
  33416. * Gets or sets the current on-screen Y position of the pointer
  33417. */
  33418. pointerY: number;
  33419. /**
  33420. * Gets the cached material (ie. the latest rendered one)
  33421. * @returns the cached material
  33422. */
  33423. getCachedMaterial(): Nullable<Material>;
  33424. /**
  33425. * Gets the cached effect (ie. the latest rendered one)
  33426. * @returns the cached effect
  33427. */
  33428. getCachedEffect(): Nullable<Effect>;
  33429. /**
  33430. * Gets the cached visibility state (ie. the latest rendered one)
  33431. * @returns the cached visibility state
  33432. */
  33433. getCachedVisibility(): Nullable<number>;
  33434. /**
  33435. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  33436. * @param material defines the current material
  33437. * @param effect defines the current effect
  33438. * @param visibility defines the current visibility state
  33439. * @returns true if one parameter is not cached
  33440. */
  33441. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  33442. /**
  33443. * Gets the engine associated with the scene
  33444. * @returns an Engine
  33445. */
  33446. getEngine(): Engine;
  33447. /**
  33448. * Gets the total number of vertices rendered per frame
  33449. * @returns the total number of vertices rendered per frame
  33450. */
  33451. getTotalVertices(): number;
  33452. /**
  33453. * Gets the performance counter for total vertices
  33454. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33455. */
  33456. readonly totalVerticesPerfCounter: PerfCounter;
  33457. /**
  33458. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  33459. * @returns the total number of active indices rendered per frame
  33460. */
  33461. getActiveIndices(): number;
  33462. /**
  33463. * Gets the performance counter for active indices
  33464. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33465. */
  33466. readonly totalActiveIndicesPerfCounter: PerfCounter;
  33467. /**
  33468. * Gets the total number of active particles rendered per frame
  33469. * @returns the total number of active particles rendered per frame
  33470. */
  33471. getActiveParticles(): number;
  33472. /**
  33473. * Gets the performance counter for active particles
  33474. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33475. */
  33476. readonly activeParticlesPerfCounter: PerfCounter;
  33477. /**
  33478. * Gets the total number of active bones rendered per frame
  33479. * @returns the total number of active bones rendered per frame
  33480. */
  33481. getActiveBones(): number;
  33482. /**
  33483. * Gets the performance counter for active bones
  33484. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  33485. */
  33486. readonly activeBonesPerfCounter: PerfCounter;
  33487. /**
  33488. * Gets the array of active meshes
  33489. * @returns an array of AbstractMesh
  33490. */
  33491. getActiveMeshes(): SmartArray<AbstractMesh>;
  33492. /**
  33493. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  33494. * @returns a number
  33495. */
  33496. getAnimationRatio(): number;
  33497. /**
  33498. * Gets an unique Id for the current render phase
  33499. * @returns a number
  33500. */
  33501. getRenderId(): number;
  33502. /**
  33503. * Gets an unique Id for the current frame
  33504. * @returns a number
  33505. */
  33506. getFrameId(): number;
  33507. /** Call this function if you want to manually increment the render Id*/
  33508. incrementRenderId(): void;
  33509. private _updatePointerPosition;
  33510. private _createUbo;
  33511. private _setRayOnPointerInfo;
  33512. /**
  33513. * Use this method to simulate a pointer move on a mesh
  33514. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33515. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33516. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33517. * @returns the current scene
  33518. */
  33519. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33520. private _processPointerMove;
  33521. private _checkPrePointerObservable;
  33522. /**
  33523. * Use this method to simulate a pointer down on a mesh
  33524. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33525. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33526. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33527. * @returns the current scene
  33528. */
  33529. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  33530. private _processPointerDown;
  33531. /**
  33532. * Use this method to simulate a pointer up on a mesh
  33533. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  33534. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  33535. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  33536. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  33537. * @returns the current scene
  33538. */
  33539. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  33540. private _processPointerUp;
  33541. /**
  33542. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  33543. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  33544. * @returns true if the pointer was captured
  33545. */
  33546. isPointerCaptured(pointerId?: number): boolean;
  33547. /** @hidden */
  33548. _isPointerSwiping(): boolean;
  33549. /**
  33550. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  33551. * @param attachUp defines if you want to attach events to pointerup
  33552. * @param attachDown defines if you want to attach events to pointerdown
  33553. * @param attachMove defines if you want to attach events to pointermove
  33554. */
  33555. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  33556. /** Detaches all event handlers*/
  33557. detachControl(): void;
  33558. /**
  33559. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  33560. * Delay loaded resources are not taking in account
  33561. * @return true if all required resources are ready
  33562. */
  33563. isReady(): boolean;
  33564. /** Resets all cached information relative to material (including effect and visibility) */
  33565. resetCachedMaterial(): void;
  33566. /**
  33567. * Registers a function to be called before every frame render
  33568. * @param func defines the function to register
  33569. */
  33570. registerBeforeRender(func: () => void): void;
  33571. /**
  33572. * Unregisters a function called before every frame render
  33573. * @param func defines the function to unregister
  33574. */
  33575. unregisterBeforeRender(func: () => void): void;
  33576. /**
  33577. * Registers a function to be called after every frame render
  33578. * @param func defines the function to register
  33579. */
  33580. registerAfterRender(func: () => void): void;
  33581. /**
  33582. * Unregisters a function called after every frame render
  33583. * @param func defines the function to unregister
  33584. */
  33585. unregisterAfterRender(func: () => void): void;
  33586. private _executeOnceBeforeRender;
  33587. /**
  33588. * The provided function will run before render once and will be disposed afterwards.
  33589. * A timeout delay can be provided so that the function will be executed in N ms.
  33590. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  33591. * @param func The function to be executed.
  33592. * @param timeout optional delay in ms
  33593. */
  33594. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  33595. /** @hidden */
  33596. _addPendingData(data: any): void;
  33597. /** @hidden */
  33598. _removePendingData(data: any): void;
  33599. /**
  33600. * Returns the number of items waiting to be loaded
  33601. * @returns the number of items waiting to be loaded
  33602. */
  33603. getWaitingItemsCount(): number;
  33604. /**
  33605. * Returns a boolean indicating if the scene is still loading data
  33606. */
  33607. readonly isLoading: boolean;
  33608. /**
  33609. * Registers a function to be executed when the scene is ready
  33610. * @param {Function} func - the function to be executed
  33611. */
  33612. executeWhenReady(func: () => void): void;
  33613. /**
  33614. * Returns a promise that resolves when the scene is ready
  33615. * @returns A promise that resolves when the scene is ready
  33616. */
  33617. whenReadyAsync(): Promise<void>;
  33618. /** @hidden */
  33619. _checkIsReady(): void;
  33620. /**
  33621. * Gets all animatable attached to the scene
  33622. */
  33623. readonly animatables: Animatable[];
  33624. /**
  33625. * Resets the last animation time frame.
  33626. * Useful to override when animations start running when loading a scene for the first time.
  33627. */
  33628. resetLastAnimationTimeFrame(): void;
  33629. /**
  33630. * Gets the current view matrix
  33631. * @returns a Matrix
  33632. */
  33633. getViewMatrix(): Matrix;
  33634. /**
  33635. * Gets the current projection matrix
  33636. * @returns a Matrix
  33637. */
  33638. getProjectionMatrix(): Matrix;
  33639. /**
  33640. * Gets the current transform matrix
  33641. * @returns a Matrix made of View * Projection
  33642. */
  33643. getTransformMatrix(): Matrix;
  33644. /**
  33645. * Sets the current transform matrix
  33646. * @param viewL defines the View matrix to use
  33647. * @param projectionL defines the Projection matrix to use
  33648. * @param viewR defines the right View matrix to use (if provided)
  33649. * @param projectionR defines the right Projection matrix to use (if provided)
  33650. */
  33651. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  33652. /**
  33653. * Gets the uniform buffer used to store scene data
  33654. * @returns a UniformBuffer
  33655. */
  33656. getSceneUniformBuffer(): UniformBuffer;
  33657. /**
  33658. * Gets an unique (relatively to the current scene) Id
  33659. * @returns an unique number for the scene
  33660. */
  33661. getUniqueId(): number;
  33662. /**
  33663. * Add a mesh to the list of scene's meshes
  33664. * @param newMesh defines the mesh to add
  33665. * @param recursive if all child meshes should also be added to the scene
  33666. */
  33667. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  33668. /**
  33669. * Remove a mesh for the list of scene's meshes
  33670. * @param toRemove defines the mesh to remove
  33671. * @param recursive if all child meshes should also be removed from the scene
  33672. * @returns the index where the mesh was in the mesh list
  33673. */
  33674. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  33675. /**
  33676. * Add a transform node to the list of scene's transform nodes
  33677. * @param newTransformNode defines the transform node to add
  33678. */
  33679. addTransformNode(newTransformNode: TransformNode): void;
  33680. /**
  33681. * Remove a transform node for the list of scene's transform nodes
  33682. * @param toRemove defines the transform node to remove
  33683. * @returns the index where the transform node was in the transform node list
  33684. */
  33685. removeTransformNode(toRemove: TransformNode): number;
  33686. /**
  33687. * Remove a skeleton for the list of scene's skeletons
  33688. * @param toRemove defines the skeleton to remove
  33689. * @returns the index where the skeleton was in the skeleton list
  33690. */
  33691. removeSkeleton(toRemove: Skeleton): number;
  33692. /**
  33693. * Remove a morph target for the list of scene's morph targets
  33694. * @param toRemove defines the morph target to remove
  33695. * @returns the index where the morph target was in the morph target list
  33696. */
  33697. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  33698. /**
  33699. * Remove a light for the list of scene's lights
  33700. * @param toRemove defines the light to remove
  33701. * @returns the index where the light was in the light list
  33702. */
  33703. removeLight(toRemove: Light): number;
  33704. /**
  33705. * Remove a camera for the list of scene's cameras
  33706. * @param toRemove defines the camera to remove
  33707. * @returns the index where the camera was in the camera list
  33708. */
  33709. removeCamera(toRemove: Camera): number;
  33710. /**
  33711. * Remove a particle system for the list of scene's particle systems
  33712. * @param toRemove defines the particle system to remove
  33713. * @returns the index where the particle system was in the particle system list
  33714. */
  33715. removeParticleSystem(toRemove: IParticleSystem): number;
  33716. /**
  33717. * Remove a animation for the list of scene's animations
  33718. * @param toRemove defines the animation to remove
  33719. * @returns the index where the animation was in the animation list
  33720. */
  33721. removeAnimation(toRemove: Animation): number;
  33722. /**
  33723. * Removes the given animation group from this scene.
  33724. * @param toRemove The animation group to remove
  33725. * @returns The index of the removed animation group
  33726. */
  33727. removeAnimationGroup(toRemove: AnimationGroup): number;
  33728. /**
  33729. * Removes the given multi-material from this scene.
  33730. * @param toRemove The multi-material to remove
  33731. * @returns The index of the removed multi-material
  33732. */
  33733. removeMultiMaterial(toRemove: MultiMaterial): number;
  33734. /**
  33735. * Removes the given material from this scene.
  33736. * @param toRemove The material to remove
  33737. * @returns The index of the removed material
  33738. */
  33739. removeMaterial(toRemove: Material): number;
  33740. /**
  33741. * Removes the given action manager from this scene.
  33742. * @param toRemove The action manager to remove
  33743. * @returns The index of the removed action manager
  33744. */
  33745. removeActionManager(toRemove: AbstractActionManager): number;
  33746. /**
  33747. * Removes the given texture from this scene.
  33748. * @param toRemove The texture to remove
  33749. * @returns The index of the removed texture
  33750. */
  33751. removeTexture(toRemove: BaseTexture): number;
  33752. /**
  33753. * Adds the given light to this scene
  33754. * @param newLight The light to add
  33755. */
  33756. addLight(newLight: Light): void;
  33757. /**
  33758. * Sorts the list list based on light priorities
  33759. */
  33760. sortLightsByPriority(): void;
  33761. /**
  33762. * Adds the given camera to this scene
  33763. * @param newCamera The camera to add
  33764. */
  33765. addCamera(newCamera: Camera): void;
  33766. /**
  33767. * Adds the given skeleton to this scene
  33768. * @param newSkeleton The skeleton to add
  33769. */
  33770. addSkeleton(newSkeleton: Skeleton): void;
  33771. /**
  33772. * Adds the given particle system to this scene
  33773. * @param newParticleSystem The particle system to add
  33774. */
  33775. addParticleSystem(newParticleSystem: IParticleSystem): void;
  33776. /**
  33777. * Adds the given animation to this scene
  33778. * @param newAnimation The animation to add
  33779. */
  33780. addAnimation(newAnimation: Animation): void;
  33781. /**
  33782. * Adds the given animation group to this scene.
  33783. * @param newAnimationGroup The animation group to add
  33784. */
  33785. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  33786. /**
  33787. * Adds the given multi-material to this scene
  33788. * @param newMultiMaterial The multi-material to add
  33789. */
  33790. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  33791. /**
  33792. * Adds the given material to this scene
  33793. * @param newMaterial The material to add
  33794. */
  33795. addMaterial(newMaterial: Material): void;
  33796. /**
  33797. * Adds the given morph target to this scene
  33798. * @param newMorphTargetManager The morph target to add
  33799. */
  33800. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  33801. /**
  33802. * Adds the given geometry to this scene
  33803. * @param newGeometry The geometry to add
  33804. */
  33805. addGeometry(newGeometry: Geometry): void;
  33806. /**
  33807. * Adds the given action manager to this scene
  33808. * @param newActionManager The action manager to add
  33809. */
  33810. addActionManager(newActionManager: AbstractActionManager): void;
  33811. /**
  33812. * Adds the given texture to this scene.
  33813. * @param newTexture The texture to add
  33814. */
  33815. addTexture(newTexture: BaseTexture): void;
  33816. /**
  33817. * Switch active camera
  33818. * @param newCamera defines the new active camera
  33819. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  33820. */
  33821. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  33822. /**
  33823. * sets the active camera of the scene using its ID
  33824. * @param id defines the camera's ID
  33825. * @return the new active camera or null if none found.
  33826. */
  33827. setActiveCameraByID(id: string): Nullable<Camera>;
  33828. /**
  33829. * sets the active camera of the scene using its name
  33830. * @param name defines the camera's name
  33831. * @returns the new active camera or null if none found.
  33832. */
  33833. setActiveCameraByName(name: string): Nullable<Camera>;
  33834. /**
  33835. * get an animation group using its name
  33836. * @param name defines the material's name
  33837. * @return the animation group or null if none found.
  33838. */
  33839. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  33840. /**
  33841. * Get a material using its unique id
  33842. * @param uniqueId defines the material's unique id
  33843. * @return the material or null if none found.
  33844. */
  33845. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  33846. /**
  33847. * get a material using its id
  33848. * @param id defines the material's ID
  33849. * @return the material or null if none found.
  33850. */
  33851. getMaterialByID(id: string): Nullable<Material>;
  33852. /**
  33853. * Gets a material using its name
  33854. * @param name defines the material's name
  33855. * @return the material or null if none found.
  33856. */
  33857. getMaterialByName(name: string): Nullable<Material>;
  33858. /**
  33859. * Gets a camera using its id
  33860. * @param id defines the id to look for
  33861. * @returns the camera or null if not found
  33862. */
  33863. getCameraByID(id: string): Nullable<Camera>;
  33864. /**
  33865. * Gets a camera using its unique id
  33866. * @param uniqueId defines the unique id to look for
  33867. * @returns the camera or null if not found
  33868. */
  33869. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  33870. /**
  33871. * Gets a camera using its name
  33872. * @param name defines the camera's name
  33873. * @return the camera or null if none found.
  33874. */
  33875. getCameraByName(name: string): Nullable<Camera>;
  33876. /**
  33877. * Gets a bone using its id
  33878. * @param id defines the bone's id
  33879. * @return the bone or null if not found
  33880. */
  33881. getBoneByID(id: string): Nullable<Bone>;
  33882. /**
  33883. * Gets a bone using its id
  33884. * @param name defines the bone's name
  33885. * @return the bone or null if not found
  33886. */
  33887. getBoneByName(name: string): Nullable<Bone>;
  33888. /**
  33889. * Gets a light node using its name
  33890. * @param name defines the the light's name
  33891. * @return the light or null if none found.
  33892. */
  33893. getLightByName(name: string): Nullable<Light>;
  33894. /**
  33895. * Gets a light node using its id
  33896. * @param id defines the light's id
  33897. * @return the light or null if none found.
  33898. */
  33899. getLightByID(id: string): Nullable<Light>;
  33900. /**
  33901. * Gets a light node using its scene-generated unique ID
  33902. * @param uniqueId defines the light's unique id
  33903. * @return the light or null if none found.
  33904. */
  33905. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  33906. /**
  33907. * Gets a particle system by id
  33908. * @param id defines the particle system id
  33909. * @return the corresponding system or null if none found
  33910. */
  33911. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  33912. /**
  33913. * Gets a geometry using its ID
  33914. * @param id defines the geometry's id
  33915. * @return the geometry or null if none found.
  33916. */
  33917. getGeometryByID(id: string): Nullable<Geometry>;
  33918. private _getGeometryByUniqueID;
  33919. /**
  33920. * Add a new geometry to this scene
  33921. * @param geometry defines the geometry to be added to the scene.
  33922. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  33923. * @return a boolean defining if the geometry was added or not
  33924. */
  33925. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  33926. /**
  33927. * Removes an existing geometry
  33928. * @param geometry defines the geometry to be removed from the scene
  33929. * @return a boolean defining if the geometry was removed or not
  33930. */
  33931. removeGeometry(geometry: Geometry): boolean;
  33932. /**
  33933. * Gets the list of geometries attached to the scene
  33934. * @returns an array of Geometry
  33935. */
  33936. getGeometries(): Geometry[];
  33937. /**
  33938. * Gets the first added mesh found of a given ID
  33939. * @param id defines the id to search for
  33940. * @return the mesh found or null if not found at all
  33941. */
  33942. getMeshByID(id: string): Nullable<AbstractMesh>;
  33943. /**
  33944. * Gets a list of meshes using their id
  33945. * @param id defines the id to search for
  33946. * @returns a list of meshes
  33947. */
  33948. getMeshesByID(id: string): Array<AbstractMesh>;
  33949. /**
  33950. * Gets the first added transform node found of a given ID
  33951. * @param id defines the id to search for
  33952. * @return the found transform node or null if not found at all.
  33953. */
  33954. getTransformNodeByID(id: string): Nullable<TransformNode>;
  33955. /**
  33956. * Gets a transform node with its auto-generated unique id
  33957. * @param uniqueId efines the unique id to search for
  33958. * @return the found transform node or null if not found at all.
  33959. */
  33960. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  33961. /**
  33962. * Gets a list of transform nodes using their id
  33963. * @param id defines the id to search for
  33964. * @returns a list of transform nodes
  33965. */
  33966. getTransformNodesByID(id: string): Array<TransformNode>;
  33967. /**
  33968. * Gets a mesh with its auto-generated unique id
  33969. * @param uniqueId defines the unique id to search for
  33970. * @return the found mesh or null if not found at all.
  33971. */
  33972. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  33973. /**
  33974. * Gets a the last added mesh using a given id
  33975. * @param id defines the id to search for
  33976. * @return the found mesh or null if not found at all.
  33977. */
  33978. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  33979. /**
  33980. * Gets a the last added node (Mesh, Camera, Light) using a given id
  33981. * @param id defines the id to search for
  33982. * @return the found node or null if not found at all
  33983. */
  33984. getLastEntryByID(id: string): Nullable<Node>;
  33985. /**
  33986. * Gets a node (Mesh, Camera, Light) using a given id
  33987. * @param id defines the id to search for
  33988. * @return the found node or null if not found at all
  33989. */
  33990. getNodeByID(id: string): Nullable<Node>;
  33991. /**
  33992. * Gets a node (Mesh, Camera, Light) using a given name
  33993. * @param name defines the name to search for
  33994. * @return the found node or null if not found at all.
  33995. */
  33996. getNodeByName(name: string): Nullable<Node>;
  33997. /**
  33998. * Gets a mesh using a given name
  33999. * @param name defines the name to search for
  34000. * @return the found mesh or null if not found at all.
  34001. */
  34002. getMeshByName(name: string): Nullable<AbstractMesh>;
  34003. /**
  34004. * Gets a transform node using a given name
  34005. * @param name defines the name to search for
  34006. * @return the found transform node or null if not found at all.
  34007. */
  34008. getTransformNodeByName(name: string): Nullable<TransformNode>;
  34009. /**
  34010. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  34011. * @param id defines the id to search for
  34012. * @return the found skeleton or null if not found at all.
  34013. */
  34014. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  34015. /**
  34016. * Gets a skeleton using a given auto generated unique id
  34017. * @param uniqueId defines the unique id to search for
  34018. * @return the found skeleton or null if not found at all.
  34019. */
  34020. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  34021. /**
  34022. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  34023. * @param id defines the id to search for
  34024. * @return the found skeleton or null if not found at all.
  34025. */
  34026. getSkeletonById(id: string): Nullable<Skeleton>;
  34027. /**
  34028. * Gets a skeleton using a given name
  34029. * @param name defines the name to search for
  34030. * @return the found skeleton or null if not found at all.
  34031. */
  34032. getSkeletonByName(name: string): Nullable<Skeleton>;
  34033. /**
  34034. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  34035. * @param id defines the id to search for
  34036. * @return the found morph target manager or null if not found at all.
  34037. */
  34038. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  34039. /**
  34040. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  34041. * @param id defines the id to search for
  34042. * @return the found morph target or null if not found at all.
  34043. */
  34044. getMorphTargetById(id: string): Nullable<MorphTarget>;
  34045. /**
  34046. * Gets a boolean indicating if the given mesh is active
  34047. * @param mesh defines the mesh to look for
  34048. * @returns true if the mesh is in the active list
  34049. */
  34050. isActiveMesh(mesh: AbstractMesh): boolean;
  34051. /**
  34052. * Return a unique id as a string which can serve as an identifier for the scene
  34053. */
  34054. readonly uid: string;
  34055. /**
  34056. * Add an externaly attached data from its key.
  34057. * This method call will fail and return false, if such key already exists.
  34058. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  34059. * @param key the unique key that identifies the data
  34060. * @param data the data object to associate to the key for this Engine instance
  34061. * @return true if no such key were already present and the data was added successfully, false otherwise
  34062. */
  34063. addExternalData<T>(key: string, data: T): boolean;
  34064. /**
  34065. * Get an externaly attached data from its key
  34066. * @param key the unique key that identifies the data
  34067. * @return the associated data, if present (can be null), or undefined if not present
  34068. */
  34069. getExternalData<T>(key: string): Nullable<T>;
  34070. /**
  34071. * Get an externaly attached data from its key, create it using a factory if it's not already present
  34072. * @param key the unique key that identifies the data
  34073. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  34074. * @return the associated data, can be null if the factory returned null.
  34075. */
  34076. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  34077. /**
  34078. * Remove an externaly attached data from the Engine instance
  34079. * @param key the unique key that identifies the data
  34080. * @return true if the data was successfully removed, false if it doesn't exist
  34081. */
  34082. removeExternalData(key: string): boolean;
  34083. private _evaluateSubMesh;
  34084. /**
  34085. * Clear the processed materials smart array preventing retention point in material dispose.
  34086. */
  34087. freeProcessedMaterials(): void;
  34088. private _preventFreeActiveMeshesAndRenderingGroups;
  34089. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  34090. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  34091. * when disposing several meshes in a row or a hierarchy of meshes.
  34092. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  34093. */
  34094. blockfreeActiveMeshesAndRenderingGroups: boolean;
  34095. /**
  34096. * Clear the active meshes smart array preventing retention point in mesh dispose.
  34097. */
  34098. freeActiveMeshes(): void;
  34099. /**
  34100. * Clear the info related to rendering groups preventing retention points during dispose.
  34101. */
  34102. freeRenderingGroups(): void;
  34103. /** @hidden */
  34104. _isInIntermediateRendering(): boolean;
  34105. /**
  34106. * Lambda returning the list of potentially active meshes.
  34107. */
  34108. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  34109. /**
  34110. * Lambda returning the list of potentially active sub meshes.
  34111. */
  34112. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  34113. /**
  34114. * Lambda returning the list of potentially intersecting sub meshes.
  34115. */
  34116. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  34117. /**
  34118. * Lambda returning the list of potentially colliding sub meshes.
  34119. */
  34120. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  34121. private _activeMeshesFrozen;
  34122. /**
  34123. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  34124. * @returns the current scene
  34125. */
  34126. freezeActiveMeshes(): Scene;
  34127. /**
  34128. * Use this function to restart evaluating active meshes on every frame
  34129. * @returns the current scene
  34130. */
  34131. unfreezeActiveMeshes(): Scene;
  34132. private _evaluateActiveMeshes;
  34133. private _activeMesh;
  34134. /**
  34135. * Update the transform matrix to update from the current active camera
  34136. * @param force defines a boolean used to force the update even if cache is up to date
  34137. */
  34138. updateTransformMatrix(force?: boolean): void;
  34139. private _bindFrameBuffer;
  34140. /** @hidden */
  34141. _allowPostProcessClearColor: boolean;
  34142. /** @hidden */
  34143. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  34144. private _processSubCameras;
  34145. private _checkIntersections;
  34146. /** @hidden */
  34147. _advancePhysicsEngineStep(step: number): void;
  34148. /**
  34149. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  34150. */
  34151. getDeterministicFrameTime: () => number;
  34152. /** @hidden */
  34153. _animate(): void;
  34154. /** Execute all animations (for a frame) */
  34155. animate(): void;
  34156. /**
  34157. * Render the scene
  34158. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  34159. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  34160. */
  34161. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  34162. /**
  34163. * Freeze all materials
  34164. * A frozen material will not be updatable but should be faster to render
  34165. */
  34166. freezeMaterials(): void;
  34167. /**
  34168. * Unfreeze all materials
  34169. * A frozen material will not be updatable but should be faster to render
  34170. */
  34171. unfreezeMaterials(): void;
  34172. /**
  34173. * Releases all held ressources
  34174. */
  34175. dispose(): void;
  34176. /**
  34177. * Gets if the scene is already disposed
  34178. */
  34179. readonly isDisposed: boolean;
  34180. /**
  34181. * Call this function to reduce memory footprint of the scene.
  34182. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  34183. */
  34184. clearCachedVertexData(): void;
  34185. /**
  34186. * This function will remove the local cached buffer data from texture.
  34187. * It will save memory but will prevent the texture from being rebuilt
  34188. */
  34189. cleanCachedTextureBuffer(): void;
  34190. /**
  34191. * Get the world extend vectors with an optional filter
  34192. *
  34193. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  34194. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  34195. */
  34196. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  34197. min: Vector3;
  34198. max: Vector3;
  34199. };
  34200. /**
  34201. * Creates a ray that can be used to pick in the scene
  34202. * @param x defines the x coordinate of the origin (on-screen)
  34203. * @param y defines the y coordinate of the origin (on-screen)
  34204. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34205. * @param camera defines the camera to use for the picking
  34206. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34207. * @returns a Ray
  34208. */
  34209. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  34210. /**
  34211. * Creates a ray that can be used to pick in the scene
  34212. * @param x defines the x coordinate of the origin (on-screen)
  34213. * @param y defines the y coordinate of the origin (on-screen)
  34214. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  34215. * @param result defines the ray where to store the picking ray
  34216. * @param camera defines the camera to use for the picking
  34217. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  34218. * @returns the current scene
  34219. */
  34220. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  34221. /**
  34222. * Creates a ray that can be used to pick in the scene
  34223. * @param x defines the x coordinate of the origin (on-screen)
  34224. * @param y defines the y coordinate of the origin (on-screen)
  34225. * @param camera defines the camera to use for the picking
  34226. * @returns a Ray
  34227. */
  34228. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  34229. /**
  34230. * Creates a ray that can be used to pick in the scene
  34231. * @param x defines the x coordinate of the origin (on-screen)
  34232. * @param y defines the y coordinate of the origin (on-screen)
  34233. * @param result defines the ray where to store the picking ray
  34234. * @param camera defines the camera to use for the picking
  34235. * @returns the current scene
  34236. */
  34237. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  34238. /** Launch a ray to try to pick a mesh in the scene
  34239. * @param x position on screen
  34240. * @param y position on screen
  34241. * @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
  34242. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  34243. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34244. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34245. * @returns a PickingInfo
  34246. */
  34247. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  34248. /** Use the given ray to pick a mesh in the scene
  34249. * @param ray The ray to use to pick meshes
  34250. * @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
  34251. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  34252. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34253. * @returns a PickingInfo
  34254. */
  34255. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  34256. /**
  34257. * Launch a ray to try to pick a mesh in the scene
  34258. * @param x X position on screen
  34259. * @param y Y position on screen
  34260. * @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
  34261. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  34262. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34263. * @returns an array of PickingInfo
  34264. */
  34265. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34266. /**
  34267. * Launch a ray to try to pick a mesh in the scene
  34268. * @param ray Ray to use
  34269. * @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
  34270. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  34271. * @returns an array of PickingInfo
  34272. */
  34273. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  34274. /**
  34275. * Force the value of meshUnderPointer
  34276. * @param mesh defines the mesh to use
  34277. */
  34278. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  34279. /**
  34280. * Gets the mesh under the pointer
  34281. * @returns a Mesh or null if no mesh is under the pointer
  34282. */
  34283. getPointerOverMesh(): Nullable<AbstractMesh>;
  34284. /** @hidden */
  34285. _rebuildGeometries(): void;
  34286. /** @hidden */
  34287. _rebuildTextures(): void;
  34288. private _getByTags;
  34289. /**
  34290. * Get a list of meshes by tags
  34291. * @param tagsQuery defines the tags query to use
  34292. * @param forEach defines a predicate used to filter results
  34293. * @returns an array of Mesh
  34294. */
  34295. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  34296. /**
  34297. * Get a list of cameras by tags
  34298. * @param tagsQuery defines the tags query to use
  34299. * @param forEach defines a predicate used to filter results
  34300. * @returns an array of Camera
  34301. */
  34302. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  34303. /**
  34304. * Get a list of lights by tags
  34305. * @param tagsQuery defines the tags query to use
  34306. * @param forEach defines a predicate used to filter results
  34307. * @returns an array of Light
  34308. */
  34309. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  34310. /**
  34311. * Get a list of materials by tags
  34312. * @param tagsQuery defines the tags query to use
  34313. * @param forEach defines a predicate used to filter results
  34314. * @returns an array of Material
  34315. */
  34316. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  34317. /**
  34318. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  34319. * This allowed control for front to back rendering or reversly depending of the special needs.
  34320. *
  34321. * @param renderingGroupId The rendering group id corresponding to its index
  34322. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  34323. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  34324. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  34325. */
  34326. 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;
  34327. /**
  34328. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  34329. *
  34330. * @param renderingGroupId The rendering group id corresponding to its index
  34331. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  34332. * @param depth Automatically clears depth between groups if true and autoClear is true.
  34333. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  34334. */
  34335. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  34336. /**
  34337. * Gets the current auto clear configuration for one rendering group of the rendering
  34338. * manager.
  34339. * @param index the rendering group index to get the information for
  34340. * @returns The auto clear setup for the requested rendering group
  34341. */
  34342. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  34343. private _blockMaterialDirtyMechanism;
  34344. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  34345. blockMaterialDirtyMechanism: boolean;
  34346. /**
  34347. * Will flag all materials as dirty to trigger new shader compilation
  34348. * @param flag defines the flag used to specify which material part must be marked as dirty
  34349. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  34350. */
  34351. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  34352. /** @hidden */
  34353. _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;
  34354. /** @hidden */
  34355. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  34356. }
  34357. }
  34358. declare module "babylonjs/assetContainer" {
  34359. import { AbstractScene } from "babylonjs/abstractScene";
  34360. import { Scene } from "babylonjs/scene";
  34361. import { Mesh } from "babylonjs/Meshes/mesh";
  34362. /**
  34363. * Set of assets to keep when moving a scene into an asset container.
  34364. */
  34365. export class KeepAssets extends AbstractScene {
  34366. }
  34367. /**
  34368. * Container with a set of assets that can be added or removed from a scene.
  34369. */
  34370. export class AssetContainer extends AbstractScene {
  34371. /**
  34372. * The scene the AssetContainer belongs to.
  34373. */
  34374. scene: Scene;
  34375. /**
  34376. * Instantiates an AssetContainer.
  34377. * @param scene The scene the AssetContainer belongs to.
  34378. */
  34379. constructor(scene: Scene);
  34380. /**
  34381. * Adds all the assets from the container to the scene.
  34382. */
  34383. addAllToScene(): void;
  34384. /**
  34385. * Removes all the assets in the container from the scene
  34386. */
  34387. removeAllFromScene(): void;
  34388. /**
  34389. * Disposes all the assets in the container
  34390. */
  34391. dispose(): void;
  34392. private _moveAssets;
  34393. /**
  34394. * Removes all the assets contained in the scene and adds them to the container.
  34395. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  34396. */
  34397. moveAllFromScene(keepAssets?: KeepAssets): void;
  34398. /**
  34399. * 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.
  34400. * @returns the root mesh
  34401. */
  34402. createRootMesh(): Mesh;
  34403. }
  34404. }
  34405. declare module "babylonjs/abstractScene" {
  34406. import { Scene } from "babylonjs/scene";
  34407. import { Nullable } from "babylonjs/types";
  34408. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34409. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34410. import { Geometry } from "babylonjs/Meshes/geometry";
  34411. import { Skeleton } from "babylonjs/Bones/skeleton";
  34412. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  34413. import { AssetContainer } from "babylonjs/assetContainer";
  34414. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  34415. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  34416. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  34417. import { Material } from "babylonjs/Materials/material";
  34418. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  34419. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34420. import { Camera } from "babylonjs/Cameras/camera";
  34421. import { Light } from "babylonjs/Lights/light";
  34422. import { Node } from "babylonjs/node";
  34423. import { Animation } from "babylonjs/Animations/animation";
  34424. /**
  34425. * Defines how the parser contract is defined.
  34426. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  34427. */
  34428. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  34429. /**
  34430. * Defines how the individual parser contract is defined.
  34431. * These parser can parse an individual asset
  34432. */
  34433. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  34434. /**
  34435. * Base class of the scene acting as a container for the different elements composing a scene.
  34436. * This class is dynamically extended by the different components of the scene increasing
  34437. * flexibility and reducing coupling
  34438. */
  34439. export abstract class AbstractScene {
  34440. /**
  34441. * Stores the list of available parsers in the application.
  34442. */
  34443. private static _BabylonFileParsers;
  34444. /**
  34445. * Stores the list of available individual parsers in the application.
  34446. */
  34447. private static _IndividualBabylonFileParsers;
  34448. /**
  34449. * Adds a parser in the list of available ones
  34450. * @param name Defines the name of the parser
  34451. * @param parser Defines the parser to add
  34452. */
  34453. static AddParser(name: string, parser: BabylonFileParser): void;
  34454. /**
  34455. * Gets a general parser from the list of avaialble ones
  34456. * @param name Defines the name of the parser
  34457. * @returns the requested parser or null
  34458. */
  34459. static GetParser(name: string): Nullable<BabylonFileParser>;
  34460. /**
  34461. * Adds n individual parser in the list of available ones
  34462. * @param name Defines the name of the parser
  34463. * @param parser Defines the parser to add
  34464. */
  34465. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  34466. /**
  34467. * Gets an individual parser from the list of avaialble ones
  34468. * @param name Defines the name of the parser
  34469. * @returns the requested parser or null
  34470. */
  34471. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  34472. /**
  34473. * Parser json data and populate both a scene and its associated container object
  34474. * @param jsonData Defines the data to parse
  34475. * @param scene Defines the scene to parse the data for
  34476. * @param container Defines the container attached to the parsing sequence
  34477. * @param rootUrl Defines the root url of the data
  34478. */
  34479. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  34480. /**
  34481. * Gets the list of root nodes (ie. nodes with no parent)
  34482. */
  34483. rootNodes: Node[];
  34484. /** All of the cameras added to this scene
  34485. * @see http://doc.babylonjs.com/babylon101/cameras
  34486. */
  34487. cameras: Camera[];
  34488. /**
  34489. * All of the lights added to this scene
  34490. * @see http://doc.babylonjs.com/babylon101/lights
  34491. */
  34492. lights: Light[];
  34493. /**
  34494. * All of the (abstract) meshes added to this scene
  34495. */
  34496. meshes: AbstractMesh[];
  34497. /**
  34498. * The list of skeletons added to the scene
  34499. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  34500. */
  34501. skeletons: Skeleton[];
  34502. /**
  34503. * All of the particle systems added to this scene
  34504. * @see http://doc.babylonjs.com/babylon101/particles
  34505. */
  34506. particleSystems: IParticleSystem[];
  34507. /**
  34508. * Gets a list of Animations associated with the scene
  34509. */
  34510. animations: Animation[];
  34511. /**
  34512. * All of the animation groups added to this scene
  34513. * @see http://doc.babylonjs.com/how_to/group
  34514. */
  34515. animationGroups: AnimationGroup[];
  34516. /**
  34517. * All of the multi-materials added to this scene
  34518. * @see http://doc.babylonjs.com/how_to/multi_materials
  34519. */
  34520. multiMaterials: MultiMaterial[];
  34521. /**
  34522. * All of the materials added to this scene
  34523. * In the context of a Scene, it is not supposed to be modified manually.
  34524. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  34525. * Note also that the order of the Material wihin the array is not significant and might change.
  34526. * @see http://doc.babylonjs.com/babylon101/materials
  34527. */
  34528. materials: Material[];
  34529. /**
  34530. * The list of morph target managers added to the scene
  34531. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  34532. */
  34533. morphTargetManagers: MorphTargetManager[];
  34534. /**
  34535. * The list of geometries used in the scene.
  34536. */
  34537. geometries: Geometry[];
  34538. /**
  34539. * All of the tranform nodes added to this scene
  34540. * In the context of a Scene, it is not supposed to be modified manually.
  34541. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  34542. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  34543. * @see http://doc.babylonjs.com/how_to/transformnode
  34544. */
  34545. transformNodes: TransformNode[];
  34546. /**
  34547. * ActionManagers available on the scene.
  34548. */
  34549. actionManagers: AbstractActionManager[];
  34550. /**
  34551. * Textures to keep.
  34552. */
  34553. textures: BaseTexture[];
  34554. /**
  34555. * Environment texture for the scene
  34556. */
  34557. environmentTexture: Nullable<BaseTexture>;
  34558. }
  34559. }
  34560. declare module "babylonjs/Audio/sound" {
  34561. import { Observable } from "babylonjs/Misc/observable";
  34562. import { Vector3 } from "babylonjs/Maths/math";
  34563. import { Nullable } from "babylonjs/types";
  34564. import { Scene } from "babylonjs/scene";
  34565. import { TransformNode } from "babylonjs/Meshes/transformNode";
  34566. /**
  34567. * Defines a sound that can be played in the application.
  34568. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  34569. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  34570. */
  34571. export class Sound {
  34572. /**
  34573. * The name of the sound in the scene.
  34574. */
  34575. name: string;
  34576. /**
  34577. * Does the sound autoplay once loaded.
  34578. */
  34579. autoplay: boolean;
  34580. /**
  34581. * Does the sound loop after it finishes playing once.
  34582. */
  34583. loop: boolean;
  34584. /**
  34585. * Does the sound use a custom attenuation curve to simulate the falloff
  34586. * happening when the source gets further away from the camera.
  34587. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34588. */
  34589. useCustomAttenuation: boolean;
  34590. /**
  34591. * The sound track id this sound belongs to.
  34592. */
  34593. soundTrackId: number;
  34594. /**
  34595. * Is this sound currently played.
  34596. */
  34597. isPlaying: boolean;
  34598. /**
  34599. * Is this sound currently paused.
  34600. */
  34601. isPaused: boolean;
  34602. /**
  34603. * Does this sound enables spatial sound.
  34604. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34605. */
  34606. spatialSound: boolean;
  34607. /**
  34608. * Define the reference distance the sound should be heard perfectly.
  34609. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34610. */
  34611. refDistance: number;
  34612. /**
  34613. * Define the roll off factor of spatial sounds.
  34614. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34615. */
  34616. rolloffFactor: number;
  34617. /**
  34618. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  34619. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34620. */
  34621. maxDistance: number;
  34622. /**
  34623. * Define the distance attenuation model the sound will follow.
  34624. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34625. */
  34626. distanceModel: string;
  34627. /**
  34628. * @hidden
  34629. * Back Compat
  34630. **/
  34631. onended: () => any;
  34632. /**
  34633. * Observable event when the current playing sound finishes.
  34634. */
  34635. onEndedObservable: Observable<Sound>;
  34636. private _panningModel;
  34637. private _playbackRate;
  34638. private _streaming;
  34639. private _startTime;
  34640. private _startOffset;
  34641. private _position;
  34642. /** @hidden */
  34643. _positionInEmitterSpace: boolean;
  34644. private _localDirection;
  34645. private _volume;
  34646. private _isReadyToPlay;
  34647. private _isDirectional;
  34648. private _readyToPlayCallback;
  34649. private _audioBuffer;
  34650. private _soundSource;
  34651. private _streamingSource;
  34652. private _soundPanner;
  34653. private _soundGain;
  34654. private _inputAudioNode;
  34655. private _outputAudioNode;
  34656. private _coneInnerAngle;
  34657. private _coneOuterAngle;
  34658. private _coneOuterGain;
  34659. private _scene;
  34660. private _connectedTransformNode;
  34661. private _customAttenuationFunction;
  34662. private _registerFunc;
  34663. private _isOutputConnected;
  34664. private _htmlAudioElement;
  34665. private _urlType;
  34666. /** @hidden */
  34667. static _SceneComponentInitialization: (scene: Scene) => void;
  34668. /**
  34669. * Create a sound and attach it to a scene
  34670. * @param name Name of your sound
  34671. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  34672. * @param scene defines the scene the sound belongs to
  34673. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  34674. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  34675. */
  34676. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  34677. /**
  34678. * Release the sound and its associated resources
  34679. */
  34680. dispose(): void;
  34681. /**
  34682. * Gets if the sounds is ready to be played or not.
  34683. * @returns true if ready, otherwise false
  34684. */
  34685. isReady(): boolean;
  34686. private _soundLoaded;
  34687. /**
  34688. * Sets the data of the sound from an audiobuffer
  34689. * @param audioBuffer The audioBuffer containing the data
  34690. */
  34691. setAudioBuffer(audioBuffer: AudioBuffer): void;
  34692. /**
  34693. * Updates the current sounds options such as maxdistance, loop...
  34694. * @param options A JSON object containing values named as the object properties
  34695. */
  34696. updateOptions(options: any): void;
  34697. private _createSpatialParameters;
  34698. private _updateSpatialParameters;
  34699. /**
  34700. * Switch the panning model to HRTF:
  34701. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  34702. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34703. */
  34704. switchPanningModelToHRTF(): void;
  34705. /**
  34706. * Switch the panning model to Equal Power:
  34707. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  34708. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  34709. */
  34710. switchPanningModelToEqualPower(): void;
  34711. private _switchPanningModel;
  34712. /**
  34713. * Connect this sound to a sound track audio node like gain...
  34714. * @param soundTrackAudioNode the sound track audio node to connect to
  34715. */
  34716. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  34717. /**
  34718. * Transform this sound into a directional source
  34719. * @param coneInnerAngle Size of the inner cone in degree
  34720. * @param coneOuterAngle Size of the outer cone in degree
  34721. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  34722. */
  34723. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  34724. /**
  34725. * Gets or sets the inner angle for the directional cone.
  34726. */
  34727. /**
  34728. * Gets or sets the inner angle for the directional cone.
  34729. */
  34730. directionalConeInnerAngle: number;
  34731. /**
  34732. * Gets or sets the outer angle for the directional cone.
  34733. */
  34734. /**
  34735. * Gets or sets the outer angle for the directional cone.
  34736. */
  34737. directionalConeOuterAngle: number;
  34738. /**
  34739. * Sets the position of the emitter if spatial sound is enabled
  34740. * @param newPosition Defines the new posisiton
  34741. */
  34742. setPosition(newPosition: Vector3): void;
  34743. /**
  34744. * Sets the local direction of the emitter if spatial sound is enabled
  34745. * @param newLocalDirection Defines the new local direction
  34746. */
  34747. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  34748. private _updateDirection;
  34749. /** @hidden */
  34750. updateDistanceFromListener(): void;
  34751. /**
  34752. * Sets a new custom attenuation function for the sound.
  34753. * @param callback Defines the function used for the attenuation
  34754. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  34755. */
  34756. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  34757. /**
  34758. * Play the sound
  34759. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  34760. * @param offset (optional) Start the sound setting it at a specific time
  34761. */
  34762. play(time?: number, offset?: number): void;
  34763. private _onended;
  34764. /**
  34765. * Stop the sound
  34766. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  34767. */
  34768. stop(time?: number): void;
  34769. /**
  34770. * Put the sound in pause
  34771. */
  34772. pause(): void;
  34773. /**
  34774. * Sets a dedicated volume for this sounds
  34775. * @param newVolume Define the new volume of the sound
  34776. * @param time Define in how long the sound should be at this value
  34777. */
  34778. setVolume(newVolume: number, time?: number): void;
  34779. /**
  34780. * Set the sound play back rate
  34781. * @param newPlaybackRate Define the playback rate the sound should be played at
  34782. */
  34783. setPlaybackRate(newPlaybackRate: number): void;
  34784. /**
  34785. * Gets the volume of the sound.
  34786. * @returns the volume of the sound
  34787. */
  34788. getVolume(): number;
  34789. /**
  34790. * Attach the sound to a dedicated mesh
  34791. * @param transformNode The transform node to connect the sound with
  34792. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34793. */
  34794. attachToMesh(transformNode: TransformNode): void;
  34795. /**
  34796. * Detach the sound from the previously attached mesh
  34797. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  34798. */
  34799. detachFromMesh(): void;
  34800. private _onRegisterAfterWorldMatrixUpdate;
  34801. /**
  34802. * Clone the current sound in the scene.
  34803. * @returns the new sound clone
  34804. */
  34805. clone(): Nullable<Sound>;
  34806. /**
  34807. * Gets the current underlying audio buffer containing the data
  34808. * @returns the audio buffer
  34809. */
  34810. getAudioBuffer(): Nullable<AudioBuffer>;
  34811. /**
  34812. * Serializes the Sound in a JSON representation
  34813. * @returns the JSON representation of the sound
  34814. */
  34815. serialize(): any;
  34816. /**
  34817. * Parse a JSON representation of a sound to innstantiate in a given scene
  34818. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  34819. * @param scene Define the scene the new parsed sound should be created in
  34820. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  34821. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  34822. * @returns the newly parsed sound
  34823. */
  34824. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  34825. }
  34826. }
  34827. declare module "babylonjs/Actions/directAudioActions" {
  34828. import { Action } from "babylonjs/Actions/action";
  34829. import { Condition } from "babylonjs/Actions/condition";
  34830. import { Sound } from "babylonjs/Audio/sound";
  34831. /**
  34832. * This defines an action helpful to play a defined sound on a triggered action.
  34833. */
  34834. export class PlaySoundAction extends Action {
  34835. private _sound;
  34836. /**
  34837. * Instantiate the action
  34838. * @param triggerOptions defines the trigger options
  34839. * @param sound defines the sound to play
  34840. * @param condition defines the trigger related conditions
  34841. */
  34842. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34843. /** @hidden */
  34844. _prepare(): void;
  34845. /**
  34846. * Execute the action and play the sound.
  34847. */
  34848. execute(): void;
  34849. /**
  34850. * Serializes the actions and its related information.
  34851. * @param parent defines the object to serialize in
  34852. * @returns the serialized object
  34853. */
  34854. serialize(parent: any): any;
  34855. }
  34856. /**
  34857. * This defines an action helpful to stop a defined sound on a triggered action.
  34858. */
  34859. export class StopSoundAction extends Action {
  34860. private _sound;
  34861. /**
  34862. * Instantiate the action
  34863. * @param triggerOptions defines the trigger options
  34864. * @param sound defines the sound to stop
  34865. * @param condition defines the trigger related conditions
  34866. */
  34867. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  34868. /** @hidden */
  34869. _prepare(): void;
  34870. /**
  34871. * Execute the action and stop the sound.
  34872. */
  34873. execute(): void;
  34874. /**
  34875. * Serializes the actions and its related information.
  34876. * @param parent defines the object to serialize in
  34877. * @returns the serialized object
  34878. */
  34879. serialize(parent: any): any;
  34880. }
  34881. }
  34882. declare module "babylonjs/Actions/interpolateValueAction" {
  34883. import { Action } from "babylonjs/Actions/action";
  34884. import { Condition } from "babylonjs/Actions/condition";
  34885. import { Observable } from "babylonjs/Misc/observable";
  34886. /**
  34887. * This defines an action responsible to change the value of a property
  34888. * by interpolating between its current value and the newly set one once triggered.
  34889. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  34890. */
  34891. export class InterpolateValueAction extends Action {
  34892. /**
  34893. * Defines the path of the property where the value should be interpolated
  34894. */
  34895. propertyPath: string;
  34896. /**
  34897. * Defines the target value at the end of the interpolation.
  34898. */
  34899. value: any;
  34900. /**
  34901. * Defines the time it will take for the property to interpolate to the value.
  34902. */
  34903. duration: number;
  34904. /**
  34905. * Defines if the other scene animations should be stopped when the action has been triggered
  34906. */
  34907. stopOtherAnimations?: boolean;
  34908. /**
  34909. * Defines a callback raised once the interpolation animation has been done.
  34910. */
  34911. onInterpolationDone?: () => void;
  34912. /**
  34913. * Observable triggered once the interpolation animation has been done.
  34914. */
  34915. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  34916. private _target;
  34917. private _effectiveTarget;
  34918. private _property;
  34919. /**
  34920. * Instantiate the action
  34921. * @param triggerOptions defines the trigger options
  34922. * @param target defines the object containing the value to interpolate
  34923. * @param propertyPath defines the path to the property in the target object
  34924. * @param value defines the target value at the end of the interpolation
  34925. * @param duration deines the time it will take for the property to interpolate to the value.
  34926. * @param condition defines the trigger related conditions
  34927. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  34928. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  34929. */
  34930. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  34931. /** @hidden */
  34932. _prepare(): void;
  34933. /**
  34934. * Execute the action starts the value interpolation.
  34935. */
  34936. execute(): void;
  34937. /**
  34938. * Serializes the actions and its related information.
  34939. * @param parent defines the object to serialize in
  34940. * @returns the serialized object
  34941. */
  34942. serialize(parent: any): any;
  34943. }
  34944. }
  34945. declare module "babylonjs/Actions/index" {
  34946. export * from "babylonjs/Actions/action";
  34947. export * from "babylonjs/Actions/actionEvent";
  34948. export * from "babylonjs/Actions/actionManager";
  34949. export * from "babylonjs/Actions/condition";
  34950. export * from "babylonjs/Actions/directActions";
  34951. export * from "babylonjs/Actions/directAudioActions";
  34952. export * from "babylonjs/Actions/interpolateValueAction";
  34953. }
  34954. declare module "babylonjs/Animations/index" {
  34955. export * from "babylonjs/Animations/animatable";
  34956. export * from "babylonjs/Animations/animation";
  34957. export * from "babylonjs/Animations/animationGroup";
  34958. export * from "babylonjs/Animations/animationPropertiesOverride";
  34959. export * from "babylonjs/Animations/easing";
  34960. export * from "babylonjs/Animations/runtimeAnimation";
  34961. export * from "babylonjs/Animations/animationEvent";
  34962. export * from "babylonjs/Animations/animationGroup";
  34963. export * from "babylonjs/Animations/animationKey";
  34964. export * from "babylonjs/Animations/animationRange";
  34965. }
  34966. declare module "babylonjs/Audio/soundTrack" {
  34967. import { Sound } from "babylonjs/Audio/sound";
  34968. import { Analyser } from "babylonjs/Audio/analyser";
  34969. import { Scene } from "babylonjs/scene";
  34970. /**
  34971. * Options allowed during the creation of a sound track.
  34972. */
  34973. export interface ISoundTrackOptions {
  34974. /**
  34975. * The volume the sound track should take during creation
  34976. */
  34977. volume?: number;
  34978. /**
  34979. * Define if the sound track is the main sound track of the scene
  34980. */
  34981. mainTrack?: boolean;
  34982. }
  34983. /**
  34984. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  34985. * It will be also used in a future release to apply effects on a specific track.
  34986. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  34987. */
  34988. export class SoundTrack {
  34989. /**
  34990. * The unique identifier of the sound track in the scene.
  34991. */
  34992. id: number;
  34993. /**
  34994. * The list of sounds included in the sound track.
  34995. */
  34996. soundCollection: Array<Sound>;
  34997. private _outputAudioNode;
  34998. private _scene;
  34999. private _isMainTrack;
  35000. private _connectedAnalyser;
  35001. private _options;
  35002. private _isInitialized;
  35003. /**
  35004. * Creates a new sound track.
  35005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  35006. * @param scene Define the scene the sound track belongs to
  35007. * @param options
  35008. */
  35009. constructor(scene: Scene, options?: ISoundTrackOptions);
  35010. private _initializeSoundTrackAudioGraph;
  35011. /**
  35012. * Release the sound track and its associated resources
  35013. */
  35014. dispose(): void;
  35015. /**
  35016. * Adds a sound to this sound track
  35017. * @param sound define the cound to add
  35018. * @ignoreNaming
  35019. */
  35020. AddSound(sound: Sound): void;
  35021. /**
  35022. * Removes a sound to this sound track
  35023. * @param sound define the cound to remove
  35024. * @ignoreNaming
  35025. */
  35026. RemoveSound(sound: Sound): void;
  35027. /**
  35028. * Set a global volume for the full sound track.
  35029. * @param newVolume Define the new volume of the sound track
  35030. */
  35031. setVolume(newVolume: number): void;
  35032. /**
  35033. * Switch the panning model to HRTF:
  35034. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  35035. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35036. */
  35037. switchPanningModelToHRTF(): void;
  35038. /**
  35039. * Switch the panning model to Equal Power:
  35040. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  35041. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  35042. */
  35043. switchPanningModelToEqualPower(): void;
  35044. /**
  35045. * Connect the sound track to an audio analyser allowing some amazing
  35046. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  35047. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  35048. * @param analyser The analyser to connect to the engine
  35049. */
  35050. connectToAnalyser(analyser: Analyser): void;
  35051. }
  35052. }
  35053. declare module "babylonjs/Audio/audioSceneComponent" {
  35054. import { Sound } from "babylonjs/Audio/sound";
  35055. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  35056. import { Nullable } from "babylonjs/types";
  35057. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  35058. import { Scene } from "babylonjs/scene";
  35059. import { AbstractScene } from "babylonjs/abstractScene";
  35060. module "babylonjs/abstractScene" {
  35061. interface AbstractScene {
  35062. /**
  35063. * The list of sounds used in the scene.
  35064. */
  35065. sounds: Nullable<Array<Sound>>;
  35066. }
  35067. }
  35068. module "babylonjs/scene" {
  35069. interface Scene {
  35070. /**
  35071. * @hidden
  35072. * Backing field
  35073. */
  35074. _mainSoundTrack: SoundTrack;
  35075. /**
  35076. * The main sound track played by the scene.
  35077. * It cotains your primary collection of sounds.
  35078. */
  35079. mainSoundTrack: SoundTrack;
  35080. /**
  35081. * The list of sound tracks added to the scene
  35082. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35083. */
  35084. soundTracks: Nullable<Array<SoundTrack>>;
  35085. /**
  35086. * Gets a sound using a given name
  35087. * @param name defines the name to search for
  35088. * @return the found sound or null if not found at all.
  35089. */
  35090. getSoundByName(name: string): Nullable<Sound>;
  35091. /**
  35092. * Gets or sets if audio support is enabled
  35093. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35094. */
  35095. audioEnabled: boolean;
  35096. /**
  35097. * Gets or sets if audio will be output to headphones
  35098. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  35099. */
  35100. headphone: boolean;
  35101. }
  35102. }
  35103. /**
  35104. * Defines the sound scene component responsible to manage any sounds
  35105. * in a given scene.
  35106. */
  35107. export class AudioSceneComponent implements ISceneSerializableComponent {
  35108. /**
  35109. * The component name helpfull to identify the component in the list of scene components.
  35110. */
  35111. readonly name: string;
  35112. /**
  35113. * The scene the component belongs to.
  35114. */
  35115. scene: Scene;
  35116. private _audioEnabled;
  35117. /**
  35118. * Gets whether audio is enabled or not.
  35119. * Please use related enable/disable method to switch state.
  35120. */
  35121. readonly audioEnabled: boolean;
  35122. private _headphone;
  35123. /**
  35124. * Gets whether audio is outputing to headphone or not.
  35125. * Please use the according Switch methods to change output.
  35126. */
  35127. readonly headphone: boolean;
  35128. /**
  35129. * Creates a new instance of the component for the given scene
  35130. * @param scene Defines the scene to register the component in
  35131. */
  35132. constructor(scene: Scene);
  35133. /**
  35134. * Registers the component in a given scene
  35135. */
  35136. register(): void;
  35137. /**
  35138. * Rebuilds the elements related to this component in case of
  35139. * context lost for instance.
  35140. */
  35141. rebuild(): void;
  35142. /**
  35143. * Serializes the component data to the specified json object
  35144. * @param serializationObject The object to serialize to
  35145. */
  35146. serialize(serializationObject: any): void;
  35147. /**
  35148. * Adds all the element from the container to the scene
  35149. * @param container the container holding the elements
  35150. */
  35151. addFromContainer(container: AbstractScene): void;
  35152. /**
  35153. * Removes all the elements in the container from the scene
  35154. * @param container contains the elements to remove
  35155. * @param dispose if the removed element should be disposed (default: false)
  35156. */
  35157. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  35158. /**
  35159. * Disposes the component and the associated ressources.
  35160. */
  35161. dispose(): void;
  35162. /**
  35163. * Disables audio in the associated scene.
  35164. */
  35165. disableAudio(): void;
  35166. /**
  35167. * Enables audio in the associated scene.
  35168. */
  35169. enableAudio(): void;
  35170. /**
  35171. * Switch audio to headphone output.
  35172. */
  35173. switchAudioModeForHeadphones(): void;
  35174. /**
  35175. * Switch audio to normal speakers.
  35176. */
  35177. switchAudioModeForNormalSpeakers(): void;
  35178. private _afterRender;
  35179. }
  35180. }
  35181. declare module "babylonjs/Audio/weightedsound" {
  35182. import { Sound } from "babylonjs/Audio/sound";
  35183. /**
  35184. * Wraps one or more Sound objects and selects one with random weight for playback.
  35185. */
  35186. export class WeightedSound {
  35187. /** When true a Sound will be selected and played when the current playing Sound completes. */
  35188. loop: boolean;
  35189. private _coneInnerAngle;
  35190. private _coneOuterAngle;
  35191. private _volume;
  35192. /** A Sound is currently playing. */
  35193. isPlaying: boolean;
  35194. /** A Sound is currently paused. */
  35195. isPaused: boolean;
  35196. private _sounds;
  35197. private _weights;
  35198. private _currentIndex?;
  35199. /**
  35200. * Creates a new WeightedSound from the list of sounds given.
  35201. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  35202. * @param sounds Array of Sounds that will be selected from.
  35203. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  35204. */
  35205. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  35206. /**
  35207. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  35208. */
  35209. /**
  35210. * The size of cone in degress for a directional sound in which there will be no attenuation.
  35211. */
  35212. directionalConeInnerAngle: number;
  35213. /**
  35214. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35215. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35216. */
  35217. /**
  35218. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  35219. * Listener angles between innerAngle and outerAngle will falloff linearly.
  35220. */
  35221. directionalConeOuterAngle: number;
  35222. /**
  35223. * Playback volume.
  35224. */
  35225. /**
  35226. * Playback volume.
  35227. */
  35228. volume: number;
  35229. private _onended;
  35230. /**
  35231. * Suspend playback
  35232. */
  35233. pause(): void;
  35234. /**
  35235. * Stop playback
  35236. */
  35237. stop(): void;
  35238. /**
  35239. * Start playback.
  35240. * @param startOffset Position the clip head at a specific time in seconds.
  35241. */
  35242. play(startOffset?: number): void;
  35243. }
  35244. }
  35245. declare module "babylonjs/Audio/index" {
  35246. export * from "babylonjs/Audio/analyser";
  35247. export * from "babylonjs/Audio/audioEngine";
  35248. export * from "babylonjs/Audio/audioSceneComponent";
  35249. export * from "babylonjs/Audio/sound";
  35250. export * from "babylonjs/Audio/soundTrack";
  35251. export * from "babylonjs/Audio/weightedsound";
  35252. }
  35253. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  35254. import { Behavior } from "babylonjs/Behaviors/behavior";
  35255. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35256. import { BackEase } from "babylonjs/Animations/easing";
  35257. /**
  35258. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  35259. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  35260. */
  35261. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  35262. /**
  35263. * Gets the name of the behavior.
  35264. */
  35265. readonly name: string;
  35266. /**
  35267. * The easing function used by animations
  35268. */
  35269. static EasingFunction: BackEase;
  35270. /**
  35271. * The easing mode used by animations
  35272. */
  35273. static EasingMode: number;
  35274. /**
  35275. * The duration of the animation, in milliseconds
  35276. */
  35277. transitionDuration: number;
  35278. /**
  35279. * Length of the distance animated by the transition when lower radius is reached
  35280. */
  35281. lowerRadiusTransitionRange: number;
  35282. /**
  35283. * Length of the distance animated by the transition when upper radius is reached
  35284. */
  35285. upperRadiusTransitionRange: number;
  35286. private _autoTransitionRange;
  35287. /**
  35288. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35289. */
  35290. /**
  35291. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  35292. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  35293. */
  35294. autoTransitionRange: boolean;
  35295. private _attachedCamera;
  35296. private _onAfterCheckInputsObserver;
  35297. private _onMeshTargetChangedObserver;
  35298. /**
  35299. * Initializes the behavior.
  35300. */
  35301. init(): void;
  35302. /**
  35303. * Attaches the behavior to its arc rotate camera.
  35304. * @param camera Defines the camera to attach the behavior to
  35305. */
  35306. attach(camera: ArcRotateCamera): void;
  35307. /**
  35308. * Detaches the behavior from its current arc rotate camera.
  35309. */
  35310. detach(): void;
  35311. private _radiusIsAnimating;
  35312. private _radiusBounceTransition;
  35313. private _animatables;
  35314. private _cachedWheelPrecision;
  35315. /**
  35316. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  35317. * @param radiusLimit The limit to check against.
  35318. * @return Bool to indicate if at limit.
  35319. */
  35320. private _isRadiusAtLimit;
  35321. /**
  35322. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  35323. * @param radiusDelta The delta by which to animate to. Can be negative.
  35324. */
  35325. private _applyBoundRadiusAnimation;
  35326. /**
  35327. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  35328. */
  35329. protected _clearAnimationLocks(): void;
  35330. /**
  35331. * Stops and removes all animations that have been applied to the camera
  35332. */
  35333. stopAllAnimations(): void;
  35334. }
  35335. }
  35336. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  35337. import { Behavior } from "babylonjs/Behaviors/behavior";
  35338. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35339. import { ExponentialEase } from "babylonjs/Animations/easing";
  35340. import { Nullable } from "babylonjs/types";
  35341. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35342. import { Vector3 } from "babylonjs/Maths/math";
  35343. /**
  35344. * 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.
  35345. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  35346. */
  35347. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  35348. /**
  35349. * Gets the name of the behavior.
  35350. */
  35351. readonly name: string;
  35352. private _mode;
  35353. private _radiusScale;
  35354. private _positionScale;
  35355. private _defaultElevation;
  35356. private _elevationReturnTime;
  35357. private _elevationReturnWaitTime;
  35358. private _zoomStopsAnimation;
  35359. private _framingTime;
  35360. /**
  35361. * The easing function used by animations
  35362. */
  35363. static EasingFunction: ExponentialEase;
  35364. /**
  35365. * The easing mode used by animations
  35366. */
  35367. static EasingMode: number;
  35368. /**
  35369. * Sets the current mode used by the behavior
  35370. */
  35371. /**
  35372. * Gets current mode used by the behavior.
  35373. */
  35374. mode: number;
  35375. /**
  35376. * Sets the scale applied to the radius (1 by default)
  35377. */
  35378. /**
  35379. * Gets the scale applied to the radius
  35380. */
  35381. radiusScale: number;
  35382. /**
  35383. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35384. */
  35385. /**
  35386. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  35387. */
  35388. positionScale: number;
  35389. /**
  35390. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35391. * behaviour is triggered, in radians.
  35392. */
  35393. /**
  35394. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  35395. * behaviour is triggered, in radians.
  35396. */
  35397. defaultElevation: number;
  35398. /**
  35399. * Sets the time (in milliseconds) taken to return to the default beta position.
  35400. * Negative value indicates camera should not return to default.
  35401. */
  35402. /**
  35403. * Gets the time (in milliseconds) taken to return to the default beta position.
  35404. * Negative value indicates camera should not return to default.
  35405. */
  35406. elevationReturnTime: number;
  35407. /**
  35408. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35409. */
  35410. /**
  35411. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  35412. */
  35413. elevationReturnWaitTime: number;
  35414. /**
  35415. * Sets the flag that indicates if user zooming should stop animation.
  35416. */
  35417. /**
  35418. * Gets the flag that indicates if user zooming should stop animation.
  35419. */
  35420. zoomStopsAnimation: boolean;
  35421. /**
  35422. * Sets the transition time when framing the mesh, in milliseconds
  35423. */
  35424. /**
  35425. * Gets the transition time when framing the mesh, in milliseconds
  35426. */
  35427. framingTime: number;
  35428. /**
  35429. * Define if the behavior should automatically change the configured
  35430. * camera limits and sensibilities.
  35431. */
  35432. autoCorrectCameraLimitsAndSensibility: boolean;
  35433. private _onPrePointerObservableObserver;
  35434. private _onAfterCheckInputsObserver;
  35435. private _onMeshTargetChangedObserver;
  35436. private _attachedCamera;
  35437. private _isPointerDown;
  35438. private _lastInteractionTime;
  35439. /**
  35440. * Initializes the behavior.
  35441. */
  35442. init(): void;
  35443. /**
  35444. * Attaches the behavior to its arc rotate camera.
  35445. * @param camera Defines the camera to attach the behavior to
  35446. */
  35447. attach(camera: ArcRotateCamera): void;
  35448. /**
  35449. * Detaches the behavior from its current arc rotate camera.
  35450. */
  35451. detach(): void;
  35452. private _animatables;
  35453. private _betaIsAnimating;
  35454. private _betaTransition;
  35455. private _radiusTransition;
  35456. private _vectorTransition;
  35457. /**
  35458. * Targets the given mesh and updates zoom level accordingly.
  35459. * @param mesh The mesh to target.
  35460. * @param radius Optional. If a cached radius position already exists, overrides default.
  35461. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35462. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35463. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35464. */
  35465. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35466. /**
  35467. * Targets the given mesh with its children and updates zoom level accordingly.
  35468. * @param mesh The mesh to target.
  35469. * @param radius Optional. If a cached radius position already exists, overrides default.
  35470. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35471. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35472. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35473. */
  35474. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35475. /**
  35476. * Targets the given meshes with their children and updates zoom level accordingly.
  35477. * @param meshes The mesh to target.
  35478. * @param radius Optional. If a cached radius position already exists, overrides default.
  35479. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  35480. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35481. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35482. */
  35483. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35484. /**
  35485. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  35486. * @param minimumWorld Determines the smaller position of the bounding box extend
  35487. * @param maximumWorld Determines the bigger position of the bounding box extend
  35488. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  35489. * @param onAnimationEnd Callback triggered at the end of the framing animation
  35490. */
  35491. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  35492. /**
  35493. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  35494. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  35495. * frustum width.
  35496. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  35497. * to fully enclose the mesh in the viewing frustum.
  35498. */
  35499. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  35500. /**
  35501. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  35502. * is automatically returned to its default position (expected to be above ground plane).
  35503. */
  35504. private _maintainCameraAboveGround;
  35505. /**
  35506. * Returns the frustum slope based on the canvas ratio and camera FOV
  35507. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  35508. */
  35509. private _getFrustumSlope;
  35510. /**
  35511. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  35512. */
  35513. private _clearAnimationLocks;
  35514. /**
  35515. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  35516. */
  35517. private _applyUserInteraction;
  35518. /**
  35519. * Stops and removes all animations that have been applied to the camera
  35520. */
  35521. stopAllAnimations(): void;
  35522. /**
  35523. * Gets a value indicating if the user is moving the camera
  35524. */
  35525. readonly isUserIsMoving: boolean;
  35526. /**
  35527. * The camera can move all the way towards the mesh.
  35528. */
  35529. static IgnoreBoundsSizeMode: number;
  35530. /**
  35531. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  35532. */
  35533. static FitFrustumSidesMode: number;
  35534. }
  35535. }
  35536. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  35537. import { Nullable } from "babylonjs/types";
  35538. import { Camera } from "babylonjs/Cameras/camera";
  35539. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35540. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35541. /**
  35542. * Base class for Camera Pointer Inputs.
  35543. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  35544. * for example usage.
  35545. */
  35546. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  35547. /**
  35548. * Defines the camera the input is attached to.
  35549. */
  35550. abstract camera: Camera;
  35551. /**
  35552. * Whether keyboard modifier keys are pressed at time of last mouse event.
  35553. */
  35554. protected _altKey: boolean;
  35555. protected _ctrlKey: boolean;
  35556. protected _metaKey: boolean;
  35557. protected _shiftKey: boolean;
  35558. /**
  35559. * Which mouse buttons were pressed at time of last mouse event.
  35560. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  35561. */
  35562. protected _buttonsPressed: number;
  35563. /**
  35564. * Defines the buttons associated with the input to handle camera move.
  35565. */
  35566. buttons: number[];
  35567. /**
  35568. * Attach the input controls to a specific dom element to get the input from.
  35569. * @param element Defines the element the controls should be listened from
  35570. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35571. */
  35572. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35573. /**
  35574. * Detach the current controls from the specified dom element.
  35575. * @param element Defines the element to stop listening the inputs from
  35576. */
  35577. detachControl(element: Nullable<HTMLElement>): void;
  35578. /**
  35579. * Gets the class name of the current input.
  35580. * @returns the class name
  35581. */
  35582. getClassName(): string;
  35583. /**
  35584. * Get the friendly name associated with the input class.
  35585. * @returns the input friendly name
  35586. */
  35587. getSimpleName(): string;
  35588. /**
  35589. * Called on pointer POINTERDOUBLETAP event.
  35590. * Override this method to provide functionality on POINTERDOUBLETAP event.
  35591. */
  35592. protected onDoubleTap(type: string): void;
  35593. /**
  35594. * Called on pointer POINTERMOVE event if only a single touch is active.
  35595. * Override this method to provide functionality.
  35596. */
  35597. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35598. /**
  35599. * Called on pointer POINTERMOVE event if multiple touches are active.
  35600. * Override this method to provide functionality.
  35601. */
  35602. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35603. /**
  35604. * Called on JS contextmenu event.
  35605. * Override this method to provide functionality.
  35606. */
  35607. protected onContextMenu(evt: PointerEvent): void;
  35608. /**
  35609. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35610. * press.
  35611. * Override this method to provide functionality.
  35612. */
  35613. protected onButtonDown(evt: PointerEvent): void;
  35614. /**
  35615. * Called each time a new POINTERUP event occurs. Ie, for each button
  35616. * release.
  35617. * Override this method to provide functionality.
  35618. */
  35619. protected onButtonUp(evt: PointerEvent): void;
  35620. /**
  35621. * Called when window becomes inactive.
  35622. * Override this method to provide functionality.
  35623. */
  35624. protected onLostFocus(): void;
  35625. private _pointerInput;
  35626. private _observer;
  35627. private _onLostFocus;
  35628. private pointA;
  35629. private pointB;
  35630. }
  35631. }
  35632. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  35633. import { Nullable } from "babylonjs/types";
  35634. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35635. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  35636. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  35637. /**
  35638. * Manage the pointers inputs to control an arc rotate camera.
  35639. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35640. */
  35641. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  35642. /**
  35643. * Defines the camera the input is attached to.
  35644. */
  35645. camera: ArcRotateCamera;
  35646. /**
  35647. * Gets the class name of the current input.
  35648. * @returns the class name
  35649. */
  35650. getClassName(): string;
  35651. /**
  35652. * Defines the buttons associated with the input to handle camera move.
  35653. */
  35654. buttons: number[];
  35655. /**
  35656. * Defines the pointer angular sensibility along the X axis or how fast is
  35657. * the camera rotating.
  35658. */
  35659. angularSensibilityX: number;
  35660. /**
  35661. * Defines the pointer angular sensibility along the Y axis or how fast is
  35662. * the camera rotating.
  35663. */
  35664. angularSensibilityY: number;
  35665. /**
  35666. * Defines the pointer pinch precision or how fast is the camera zooming.
  35667. */
  35668. pinchPrecision: number;
  35669. /**
  35670. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  35671. * from 0.
  35672. * It defines the percentage of current camera.radius to use as delta when
  35673. * pinch zoom is used.
  35674. */
  35675. pinchDeltaPercentage: number;
  35676. /**
  35677. * Defines the pointer panning sensibility or how fast is the camera moving.
  35678. */
  35679. panningSensibility: number;
  35680. /**
  35681. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  35682. */
  35683. multiTouchPanning: boolean;
  35684. /**
  35685. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  35686. * zoom (pinch) through multitouch.
  35687. */
  35688. multiTouchPanAndZoom: boolean;
  35689. /**
  35690. * Revers pinch action direction.
  35691. */
  35692. pinchInwards: boolean;
  35693. private _isPanClick;
  35694. private _twoFingerActivityCount;
  35695. private _isPinching;
  35696. /**
  35697. * Called on pointer POINTERMOVE event if only a single touch is active.
  35698. */
  35699. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  35700. /**
  35701. * Called on pointer POINTERDOUBLETAP event.
  35702. */
  35703. protected onDoubleTap(type: string): void;
  35704. /**
  35705. * Called on pointer POINTERMOVE event if multiple touches are active.
  35706. */
  35707. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  35708. /**
  35709. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  35710. * press.
  35711. */
  35712. protected onButtonDown(evt: PointerEvent): void;
  35713. /**
  35714. * Called each time a new POINTERUP event occurs. Ie, for each button
  35715. * release.
  35716. */
  35717. protected onButtonUp(evt: PointerEvent): void;
  35718. /**
  35719. * Called when window becomes inactive.
  35720. */
  35721. protected onLostFocus(): void;
  35722. }
  35723. }
  35724. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  35725. import { Nullable } from "babylonjs/types";
  35726. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35727. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35728. /**
  35729. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  35730. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35731. */
  35732. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  35733. /**
  35734. * Defines the camera the input is attached to.
  35735. */
  35736. camera: ArcRotateCamera;
  35737. /**
  35738. * Defines the list of key codes associated with the up action (increase alpha)
  35739. */
  35740. keysUp: number[];
  35741. /**
  35742. * Defines the list of key codes associated with the down action (decrease alpha)
  35743. */
  35744. keysDown: number[];
  35745. /**
  35746. * Defines the list of key codes associated with the left action (increase beta)
  35747. */
  35748. keysLeft: number[];
  35749. /**
  35750. * Defines the list of key codes associated with the right action (decrease beta)
  35751. */
  35752. keysRight: number[];
  35753. /**
  35754. * Defines the list of key codes associated with the reset action.
  35755. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  35756. */
  35757. keysReset: number[];
  35758. /**
  35759. * Defines the panning sensibility of the inputs.
  35760. * (How fast is the camera paning)
  35761. */
  35762. panningSensibility: number;
  35763. /**
  35764. * Defines the zooming sensibility of the inputs.
  35765. * (How fast is the camera zooming)
  35766. */
  35767. zoomingSensibility: number;
  35768. /**
  35769. * Defines wether maintaining the alt key down switch the movement mode from
  35770. * orientation to zoom.
  35771. */
  35772. useAltToZoom: boolean;
  35773. /**
  35774. * Rotation speed of the camera
  35775. */
  35776. angularSpeed: number;
  35777. private _keys;
  35778. private _ctrlPressed;
  35779. private _altPressed;
  35780. private _onCanvasBlurObserver;
  35781. private _onKeyboardObserver;
  35782. private _engine;
  35783. private _scene;
  35784. /**
  35785. * Attach the input controls to a specific dom element to get the input from.
  35786. * @param element Defines the element the controls should be listened from
  35787. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35788. */
  35789. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35790. /**
  35791. * Detach the current controls from the specified dom element.
  35792. * @param element Defines the element to stop listening the inputs from
  35793. */
  35794. detachControl(element: Nullable<HTMLElement>): void;
  35795. /**
  35796. * Update the current camera state depending on the inputs that have been used this frame.
  35797. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  35798. */
  35799. checkInputs(): void;
  35800. /**
  35801. * Gets the class name of the current intput.
  35802. * @returns the class name
  35803. */
  35804. getClassName(): string;
  35805. /**
  35806. * Get the friendly name associated with the input class.
  35807. * @returns the input friendly name
  35808. */
  35809. getSimpleName(): string;
  35810. }
  35811. }
  35812. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  35813. import { Nullable } from "babylonjs/types";
  35814. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35815. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  35816. /**
  35817. * Manage the mouse wheel inputs to control an arc rotate camera.
  35818. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35819. */
  35820. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  35821. /**
  35822. * Defines the camera the input is attached to.
  35823. */
  35824. camera: ArcRotateCamera;
  35825. /**
  35826. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  35827. */
  35828. wheelPrecision: number;
  35829. /**
  35830. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  35831. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  35832. */
  35833. wheelDeltaPercentage: number;
  35834. private _wheel;
  35835. private _observer;
  35836. /**
  35837. * Attach the input controls to a specific dom element to get the input from.
  35838. * @param element Defines the element the controls should be listened from
  35839. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  35840. */
  35841. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  35842. /**
  35843. * Detach the current controls from the specified dom element.
  35844. * @param element Defines the element to stop listening the inputs from
  35845. */
  35846. detachControl(element: Nullable<HTMLElement>): void;
  35847. /**
  35848. * Gets the class name of the current intput.
  35849. * @returns the class name
  35850. */
  35851. getClassName(): string;
  35852. /**
  35853. * Get the friendly name associated with the input class.
  35854. * @returns the input friendly name
  35855. */
  35856. getSimpleName(): string;
  35857. }
  35858. }
  35859. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  35860. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  35861. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  35862. /**
  35863. * Default Inputs manager for the ArcRotateCamera.
  35864. * It groups all the default supported inputs for ease of use.
  35865. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  35866. */
  35867. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  35868. /**
  35869. * Instantiates a new ArcRotateCameraInputsManager.
  35870. * @param camera Defines the camera the inputs belong to
  35871. */
  35872. constructor(camera: ArcRotateCamera);
  35873. /**
  35874. * Add mouse wheel input support to the input manager.
  35875. * @returns the current input manager
  35876. */
  35877. addMouseWheel(): ArcRotateCameraInputsManager;
  35878. /**
  35879. * Add pointers input support to the input manager.
  35880. * @returns the current input manager
  35881. */
  35882. addPointers(): ArcRotateCameraInputsManager;
  35883. /**
  35884. * Add keyboard input support to the input manager.
  35885. * @returns the current input manager
  35886. */
  35887. addKeyboard(): ArcRotateCameraInputsManager;
  35888. }
  35889. }
  35890. declare module "babylonjs/Cameras/arcRotateCamera" {
  35891. import { Observable } from "babylonjs/Misc/observable";
  35892. import { Nullable } from "babylonjs/types";
  35893. import { Scene } from "babylonjs/scene";
  35894. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math";
  35895. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  35896. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  35897. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  35898. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  35899. import { Camera } from "babylonjs/Cameras/camera";
  35900. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  35901. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  35902. import { Collider } from "babylonjs/Collisions/collider";
  35903. /**
  35904. * This represents an orbital type of camera.
  35905. *
  35906. * 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.
  35907. * 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.
  35908. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  35909. */
  35910. export class ArcRotateCamera extends TargetCamera {
  35911. /**
  35912. * Defines the rotation angle of the camera along the longitudinal axis.
  35913. */
  35914. alpha: number;
  35915. /**
  35916. * Defines the rotation angle of the camera along the latitudinal axis.
  35917. */
  35918. beta: number;
  35919. /**
  35920. * Defines the radius of the camera from it s target point.
  35921. */
  35922. radius: number;
  35923. protected _target: Vector3;
  35924. protected _targetHost: Nullable<AbstractMesh>;
  35925. /**
  35926. * Defines the target point of the camera.
  35927. * The camera looks towards it form the radius distance.
  35928. */
  35929. target: Vector3;
  35930. /**
  35931. * Define the current local position of the camera in the scene
  35932. */
  35933. position: Vector3;
  35934. protected _upVector: Vector3;
  35935. protected _upToYMatrix: Matrix;
  35936. protected _YToUpMatrix: Matrix;
  35937. /**
  35938. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  35939. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  35940. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  35941. */
  35942. upVector: Vector3;
  35943. /**
  35944. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  35945. */
  35946. setMatUp(): void;
  35947. /**
  35948. * Current inertia value on the longitudinal axis.
  35949. * The bigger this number the longer it will take for the camera to stop.
  35950. */
  35951. inertialAlphaOffset: number;
  35952. /**
  35953. * Current inertia value on the latitudinal axis.
  35954. * The bigger this number the longer it will take for the camera to stop.
  35955. */
  35956. inertialBetaOffset: number;
  35957. /**
  35958. * Current inertia value on the radius axis.
  35959. * The bigger this number the longer it will take for the camera to stop.
  35960. */
  35961. inertialRadiusOffset: number;
  35962. /**
  35963. * Minimum allowed angle on the longitudinal axis.
  35964. * This can help limiting how the Camera is able to move in the scene.
  35965. */
  35966. lowerAlphaLimit: Nullable<number>;
  35967. /**
  35968. * Maximum allowed angle on the longitudinal axis.
  35969. * This can help limiting how the Camera is able to move in the scene.
  35970. */
  35971. upperAlphaLimit: Nullable<number>;
  35972. /**
  35973. * Minimum allowed angle on the latitudinal axis.
  35974. * This can help limiting how the Camera is able to move in the scene.
  35975. */
  35976. lowerBetaLimit: number;
  35977. /**
  35978. * Maximum allowed angle on the latitudinal axis.
  35979. * This can help limiting how the Camera is able to move in the scene.
  35980. */
  35981. upperBetaLimit: number;
  35982. /**
  35983. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  35984. * This can help limiting how the Camera is able to move in the scene.
  35985. */
  35986. lowerRadiusLimit: Nullable<number>;
  35987. /**
  35988. * Maximum allowed distance of the camera to the target (The camera can not get further).
  35989. * This can help limiting how the Camera is able to move in the scene.
  35990. */
  35991. upperRadiusLimit: Nullable<number>;
  35992. /**
  35993. * Defines the current inertia value used during panning of the camera along the X axis.
  35994. */
  35995. inertialPanningX: number;
  35996. /**
  35997. * Defines the current inertia value used during panning of the camera along the Y axis.
  35998. */
  35999. inertialPanningY: number;
  36000. /**
  36001. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  36002. * Basically if your fingers moves away from more than this distance you will be considered
  36003. * in pinch mode.
  36004. */
  36005. pinchToPanMaxDistance: number;
  36006. /**
  36007. * Defines the maximum distance the camera can pan.
  36008. * This could help keeping the cammera always in your scene.
  36009. */
  36010. panningDistanceLimit: Nullable<number>;
  36011. /**
  36012. * Defines the target of the camera before paning.
  36013. */
  36014. panningOriginTarget: Vector3;
  36015. /**
  36016. * Defines the value of the inertia used during panning.
  36017. * 0 would mean stop inertia and one would mean no decelleration at all.
  36018. */
  36019. panningInertia: number;
  36020. /**
  36021. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  36022. */
  36023. angularSensibilityX: number;
  36024. /**
  36025. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  36026. */
  36027. angularSensibilityY: number;
  36028. /**
  36029. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  36030. */
  36031. pinchPrecision: number;
  36032. /**
  36033. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  36034. * It will be used instead of pinchDeltaPrecision if different from 0.
  36035. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36036. */
  36037. pinchDeltaPercentage: number;
  36038. /**
  36039. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  36040. */
  36041. panningSensibility: number;
  36042. /**
  36043. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  36044. */
  36045. keysUp: number[];
  36046. /**
  36047. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  36048. */
  36049. keysDown: number[];
  36050. /**
  36051. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  36052. */
  36053. keysLeft: number[];
  36054. /**
  36055. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  36056. */
  36057. keysRight: number[];
  36058. /**
  36059. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  36060. */
  36061. wheelPrecision: number;
  36062. /**
  36063. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  36064. * It will be used instead of pinchDeltaPrecision if different from 0.
  36065. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  36066. */
  36067. wheelDeltaPercentage: number;
  36068. /**
  36069. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  36070. */
  36071. zoomOnFactor: number;
  36072. /**
  36073. * Defines a screen offset for the camera position.
  36074. */
  36075. targetScreenOffset: Vector2;
  36076. /**
  36077. * Allows the camera to be completely reversed.
  36078. * If false the camera can not arrive upside down.
  36079. */
  36080. allowUpsideDown: boolean;
  36081. /**
  36082. * Define if double tap/click is used to restore the previously saved state of the camera.
  36083. */
  36084. useInputToRestoreState: boolean;
  36085. /** @hidden */
  36086. _viewMatrix: Matrix;
  36087. /** @hidden */
  36088. _useCtrlForPanning: boolean;
  36089. /** @hidden */
  36090. _panningMouseButton: number;
  36091. /**
  36092. * Defines the input associated to the camera.
  36093. */
  36094. inputs: ArcRotateCameraInputsManager;
  36095. /** @hidden */
  36096. _reset: () => void;
  36097. /**
  36098. * Defines the allowed panning axis.
  36099. */
  36100. panningAxis: Vector3;
  36101. protected _localDirection: Vector3;
  36102. protected _transformedDirection: Vector3;
  36103. private _bouncingBehavior;
  36104. /**
  36105. * Gets the bouncing behavior of the camera if it has been enabled.
  36106. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36107. */
  36108. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  36109. /**
  36110. * Defines if the bouncing behavior of the camera is enabled on the camera.
  36111. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  36112. */
  36113. useBouncingBehavior: boolean;
  36114. private _framingBehavior;
  36115. /**
  36116. * Gets the framing behavior of the camera if it has been enabled.
  36117. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36118. */
  36119. readonly framingBehavior: Nullable<FramingBehavior>;
  36120. /**
  36121. * Defines if the framing behavior of the camera is enabled on the camera.
  36122. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  36123. */
  36124. useFramingBehavior: boolean;
  36125. private _autoRotationBehavior;
  36126. /**
  36127. * Gets the auto rotation behavior of the camera if it has been enabled.
  36128. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36129. */
  36130. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  36131. /**
  36132. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  36133. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36134. */
  36135. useAutoRotationBehavior: boolean;
  36136. /**
  36137. * Observable triggered when the mesh target has been changed on the camera.
  36138. */
  36139. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  36140. /**
  36141. * Event raised when the camera is colliding with a mesh.
  36142. */
  36143. onCollide: (collidedMesh: AbstractMesh) => void;
  36144. /**
  36145. * Defines whether the camera should check collision with the objects oh the scene.
  36146. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  36147. */
  36148. checkCollisions: boolean;
  36149. /**
  36150. * Defines the collision radius of the camera.
  36151. * This simulates a sphere around the camera.
  36152. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  36153. */
  36154. collisionRadius: Vector3;
  36155. protected _collider: Collider;
  36156. protected _previousPosition: Vector3;
  36157. protected _collisionVelocity: Vector3;
  36158. protected _newPosition: Vector3;
  36159. protected _previousAlpha: number;
  36160. protected _previousBeta: number;
  36161. protected _previousRadius: number;
  36162. protected _collisionTriggered: boolean;
  36163. protected _targetBoundingCenter: Nullable<Vector3>;
  36164. private _computationVector;
  36165. /**
  36166. * Instantiates a new ArcRotateCamera in a given scene
  36167. * @param name Defines the name of the camera
  36168. * @param alpha Defines the camera rotation along the logitudinal axis
  36169. * @param beta Defines the camera rotation along the latitudinal axis
  36170. * @param radius Defines the camera distance from its target
  36171. * @param target Defines the camera target
  36172. * @param scene Defines the scene the camera belongs to
  36173. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  36174. */
  36175. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  36176. /** @hidden */
  36177. _initCache(): void;
  36178. /** @hidden */
  36179. _updateCache(ignoreParentClass?: boolean): void;
  36180. protected _getTargetPosition(): Vector3;
  36181. private _storedAlpha;
  36182. private _storedBeta;
  36183. private _storedRadius;
  36184. private _storedTarget;
  36185. /**
  36186. * Stores the current state of the camera (alpha, beta, radius and target)
  36187. * @returns the camera itself
  36188. */
  36189. storeState(): Camera;
  36190. /**
  36191. * @hidden
  36192. * Restored camera state. You must call storeState() first
  36193. */
  36194. _restoreStateValues(): boolean;
  36195. /** @hidden */
  36196. _isSynchronizedViewMatrix(): boolean;
  36197. /**
  36198. * Attached controls to the current camera.
  36199. * @param element Defines the element the controls should be listened from
  36200. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  36201. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  36202. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  36203. */
  36204. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  36205. /**
  36206. * Detach the current controls from the camera.
  36207. * The camera will stop reacting to inputs.
  36208. * @param element Defines the element to stop listening the inputs from
  36209. */
  36210. detachControl(element: HTMLElement): void;
  36211. /** @hidden */
  36212. _checkInputs(): void;
  36213. protected _checkLimits(): void;
  36214. /**
  36215. * Rebuilds angles (alpha, beta) and radius from the give position and target
  36216. */
  36217. rebuildAnglesAndRadius(): void;
  36218. /**
  36219. * Use a position to define the current camera related information like aplha, beta and radius
  36220. * @param position Defines the position to set the camera at
  36221. */
  36222. setPosition(position: Vector3): void;
  36223. /**
  36224. * Defines the target the camera should look at.
  36225. * This will automatically adapt alpha beta and radius to fit within the new target.
  36226. * @param target Defines the new target as a Vector or a mesh
  36227. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  36228. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  36229. */
  36230. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  36231. /** @hidden */
  36232. _getViewMatrix(): Matrix;
  36233. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  36234. /**
  36235. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  36236. * @param meshes Defines the mesh to zoom on
  36237. * @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)
  36238. */
  36239. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  36240. /**
  36241. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  36242. * The target will be changed but the radius
  36243. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  36244. * @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)
  36245. */
  36246. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  36247. min: Vector3;
  36248. max: Vector3;
  36249. distance: number;
  36250. }, doNotUpdateMaxZ?: boolean): void;
  36251. /**
  36252. * @override
  36253. * Override Camera.createRigCamera
  36254. */
  36255. createRigCamera(name: string, cameraIndex: number): Camera;
  36256. /**
  36257. * @hidden
  36258. * @override
  36259. * Override Camera._updateRigCameras
  36260. */
  36261. _updateRigCameras(): void;
  36262. /**
  36263. * Destroy the camera and release the current resources hold by it.
  36264. */
  36265. dispose(): void;
  36266. /**
  36267. * Gets the current object class name.
  36268. * @return the class name
  36269. */
  36270. getClassName(): string;
  36271. }
  36272. }
  36273. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  36274. import { Behavior } from "babylonjs/Behaviors/behavior";
  36275. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  36276. /**
  36277. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  36278. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  36279. */
  36280. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  36281. /**
  36282. * Gets the name of the behavior.
  36283. */
  36284. readonly name: string;
  36285. private _zoomStopsAnimation;
  36286. private _idleRotationSpeed;
  36287. private _idleRotationWaitTime;
  36288. private _idleRotationSpinupTime;
  36289. /**
  36290. * Sets the flag that indicates if user zooming should stop animation.
  36291. */
  36292. /**
  36293. * Gets the flag that indicates if user zooming should stop animation.
  36294. */
  36295. zoomStopsAnimation: boolean;
  36296. /**
  36297. * Sets the default speed at which the camera rotates around the model.
  36298. */
  36299. /**
  36300. * Gets the default speed at which the camera rotates around the model.
  36301. */
  36302. idleRotationSpeed: number;
  36303. /**
  36304. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  36305. */
  36306. /**
  36307. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  36308. */
  36309. idleRotationWaitTime: number;
  36310. /**
  36311. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36312. */
  36313. /**
  36314. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  36315. */
  36316. idleRotationSpinupTime: number;
  36317. /**
  36318. * Gets a value indicating if the camera is currently rotating because of this behavior
  36319. */
  36320. readonly rotationInProgress: boolean;
  36321. private _onPrePointerObservableObserver;
  36322. private _onAfterCheckInputsObserver;
  36323. private _attachedCamera;
  36324. private _isPointerDown;
  36325. private _lastFrameTime;
  36326. private _lastInteractionTime;
  36327. private _cameraRotationSpeed;
  36328. /**
  36329. * Initializes the behavior.
  36330. */
  36331. init(): void;
  36332. /**
  36333. * Attaches the behavior to its arc rotate camera.
  36334. * @param camera Defines the camera to attach the behavior to
  36335. */
  36336. attach(camera: ArcRotateCamera): void;
  36337. /**
  36338. * Detaches the behavior from its current arc rotate camera.
  36339. */
  36340. detach(): void;
  36341. /**
  36342. * Returns true if user is scrolling.
  36343. * @return true if user is scrolling.
  36344. */
  36345. private _userIsZooming;
  36346. private _lastFrameRadius;
  36347. private _shouldAnimationStopForInteraction;
  36348. /**
  36349. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  36350. */
  36351. private _applyUserInteraction;
  36352. private _userIsMoving;
  36353. }
  36354. }
  36355. declare module "babylonjs/Behaviors/Cameras/index" {
  36356. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  36357. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  36358. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  36359. }
  36360. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  36361. import { Mesh } from "babylonjs/Meshes/mesh";
  36362. import { TransformNode } from "babylonjs/Meshes/transformNode";
  36363. import { Behavior } from "babylonjs/Behaviors/behavior";
  36364. /**
  36365. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  36366. */
  36367. export class AttachToBoxBehavior implements Behavior<Mesh> {
  36368. private ui;
  36369. /**
  36370. * The name of the behavior
  36371. */
  36372. name: string;
  36373. /**
  36374. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  36375. */
  36376. distanceAwayFromFace: number;
  36377. /**
  36378. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  36379. */
  36380. distanceAwayFromBottomOfFace: number;
  36381. private _faceVectors;
  36382. private _target;
  36383. private _scene;
  36384. private _onRenderObserver;
  36385. private _tmpMatrix;
  36386. private _tmpVector;
  36387. /**
  36388. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  36389. * @param ui The transform node that should be attched to the mesh
  36390. */
  36391. constructor(ui: TransformNode);
  36392. /**
  36393. * Initializes the behavior
  36394. */
  36395. init(): void;
  36396. private _closestFace;
  36397. private _zeroVector;
  36398. private _lookAtTmpMatrix;
  36399. private _lookAtToRef;
  36400. /**
  36401. * Attaches the AttachToBoxBehavior to the passed in mesh
  36402. * @param target The mesh that the specified node will be attached to
  36403. */
  36404. attach(target: Mesh): void;
  36405. /**
  36406. * Detaches the behavior from the mesh
  36407. */
  36408. detach(): void;
  36409. }
  36410. }
  36411. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  36412. import { Behavior } from "babylonjs/Behaviors/behavior";
  36413. import { Mesh } from "babylonjs/Meshes/mesh";
  36414. /**
  36415. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  36416. */
  36417. export class FadeInOutBehavior implements Behavior<Mesh> {
  36418. /**
  36419. * Time in milliseconds to delay before fading in (Default: 0)
  36420. */
  36421. delay: number;
  36422. /**
  36423. * Time in milliseconds for the mesh to fade in (Default: 300)
  36424. */
  36425. fadeInTime: number;
  36426. private _millisecondsPerFrame;
  36427. private _hovered;
  36428. private _hoverValue;
  36429. private _ownerNode;
  36430. /**
  36431. * Instatiates the FadeInOutBehavior
  36432. */
  36433. constructor();
  36434. /**
  36435. * The name of the behavior
  36436. */
  36437. readonly name: string;
  36438. /**
  36439. * Initializes the behavior
  36440. */
  36441. init(): void;
  36442. /**
  36443. * Attaches the fade behavior on the passed in mesh
  36444. * @param ownerNode The mesh that will be faded in/out once attached
  36445. */
  36446. attach(ownerNode: Mesh): void;
  36447. /**
  36448. * Detaches the behavior from the mesh
  36449. */
  36450. detach(): void;
  36451. /**
  36452. * Triggers the mesh to begin fading in or out
  36453. * @param value if the object should fade in or out (true to fade in)
  36454. */
  36455. fadeIn(value: boolean): void;
  36456. private _update;
  36457. private _setAllVisibility;
  36458. }
  36459. }
  36460. declare module "babylonjs/Misc/pivotTools" {
  36461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36462. /**
  36463. * Class containing a set of static utilities functions for managing Pivots
  36464. * @hidden
  36465. */
  36466. export class PivotTools {
  36467. private static _PivotCached;
  36468. private static _OldPivotPoint;
  36469. private static _PivotTranslation;
  36470. private static _PivotTmpVector;
  36471. /** @hidden */
  36472. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  36473. /** @hidden */
  36474. static _RestorePivotPoint(mesh: AbstractMesh): void;
  36475. }
  36476. }
  36477. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  36478. import { Scene } from "babylonjs/scene";
  36479. import { Vector4, Plane } from "babylonjs/Maths/math";
  36480. import { Mesh } from "babylonjs/Meshes/mesh";
  36481. import { Nullable } from "babylonjs/types";
  36482. /**
  36483. * Class containing static functions to help procedurally build meshes
  36484. */
  36485. export class PlaneBuilder {
  36486. /**
  36487. * Creates a plane mesh
  36488. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  36489. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  36490. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  36491. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  36492. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  36493. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  36494. * @param name defines the name of the mesh
  36495. * @param options defines the options used to create the mesh
  36496. * @param scene defines the hosting scene
  36497. * @returns the plane mesh
  36498. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  36499. */
  36500. static CreatePlane(name: string, options: {
  36501. size?: number;
  36502. width?: number;
  36503. height?: number;
  36504. sideOrientation?: number;
  36505. frontUVs?: Vector4;
  36506. backUVs?: Vector4;
  36507. updatable?: boolean;
  36508. sourcePlane?: Plane;
  36509. }, scene?: Nullable<Scene>): Mesh;
  36510. }
  36511. }
  36512. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  36513. import { Behavior } from "babylonjs/Behaviors/behavior";
  36514. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36515. import { Observable } from "babylonjs/Misc/observable";
  36516. import { Vector3 } from "babylonjs/Maths/math";
  36517. import { Ray } from "babylonjs/Culling/ray";
  36518. import "babylonjs/Meshes/Builders/planeBuilder";
  36519. /**
  36520. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  36521. */
  36522. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  36523. private static _AnyMouseID;
  36524. private _attachedNode;
  36525. private _dragPlane;
  36526. private _scene;
  36527. private _pointerObserver;
  36528. private _beforeRenderObserver;
  36529. private static _planeScene;
  36530. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  36531. /**
  36532. * 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)
  36533. */
  36534. maxDragAngle: number;
  36535. /**
  36536. * @hidden
  36537. */
  36538. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  36539. /**
  36540. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36541. */
  36542. currentDraggingPointerID: number;
  36543. /**
  36544. * The last position where the pointer hit the drag plane in world space
  36545. */
  36546. lastDragPosition: Vector3;
  36547. /**
  36548. * If the behavior is currently in a dragging state
  36549. */
  36550. dragging: boolean;
  36551. /**
  36552. * 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)
  36553. */
  36554. dragDeltaRatio: number;
  36555. /**
  36556. * If the drag plane orientation should be updated during the dragging (Default: true)
  36557. */
  36558. updateDragPlane: boolean;
  36559. private _debugMode;
  36560. private _moving;
  36561. /**
  36562. * Fires each time the attached mesh is dragged with the pointer
  36563. * * delta between last drag position and current drag position in world space
  36564. * * dragDistance along the drag axis
  36565. * * dragPlaneNormal normal of the current drag plane used during the drag
  36566. * * dragPlanePoint in world space where the drag intersects the drag plane
  36567. */
  36568. onDragObservable: Observable<{
  36569. delta: Vector3;
  36570. dragPlanePoint: Vector3;
  36571. dragPlaneNormal: Vector3;
  36572. dragDistance: number;
  36573. pointerId: number;
  36574. }>;
  36575. /**
  36576. * Fires each time a drag begins (eg. mouse down on mesh)
  36577. */
  36578. onDragStartObservable: Observable<{
  36579. dragPlanePoint: Vector3;
  36580. pointerId: number;
  36581. }>;
  36582. /**
  36583. * Fires each time a drag ends (eg. mouse release after drag)
  36584. */
  36585. onDragEndObservable: Observable<{
  36586. dragPlanePoint: Vector3;
  36587. pointerId: number;
  36588. }>;
  36589. /**
  36590. * If the attached mesh should be moved when dragged
  36591. */
  36592. moveAttached: boolean;
  36593. /**
  36594. * If the drag behavior will react to drag events (Default: true)
  36595. */
  36596. enabled: boolean;
  36597. /**
  36598. * If camera controls should be detached during the drag
  36599. */
  36600. detachCameraControls: boolean;
  36601. /**
  36602. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  36603. */
  36604. useObjectOrienationForDragging: boolean;
  36605. private _options;
  36606. /**
  36607. * Creates a pointer drag behavior that can be attached to a mesh
  36608. * @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)
  36609. */
  36610. constructor(options?: {
  36611. dragAxis?: Vector3;
  36612. dragPlaneNormal?: Vector3;
  36613. });
  36614. /**
  36615. * Predicate to determine if it is valid to move the object to a new position when it is moved
  36616. */
  36617. validateDrag: (targetPosition: Vector3) => boolean;
  36618. /**
  36619. * The name of the behavior
  36620. */
  36621. readonly name: string;
  36622. /**
  36623. * Initializes the behavior
  36624. */
  36625. init(): void;
  36626. private _tmpVector;
  36627. private _alternatePickedPoint;
  36628. private _worldDragAxis;
  36629. private _targetPosition;
  36630. private _attachedElement;
  36631. /**
  36632. * Attaches the drag behavior the passed in mesh
  36633. * @param ownerNode The mesh that will be dragged around once attached
  36634. */
  36635. attach(ownerNode: AbstractMesh): void;
  36636. /**
  36637. * Force relase the drag action by code.
  36638. */
  36639. releaseDrag(): void;
  36640. private _startDragRay;
  36641. private _lastPointerRay;
  36642. /**
  36643. * Simulates the start of a pointer drag event on the behavior
  36644. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  36645. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  36646. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  36647. */
  36648. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  36649. private _startDrag;
  36650. private _dragDelta;
  36651. private _moveDrag;
  36652. private _pickWithRayOnDragPlane;
  36653. private _pointA;
  36654. private _pointB;
  36655. private _pointC;
  36656. private _lineA;
  36657. private _lineB;
  36658. private _localAxis;
  36659. private _lookAt;
  36660. private _updateDragPlanePosition;
  36661. /**
  36662. * Detaches the behavior from the mesh
  36663. */
  36664. detach(): void;
  36665. }
  36666. }
  36667. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  36668. import { Mesh } from "babylonjs/Meshes/mesh";
  36669. import { Behavior } from "babylonjs/Behaviors/behavior";
  36670. /**
  36671. * A behavior that when attached to a mesh will allow the mesh to be scaled
  36672. */
  36673. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  36674. private _dragBehaviorA;
  36675. private _dragBehaviorB;
  36676. private _startDistance;
  36677. private _initialScale;
  36678. private _targetScale;
  36679. private _ownerNode;
  36680. private _sceneRenderObserver;
  36681. /**
  36682. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  36683. */
  36684. constructor();
  36685. /**
  36686. * The name of the behavior
  36687. */
  36688. readonly name: string;
  36689. /**
  36690. * Initializes the behavior
  36691. */
  36692. init(): void;
  36693. private _getCurrentDistance;
  36694. /**
  36695. * Attaches the scale behavior the passed in mesh
  36696. * @param ownerNode The mesh that will be scaled around once attached
  36697. */
  36698. attach(ownerNode: Mesh): void;
  36699. /**
  36700. * Detaches the behavior from the mesh
  36701. */
  36702. detach(): void;
  36703. }
  36704. }
  36705. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  36706. import { Behavior } from "babylonjs/Behaviors/behavior";
  36707. import { Mesh } from "babylonjs/Meshes/mesh";
  36708. import { Observable } from "babylonjs/Misc/observable";
  36709. /**
  36710. * 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
  36711. */
  36712. export class SixDofDragBehavior implements Behavior<Mesh> {
  36713. private static _virtualScene;
  36714. private _ownerNode;
  36715. private _sceneRenderObserver;
  36716. private _scene;
  36717. private _targetPosition;
  36718. private _virtualOriginMesh;
  36719. private _virtualDragMesh;
  36720. private _pointerObserver;
  36721. private _moving;
  36722. private _startingOrientation;
  36723. /**
  36724. * 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)
  36725. */
  36726. private zDragFactor;
  36727. /**
  36728. * If the object should rotate to face the drag origin
  36729. */
  36730. rotateDraggedObject: boolean;
  36731. /**
  36732. * If the behavior is currently in a dragging state
  36733. */
  36734. dragging: boolean;
  36735. /**
  36736. * 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)
  36737. */
  36738. dragDeltaRatio: number;
  36739. /**
  36740. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  36741. */
  36742. currentDraggingPointerID: number;
  36743. /**
  36744. * If camera controls should be detached during the drag
  36745. */
  36746. detachCameraControls: boolean;
  36747. /**
  36748. * Fires each time a drag starts
  36749. */
  36750. onDragStartObservable: Observable<{}>;
  36751. /**
  36752. * Fires each time a drag ends (eg. mouse release after drag)
  36753. */
  36754. onDragEndObservable: Observable<{}>;
  36755. /**
  36756. * 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
  36757. */
  36758. constructor();
  36759. /**
  36760. * The name of the behavior
  36761. */
  36762. readonly name: string;
  36763. /**
  36764. * Initializes the behavior
  36765. */
  36766. init(): void;
  36767. /**
  36768. * Attaches the scale behavior the passed in mesh
  36769. * @param ownerNode The mesh that will be scaled around once attached
  36770. */
  36771. attach(ownerNode: Mesh): void;
  36772. /**
  36773. * Detaches the behavior from the mesh
  36774. */
  36775. detach(): void;
  36776. }
  36777. }
  36778. declare module "babylonjs/Behaviors/Meshes/index" {
  36779. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  36780. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  36781. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  36782. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  36783. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  36784. }
  36785. declare module "babylonjs/Behaviors/index" {
  36786. export * from "babylonjs/Behaviors/behavior";
  36787. export * from "babylonjs/Behaviors/Cameras/index";
  36788. export * from "babylonjs/Behaviors/Meshes/index";
  36789. }
  36790. declare module "babylonjs/Bones/boneIKController" {
  36791. import { Bone } from "babylonjs/Bones/bone";
  36792. import { Vector3 } from "babylonjs/Maths/math";
  36793. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36794. import { Nullable } from "babylonjs/types";
  36795. /**
  36796. * Class used to apply inverse kinematics to bones
  36797. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  36798. */
  36799. export class BoneIKController {
  36800. private static _tmpVecs;
  36801. private static _tmpQuat;
  36802. private static _tmpMats;
  36803. /**
  36804. * Gets or sets the target mesh
  36805. */
  36806. targetMesh: AbstractMesh;
  36807. /** Gets or sets the mesh used as pole */
  36808. poleTargetMesh: AbstractMesh;
  36809. /**
  36810. * Gets or sets the bone used as pole
  36811. */
  36812. poleTargetBone: Nullable<Bone>;
  36813. /**
  36814. * Gets or sets the target position
  36815. */
  36816. targetPosition: Vector3;
  36817. /**
  36818. * Gets or sets the pole target position
  36819. */
  36820. poleTargetPosition: Vector3;
  36821. /**
  36822. * Gets or sets the pole target local offset
  36823. */
  36824. poleTargetLocalOffset: Vector3;
  36825. /**
  36826. * Gets or sets the pole angle
  36827. */
  36828. poleAngle: number;
  36829. /**
  36830. * Gets or sets the mesh associated with the controller
  36831. */
  36832. mesh: AbstractMesh;
  36833. /**
  36834. * 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)
  36835. */
  36836. slerpAmount: number;
  36837. private _bone1Quat;
  36838. private _bone1Mat;
  36839. private _bone2Ang;
  36840. private _bone1;
  36841. private _bone2;
  36842. private _bone1Length;
  36843. private _bone2Length;
  36844. private _maxAngle;
  36845. private _maxReach;
  36846. private _rightHandedSystem;
  36847. private _bendAxis;
  36848. private _slerping;
  36849. private _adjustRoll;
  36850. /**
  36851. * Gets or sets maximum allowed angle
  36852. */
  36853. maxAngle: number;
  36854. /**
  36855. * Creates a new BoneIKController
  36856. * @param mesh defines the mesh to control
  36857. * @param bone defines the bone to control
  36858. * @param options defines options to set up the controller
  36859. */
  36860. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  36861. targetMesh?: AbstractMesh;
  36862. poleTargetMesh?: AbstractMesh;
  36863. poleTargetBone?: Bone;
  36864. poleTargetLocalOffset?: Vector3;
  36865. poleAngle?: number;
  36866. bendAxis?: Vector3;
  36867. maxAngle?: number;
  36868. slerpAmount?: number;
  36869. });
  36870. private _setMaxAngle;
  36871. /**
  36872. * Force the controller to update the bones
  36873. */
  36874. update(): void;
  36875. }
  36876. }
  36877. declare module "babylonjs/Bones/boneLookController" {
  36878. import { Vector3, Space } from "babylonjs/Maths/math";
  36879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  36880. import { Bone } from "babylonjs/Bones/bone";
  36881. /**
  36882. * Class used to make a bone look toward a point in space
  36883. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  36884. */
  36885. export class BoneLookController {
  36886. private static _tmpVecs;
  36887. private static _tmpQuat;
  36888. private static _tmpMats;
  36889. /**
  36890. * The target Vector3 that the bone will look at
  36891. */
  36892. target: Vector3;
  36893. /**
  36894. * The mesh that the bone is attached to
  36895. */
  36896. mesh: AbstractMesh;
  36897. /**
  36898. * The bone that will be looking to the target
  36899. */
  36900. bone: Bone;
  36901. /**
  36902. * The up axis of the coordinate system that is used when the bone is rotated
  36903. */
  36904. upAxis: Vector3;
  36905. /**
  36906. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  36907. */
  36908. upAxisSpace: Space;
  36909. /**
  36910. * Used to make an adjustment to the yaw of the bone
  36911. */
  36912. adjustYaw: number;
  36913. /**
  36914. * Used to make an adjustment to the pitch of the bone
  36915. */
  36916. adjustPitch: number;
  36917. /**
  36918. * Used to make an adjustment to the roll of the bone
  36919. */
  36920. adjustRoll: number;
  36921. /**
  36922. * 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)
  36923. */
  36924. slerpAmount: number;
  36925. private _minYaw;
  36926. private _maxYaw;
  36927. private _minPitch;
  36928. private _maxPitch;
  36929. private _minYawSin;
  36930. private _minYawCos;
  36931. private _maxYawSin;
  36932. private _maxYawCos;
  36933. private _midYawConstraint;
  36934. private _minPitchTan;
  36935. private _maxPitchTan;
  36936. private _boneQuat;
  36937. private _slerping;
  36938. private _transformYawPitch;
  36939. private _transformYawPitchInv;
  36940. private _firstFrameSkipped;
  36941. private _yawRange;
  36942. private _fowardAxis;
  36943. /**
  36944. * Gets or sets the minimum yaw angle that the bone can look to
  36945. */
  36946. minYaw: number;
  36947. /**
  36948. * Gets or sets the maximum yaw angle that the bone can look to
  36949. */
  36950. maxYaw: number;
  36951. /**
  36952. * Gets or sets the minimum pitch angle that the bone can look to
  36953. */
  36954. minPitch: number;
  36955. /**
  36956. * Gets or sets the maximum pitch angle that the bone can look to
  36957. */
  36958. maxPitch: number;
  36959. /**
  36960. * Create a BoneLookController
  36961. * @param mesh the mesh that the bone belongs to
  36962. * @param bone the bone that will be looking to the target
  36963. * @param target the target Vector3 to look at
  36964. * @param options optional settings:
  36965. * * maxYaw: the maximum angle the bone will yaw to
  36966. * * minYaw: the minimum angle the bone will yaw to
  36967. * * maxPitch: the maximum angle the bone will pitch to
  36968. * * minPitch: the minimum angle the bone will yaw to
  36969. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  36970. * * upAxis: the up axis of the coordinate system
  36971. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  36972. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  36973. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  36974. * * adjustYaw: used to make an adjustment to the yaw of the bone
  36975. * * adjustPitch: used to make an adjustment to the pitch of the bone
  36976. * * adjustRoll: used to make an adjustment to the roll of the bone
  36977. **/
  36978. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  36979. maxYaw?: number;
  36980. minYaw?: number;
  36981. maxPitch?: number;
  36982. minPitch?: number;
  36983. slerpAmount?: number;
  36984. upAxis?: Vector3;
  36985. upAxisSpace?: Space;
  36986. yawAxis?: Vector3;
  36987. pitchAxis?: Vector3;
  36988. adjustYaw?: number;
  36989. adjustPitch?: number;
  36990. adjustRoll?: number;
  36991. });
  36992. /**
  36993. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  36994. */
  36995. update(): void;
  36996. private _getAngleDiff;
  36997. private _getAngleBetween;
  36998. private _isAngleBetween;
  36999. }
  37000. }
  37001. declare module "babylonjs/Bones/index" {
  37002. export * from "babylonjs/Bones/bone";
  37003. export * from "babylonjs/Bones/boneIKController";
  37004. export * from "babylonjs/Bones/boneLookController";
  37005. export * from "babylonjs/Bones/skeleton";
  37006. }
  37007. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  37008. import { Nullable } from "babylonjs/types";
  37009. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37010. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37011. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  37012. /**
  37013. * Manage the gamepad inputs to control an arc rotate camera.
  37014. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37015. */
  37016. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  37017. /**
  37018. * Defines the camera the input is attached to.
  37019. */
  37020. camera: ArcRotateCamera;
  37021. /**
  37022. * Defines the gamepad the input is gathering event from.
  37023. */
  37024. gamepad: Nullable<Gamepad>;
  37025. /**
  37026. * Defines the gamepad rotation sensiblity.
  37027. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  37028. */
  37029. gamepadRotationSensibility: number;
  37030. /**
  37031. * Defines the gamepad move sensiblity.
  37032. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  37033. */
  37034. gamepadMoveSensibility: number;
  37035. private _onGamepadConnectedObserver;
  37036. private _onGamepadDisconnectedObserver;
  37037. /**
  37038. * Attach the input controls to a specific dom element to get the input from.
  37039. * @param element Defines the element the controls should be listened from
  37040. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37041. */
  37042. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37043. /**
  37044. * Detach the current controls from the specified dom element.
  37045. * @param element Defines the element to stop listening the inputs from
  37046. */
  37047. detachControl(element: Nullable<HTMLElement>): void;
  37048. /**
  37049. * Update the current camera state depending on the inputs that have been used this frame.
  37050. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37051. */
  37052. checkInputs(): void;
  37053. /**
  37054. * Gets the class name of the current intput.
  37055. * @returns the class name
  37056. */
  37057. getClassName(): string;
  37058. /**
  37059. * Get the friendly name associated with the input class.
  37060. * @returns the input friendly name
  37061. */
  37062. getSimpleName(): string;
  37063. }
  37064. }
  37065. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  37066. import { Nullable } from "babylonjs/types";
  37067. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  37068. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37069. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  37070. interface ArcRotateCameraInputsManager {
  37071. /**
  37072. * Add orientation input support to the input manager.
  37073. * @returns the current input manager
  37074. */
  37075. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  37076. }
  37077. }
  37078. /**
  37079. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  37080. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37081. */
  37082. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  37083. /**
  37084. * Defines the camera the input is attached to.
  37085. */
  37086. camera: ArcRotateCamera;
  37087. /**
  37088. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  37089. */
  37090. alphaCorrection: number;
  37091. /**
  37092. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  37093. */
  37094. gammaCorrection: number;
  37095. private _alpha;
  37096. private _gamma;
  37097. private _dirty;
  37098. private _deviceOrientationHandler;
  37099. /**
  37100. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  37101. */
  37102. constructor();
  37103. /**
  37104. * Attach the input controls to a specific dom element to get the input from.
  37105. * @param element Defines the element the controls should be listened from
  37106. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37107. */
  37108. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37109. /** @hidden */
  37110. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  37111. /**
  37112. * Update the current camera state depending on the inputs that have been used this frame.
  37113. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37114. */
  37115. checkInputs(): void;
  37116. /**
  37117. * Detach the current controls from the specified dom element.
  37118. * @param element Defines the element to stop listening the inputs from
  37119. */
  37120. detachControl(element: Nullable<HTMLElement>): void;
  37121. /**
  37122. * Gets the class name of the current intput.
  37123. * @returns the class name
  37124. */
  37125. getClassName(): string;
  37126. /**
  37127. * Get the friendly name associated with the input class.
  37128. * @returns the input friendly name
  37129. */
  37130. getSimpleName(): string;
  37131. }
  37132. }
  37133. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  37134. import { Nullable } from "babylonjs/types";
  37135. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37136. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37137. /**
  37138. * Listen to mouse events to control the camera.
  37139. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37140. */
  37141. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  37142. /**
  37143. * Defines the camera the input is attached to.
  37144. */
  37145. camera: FlyCamera;
  37146. /**
  37147. * Defines if touch is enabled. (Default is true.)
  37148. */
  37149. touchEnabled: boolean;
  37150. /**
  37151. * Defines the buttons associated with the input to handle camera rotation.
  37152. */
  37153. buttons: number[];
  37154. /**
  37155. * Assign buttons for Yaw control.
  37156. */
  37157. buttonsYaw: number[];
  37158. /**
  37159. * Assign buttons for Pitch control.
  37160. */
  37161. buttonsPitch: number[];
  37162. /**
  37163. * Assign buttons for Roll control.
  37164. */
  37165. buttonsRoll: number[];
  37166. /**
  37167. * Detect if any button is being pressed while mouse is moved.
  37168. * -1 = Mouse locked.
  37169. * 0 = Left button.
  37170. * 1 = Middle Button.
  37171. * 2 = Right Button.
  37172. */
  37173. activeButton: number;
  37174. /**
  37175. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  37176. * Higher values reduce its sensitivity.
  37177. */
  37178. angularSensibility: number;
  37179. private _mousemoveCallback;
  37180. private _observer;
  37181. private _rollObserver;
  37182. private previousPosition;
  37183. private noPreventDefault;
  37184. private element;
  37185. /**
  37186. * Listen to mouse events to control the camera.
  37187. * @param touchEnabled Define if touch is enabled. (Default is true.)
  37188. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37189. */
  37190. constructor(touchEnabled?: boolean);
  37191. /**
  37192. * Attach the mouse control to the HTML DOM element.
  37193. * @param element Defines the element that listens to the input events.
  37194. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  37195. */
  37196. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37197. /**
  37198. * Detach the current controls from the specified dom element.
  37199. * @param element Defines the element to stop listening the inputs from
  37200. */
  37201. detachControl(element: Nullable<HTMLElement>): void;
  37202. /**
  37203. * Gets the class name of the current input.
  37204. * @returns the class name.
  37205. */
  37206. getClassName(): string;
  37207. /**
  37208. * Get the friendly name associated with the input class.
  37209. * @returns the input's friendly name.
  37210. */
  37211. getSimpleName(): string;
  37212. private _pointerInput;
  37213. private _onMouseMove;
  37214. /**
  37215. * Rotate camera by mouse offset.
  37216. */
  37217. private rotateCamera;
  37218. }
  37219. }
  37220. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  37221. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37222. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37223. /**
  37224. * Default Inputs manager for the FlyCamera.
  37225. * It groups all the default supported inputs for ease of use.
  37226. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37227. */
  37228. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  37229. /**
  37230. * Instantiates a new FlyCameraInputsManager.
  37231. * @param camera Defines the camera the inputs belong to.
  37232. */
  37233. constructor(camera: FlyCamera);
  37234. /**
  37235. * Add keyboard input support to the input manager.
  37236. * @returns the new FlyCameraKeyboardMoveInput().
  37237. */
  37238. addKeyboard(): FlyCameraInputsManager;
  37239. /**
  37240. * Add mouse input support to the input manager.
  37241. * @param touchEnabled Enable touch screen support.
  37242. * @returns the new FlyCameraMouseInput().
  37243. */
  37244. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  37245. }
  37246. }
  37247. declare module "babylonjs/Cameras/flyCamera" {
  37248. import { Scene } from "babylonjs/scene";
  37249. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  37250. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37251. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37252. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  37253. /**
  37254. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37255. * such as in a 3D Space Shooter or a Flight Simulator.
  37256. */
  37257. export class FlyCamera extends TargetCamera {
  37258. /**
  37259. * Define the collision ellipsoid of the camera.
  37260. * This is helpful for simulating a camera body, like a player's body.
  37261. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  37262. */
  37263. ellipsoid: Vector3;
  37264. /**
  37265. * Define an offset for the position of the ellipsoid around the camera.
  37266. * This can be helpful if the camera is attached away from the player's body center,
  37267. * such as at its head.
  37268. */
  37269. ellipsoidOffset: Vector3;
  37270. /**
  37271. * Enable or disable collisions of the camera with the rest of the scene objects.
  37272. */
  37273. checkCollisions: boolean;
  37274. /**
  37275. * Enable or disable gravity on the camera.
  37276. */
  37277. applyGravity: boolean;
  37278. /**
  37279. * Define the current direction the camera is moving to.
  37280. */
  37281. cameraDirection: Vector3;
  37282. /**
  37283. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  37284. * This overrides and empties cameraRotation.
  37285. */
  37286. rotationQuaternion: Quaternion;
  37287. /**
  37288. * Track Roll to maintain the wanted Rolling when looking around.
  37289. */
  37290. _trackRoll: number;
  37291. /**
  37292. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  37293. */
  37294. rollCorrect: number;
  37295. /**
  37296. * Mimic a banked turn, Rolling the camera when Yawing.
  37297. * It's recommended to use rollCorrect = 10 for faster banking correction.
  37298. */
  37299. bankedTurn: boolean;
  37300. /**
  37301. * Limit in radians for how much Roll banking will add. (Default: 90°)
  37302. */
  37303. bankedTurnLimit: number;
  37304. /**
  37305. * Value of 0 disables the banked Roll.
  37306. * Value of 1 is equal to the Yaw angle in radians.
  37307. */
  37308. bankedTurnMultiplier: number;
  37309. /**
  37310. * The inputs manager loads all the input sources, such as keyboard and mouse.
  37311. */
  37312. inputs: FlyCameraInputsManager;
  37313. /**
  37314. * Gets the input sensibility for mouse input.
  37315. * Higher values reduce sensitivity.
  37316. */
  37317. /**
  37318. * Sets the input sensibility for a mouse input.
  37319. * Higher values reduce sensitivity.
  37320. */
  37321. angularSensibility: number;
  37322. /**
  37323. * Get the keys for camera movement forward.
  37324. */
  37325. /**
  37326. * Set the keys for camera movement forward.
  37327. */
  37328. keysForward: number[];
  37329. /**
  37330. * Get the keys for camera movement backward.
  37331. */
  37332. keysBackward: number[];
  37333. /**
  37334. * Get the keys for camera movement up.
  37335. */
  37336. /**
  37337. * Set the keys for camera movement up.
  37338. */
  37339. keysUp: number[];
  37340. /**
  37341. * Get the keys for camera movement down.
  37342. */
  37343. /**
  37344. * Set the keys for camera movement down.
  37345. */
  37346. keysDown: number[];
  37347. /**
  37348. * Get the keys for camera movement left.
  37349. */
  37350. /**
  37351. * Set the keys for camera movement left.
  37352. */
  37353. keysLeft: number[];
  37354. /**
  37355. * Set the keys for camera movement right.
  37356. */
  37357. /**
  37358. * Set the keys for camera movement right.
  37359. */
  37360. keysRight: number[];
  37361. /**
  37362. * Event raised when the camera collides with a mesh in the scene.
  37363. */
  37364. onCollide: (collidedMesh: AbstractMesh) => void;
  37365. private _collider;
  37366. private _needMoveForGravity;
  37367. private _oldPosition;
  37368. private _diffPosition;
  37369. private _newPosition;
  37370. /** @hidden */
  37371. _localDirection: Vector3;
  37372. /** @hidden */
  37373. _transformedDirection: Vector3;
  37374. /**
  37375. * Instantiates a FlyCamera.
  37376. * This is a flying camera, designed for 3D movement and rotation in all directions,
  37377. * such as in a 3D Space Shooter or a Flight Simulator.
  37378. * @param name Define the name of the camera in the scene.
  37379. * @param position Define the starting position of the camera in the scene.
  37380. * @param scene Define the scene the camera belongs to.
  37381. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  37382. */
  37383. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  37384. /**
  37385. * Attach a control to the HTML DOM element.
  37386. * @param element Defines the element that listens to the input events.
  37387. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  37388. */
  37389. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37390. /**
  37391. * Detach a control from the HTML DOM element.
  37392. * The camera will stop reacting to that input.
  37393. * @param element Defines the element that listens to the input events.
  37394. */
  37395. detachControl(element: HTMLElement): void;
  37396. private _collisionMask;
  37397. /**
  37398. * Get the mask that the camera ignores in collision events.
  37399. */
  37400. /**
  37401. * Set the mask that the camera ignores in collision events.
  37402. */
  37403. collisionMask: number;
  37404. /** @hidden */
  37405. _collideWithWorld(displacement: Vector3): void;
  37406. /** @hidden */
  37407. private _onCollisionPositionChange;
  37408. /** @hidden */
  37409. _checkInputs(): void;
  37410. /** @hidden */
  37411. _decideIfNeedsToMove(): boolean;
  37412. /** @hidden */
  37413. _updatePosition(): void;
  37414. /**
  37415. * Restore the Roll to its target value at the rate specified.
  37416. * @param rate - Higher means slower restoring.
  37417. * @hidden
  37418. */
  37419. restoreRoll(rate: number): void;
  37420. /**
  37421. * Destroy the camera and release the current resources held by it.
  37422. */
  37423. dispose(): void;
  37424. /**
  37425. * Get the current object class name.
  37426. * @returns the class name.
  37427. */
  37428. getClassName(): string;
  37429. }
  37430. }
  37431. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  37432. import { Nullable } from "babylonjs/types";
  37433. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37434. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  37435. /**
  37436. * Listen to keyboard events to control the camera.
  37437. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37438. */
  37439. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  37440. /**
  37441. * Defines the camera the input is attached to.
  37442. */
  37443. camera: FlyCamera;
  37444. /**
  37445. * The list of keyboard keys used to control the forward move of the camera.
  37446. */
  37447. keysForward: number[];
  37448. /**
  37449. * The list of keyboard keys used to control the backward move of the camera.
  37450. */
  37451. keysBackward: number[];
  37452. /**
  37453. * The list of keyboard keys used to control the forward move of the camera.
  37454. */
  37455. keysUp: number[];
  37456. /**
  37457. * The list of keyboard keys used to control the backward move of the camera.
  37458. */
  37459. keysDown: number[];
  37460. /**
  37461. * The list of keyboard keys used to control the right strafe move of the camera.
  37462. */
  37463. keysRight: number[];
  37464. /**
  37465. * The list of keyboard keys used to control the left strafe move of the camera.
  37466. */
  37467. keysLeft: number[];
  37468. private _keys;
  37469. private _onCanvasBlurObserver;
  37470. private _onKeyboardObserver;
  37471. private _engine;
  37472. private _scene;
  37473. /**
  37474. * Attach the input controls to a specific dom element to get the input from.
  37475. * @param element Defines the element the controls should be listened from
  37476. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37477. */
  37478. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37479. /**
  37480. * Detach the current controls from the specified dom element.
  37481. * @param element Defines the element to stop listening the inputs from
  37482. */
  37483. detachControl(element: Nullable<HTMLElement>): void;
  37484. /**
  37485. * Gets the class name of the current intput.
  37486. * @returns the class name
  37487. */
  37488. getClassName(): string;
  37489. /** @hidden */
  37490. _onLostFocus(e: FocusEvent): void;
  37491. /**
  37492. * Get the friendly name associated with the input class.
  37493. * @returns the input friendly name
  37494. */
  37495. getSimpleName(): string;
  37496. /**
  37497. * Update the current camera state depending on the inputs that have been used this frame.
  37498. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37499. */
  37500. checkInputs(): void;
  37501. }
  37502. }
  37503. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  37504. import { Nullable } from "babylonjs/types";
  37505. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37506. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37507. /**
  37508. * Manage the mouse wheel inputs to control a follow camera.
  37509. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37510. */
  37511. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  37512. /**
  37513. * Defines the camera the input is attached to.
  37514. */
  37515. camera: FollowCamera;
  37516. /**
  37517. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  37518. */
  37519. axisControlRadius: boolean;
  37520. /**
  37521. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  37522. */
  37523. axisControlHeight: boolean;
  37524. /**
  37525. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  37526. */
  37527. axisControlRotation: boolean;
  37528. /**
  37529. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  37530. * relation to mouseWheel events.
  37531. */
  37532. wheelPrecision: number;
  37533. /**
  37534. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  37535. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  37536. */
  37537. wheelDeltaPercentage: number;
  37538. private _wheel;
  37539. private _observer;
  37540. /**
  37541. * Attach the input controls to a specific dom element to get the input from.
  37542. * @param element Defines the element the controls should be listened from
  37543. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37544. */
  37545. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37546. /**
  37547. * Detach the current controls from the specified dom element.
  37548. * @param element Defines the element to stop listening the inputs from
  37549. */
  37550. detachControl(element: Nullable<HTMLElement>): void;
  37551. /**
  37552. * Gets the class name of the current intput.
  37553. * @returns the class name
  37554. */
  37555. getClassName(): string;
  37556. /**
  37557. * Get the friendly name associated with the input class.
  37558. * @returns the input friendly name
  37559. */
  37560. getSimpleName(): string;
  37561. }
  37562. }
  37563. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  37564. import { Nullable } from "babylonjs/types";
  37565. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37566. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  37567. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  37568. /**
  37569. * Manage the pointers inputs to control an follow camera.
  37570. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37571. */
  37572. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  37573. /**
  37574. * Defines the camera the input is attached to.
  37575. */
  37576. camera: FollowCamera;
  37577. /**
  37578. * Gets the class name of the current input.
  37579. * @returns the class name
  37580. */
  37581. getClassName(): string;
  37582. /**
  37583. * Defines the pointer angular sensibility along the X axis or how fast is
  37584. * the camera rotating.
  37585. * A negative number will reverse the axis direction.
  37586. */
  37587. angularSensibilityX: number;
  37588. /**
  37589. * Defines the pointer angular sensibility along the Y axis or how fast is
  37590. * the camera rotating.
  37591. * A negative number will reverse the axis direction.
  37592. */
  37593. angularSensibilityY: number;
  37594. /**
  37595. * Defines the pointer pinch precision or how fast is the camera zooming.
  37596. * A negative number will reverse the axis direction.
  37597. */
  37598. pinchPrecision: number;
  37599. /**
  37600. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  37601. * from 0.
  37602. * It defines the percentage of current camera.radius to use as delta when
  37603. * pinch zoom is used.
  37604. */
  37605. pinchDeltaPercentage: number;
  37606. /**
  37607. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  37608. */
  37609. axisXControlRadius: boolean;
  37610. /**
  37611. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  37612. */
  37613. axisXControlHeight: boolean;
  37614. /**
  37615. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  37616. */
  37617. axisXControlRotation: boolean;
  37618. /**
  37619. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  37620. */
  37621. axisYControlRadius: boolean;
  37622. /**
  37623. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  37624. */
  37625. axisYControlHeight: boolean;
  37626. /**
  37627. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  37628. */
  37629. axisYControlRotation: boolean;
  37630. /**
  37631. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  37632. */
  37633. axisPinchControlRadius: boolean;
  37634. /**
  37635. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  37636. */
  37637. axisPinchControlHeight: boolean;
  37638. /**
  37639. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  37640. */
  37641. axisPinchControlRotation: boolean;
  37642. /**
  37643. * Log error messages if basic misconfiguration has occurred.
  37644. */
  37645. warningEnable: boolean;
  37646. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  37647. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  37648. private _warningCounter;
  37649. private _warning;
  37650. }
  37651. }
  37652. declare module "babylonjs/Cameras/followCameraInputsManager" {
  37653. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  37654. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37655. /**
  37656. * Default Inputs manager for the FollowCamera.
  37657. * It groups all the default supported inputs for ease of use.
  37658. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37659. */
  37660. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  37661. /**
  37662. * Instantiates a new FollowCameraInputsManager.
  37663. * @param camera Defines the camera the inputs belong to
  37664. */
  37665. constructor(camera: FollowCamera);
  37666. /**
  37667. * Add keyboard input support to the input manager.
  37668. * @returns the current input manager
  37669. */
  37670. addKeyboard(): FollowCameraInputsManager;
  37671. /**
  37672. * Add mouse wheel input support to the input manager.
  37673. * @returns the current input manager
  37674. */
  37675. addMouseWheel(): FollowCameraInputsManager;
  37676. /**
  37677. * Add pointers input support to the input manager.
  37678. * @returns the current input manager
  37679. */
  37680. addPointers(): FollowCameraInputsManager;
  37681. /**
  37682. * Add orientation input support to the input manager.
  37683. * @returns the current input manager
  37684. */
  37685. addVRDeviceOrientation(): FollowCameraInputsManager;
  37686. }
  37687. }
  37688. declare module "babylonjs/Cameras/followCamera" {
  37689. import { Nullable } from "babylonjs/types";
  37690. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  37691. import { Scene } from "babylonjs/scene";
  37692. import { Vector3 } from "babylonjs/Maths/math";
  37693. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  37694. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  37695. /**
  37696. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  37697. * an arc rotate version arcFollowCamera are available.
  37698. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37699. */
  37700. export class FollowCamera extends TargetCamera {
  37701. /**
  37702. * Distance the follow camera should follow an object at
  37703. */
  37704. radius: number;
  37705. /**
  37706. * Minimum allowed distance of the camera to the axis of rotation
  37707. * (The camera can not get closer).
  37708. * This can help limiting how the Camera is able to move in the scene.
  37709. */
  37710. lowerRadiusLimit: Nullable<number>;
  37711. /**
  37712. * Maximum allowed distance of the camera to the axis of rotation
  37713. * (The camera can not get further).
  37714. * This can help limiting how the Camera is able to move in the scene.
  37715. */
  37716. upperRadiusLimit: Nullable<number>;
  37717. /**
  37718. * Define a rotation offset between the camera and the object it follows
  37719. */
  37720. rotationOffset: number;
  37721. /**
  37722. * Minimum allowed angle to camera position relative to target object.
  37723. * This can help limiting how the Camera is able to move in the scene.
  37724. */
  37725. lowerRotationOffsetLimit: Nullable<number>;
  37726. /**
  37727. * Maximum allowed angle to camera position relative to target object.
  37728. * This can help limiting how the Camera is able to move in the scene.
  37729. */
  37730. upperRotationOffsetLimit: Nullable<number>;
  37731. /**
  37732. * Define a height offset between the camera and the object it follows.
  37733. * It can help following an object from the top (like a car chaing a plane)
  37734. */
  37735. heightOffset: number;
  37736. /**
  37737. * Minimum allowed height of camera position relative to target object.
  37738. * This can help limiting how the Camera is able to move in the scene.
  37739. */
  37740. lowerHeightOffsetLimit: Nullable<number>;
  37741. /**
  37742. * Maximum allowed height of camera position relative to target object.
  37743. * This can help limiting how the Camera is able to move in the scene.
  37744. */
  37745. upperHeightOffsetLimit: Nullable<number>;
  37746. /**
  37747. * Define how fast the camera can accelerate to follow it s target.
  37748. */
  37749. cameraAcceleration: number;
  37750. /**
  37751. * Define the speed limit of the camera following an object.
  37752. */
  37753. maxCameraSpeed: number;
  37754. /**
  37755. * Define the target of the camera.
  37756. */
  37757. lockedTarget: Nullable<AbstractMesh>;
  37758. /**
  37759. * Defines the input associated with the camera.
  37760. */
  37761. inputs: FollowCameraInputsManager;
  37762. /**
  37763. * Instantiates the follow camera.
  37764. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37765. * @param name Define the name of the camera in the scene
  37766. * @param position Define the position of the camera
  37767. * @param scene Define the scene the camera belong to
  37768. * @param lockedTarget Define the target of the camera
  37769. */
  37770. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  37771. private _follow;
  37772. /**
  37773. * Attached controls to the current camera.
  37774. * @param element Defines the element the controls should be listened from
  37775. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37776. */
  37777. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37778. /**
  37779. * Detach the current controls from the camera.
  37780. * The camera will stop reacting to inputs.
  37781. * @param element Defines the element to stop listening the inputs from
  37782. */
  37783. detachControl(element: HTMLElement): void;
  37784. /** @hidden */
  37785. _checkInputs(): void;
  37786. private _checkLimits;
  37787. /**
  37788. * Gets the camera class name.
  37789. * @returns the class name
  37790. */
  37791. getClassName(): string;
  37792. }
  37793. /**
  37794. * Arc Rotate version of the follow camera.
  37795. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  37796. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37797. */
  37798. export class ArcFollowCamera extends TargetCamera {
  37799. /** The longitudinal angle of the camera */
  37800. alpha: number;
  37801. /** The latitudinal angle of the camera */
  37802. beta: number;
  37803. /** The radius of the camera from its target */
  37804. radius: number;
  37805. /** Define the camera target (the messh it should follow) */
  37806. target: Nullable<AbstractMesh>;
  37807. private _cartesianCoordinates;
  37808. /**
  37809. * Instantiates a new ArcFollowCamera
  37810. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  37811. * @param name Define the name of the camera
  37812. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  37813. * @param beta Define the rotation angle of the camera around the elevation axis
  37814. * @param radius Define the radius of the camera from its target point
  37815. * @param target Define the target of the camera
  37816. * @param scene Define the scene the camera belongs to
  37817. */
  37818. constructor(name: string,
  37819. /** The longitudinal angle of the camera */
  37820. alpha: number,
  37821. /** The latitudinal angle of the camera */
  37822. beta: number,
  37823. /** The radius of the camera from its target */
  37824. radius: number,
  37825. /** Define the camera target (the messh it should follow) */
  37826. target: Nullable<AbstractMesh>, scene: Scene);
  37827. private _follow;
  37828. /** @hidden */
  37829. _checkInputs(): void;
  37830. /**
  37831. * Returns the class name of the object.
  37832. * It is mostly used internally for serialization purposes.
  37833. */
  37834. getClassName(): string;
  37835. }
  37836. }
  37837. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  37838. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37839. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  37840. import { Nullable } from "babylonjs/types";
  37841. /**
  37842. * Manage the keyboard inputs to control the movement of a follow camera.
  37843. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37844. */
  37845. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  37846. /**
  37847. * Defines the camera the input is attached to.
  37848. */
  37849. camera: FollowCamera;
  37850. /**
  37851. * Defines the list of key codes associated with the up action (increase heightOffset)
  37852. */
  37853. keysHeightOffsetIncr: number[];
  37854. /**
  37855. * Defines the list of key codes associated with the down action (decrease heightOffset)
  37856. */
  37857. keysHeightOffsetDecr: number[];
  37858. /**
  37859. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  37860. */
  37861. keysHeightOffsetModifierAlt: boolean;
  37862. /**
  37863. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  37864. */
  37865. keysHeightOffsetModifierCtrl: boolean;
  37866. /**
  37867. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  37868. */
  37869. keysHeightOffsetModifierShift: boolean;
  37870. /**
  37871. * Defines the list of key codes associated with the left action (increase rotationOffset)
  37872. */
  37873. keysRotationOffsetIncr: number[];
  37874. /**
  37875. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  37876. */
  37877. keysRotationOffsetDecr: number[];
  37878. /**
  37879. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  37880. */
  37881. keysRotationOffsetModifierAlt: boolean;
  37882. /**
  37883. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  37884. */
  37885. keysRotationOffsetModifierCtrl: boolean;
  37886. /**
  37887. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  37888. */
  37889. keysRotationOffsetModifierShift: boolean;
  37890. /**
  37891. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  37892. */
  37893. keysRadiusIncr: number[];
  37894. /**
  37895. * Defines the list of key codes associated with the zoom-out action (increase radius)
  37896. */
  37897. keysRadiusDecr: number[];
  37898. /**
  37899. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  37900. */
  37901. keysRadiusModifierAlt: boolean;
  37902. /**
  37903. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  37904. */
  37905. keysRadiusModifierCtrl: boolean;
  37906. /**
  37907. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  37908. */
  37909. keysRadiusModifierShift: boolean;
  37910. /**
  37911. * Defines the rate of change of heightOffset.
  37912. */
  37913. heightSensibility: number;
  37914. /**
  37915. * Defines the rate of change of rotationOffset.
  37916. */
  37917. rotationSensibility: number;
  37918. /**
  37919. * Defines the rate of change of radius.
  37920. */
  37921. radiusSensibility: number;
  37922. private _keys;
  37923. private _ctrlPressed;
  37924. private _altPressed;
  37925. private _shiftPressed;
  37926. private _onCanvasBlurObserver;
  37927. private _onKeyboardObserver;
  37928. private _engine;
  37929. private _scene;
  37930. /**
  37931. * Attach the input controls to a specific dom element to get the input from.
  37932. * @param element Defines the element the controls should be listened from
  37933. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  37934. */
  37935. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  37936. /**
  37937. * Detach the current controls from the specified dom element.
  37938. * @param element Defines the element to stop listening the inputs from
  37939. */
  37940. detachControl(element: Nullable<HTMLElement>): void;
  37941. /**
  37942. * Update the current camera state depending on the inputs that have been used this frame.
  37943. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  37944. */
  37945. checkInputs(): void;
  37946. /**
  37947. * Gets the class name of the current input.
  37948. * @returns the class name
  37949. */
  37950. getClassName(): string;
  37951. /**
  37952. * Get the friendly name associated with the input class.
  37953. * @returns the input friendly name
  37954. */
  37955. getSimpleName(): string;
  37956. /**
  37957. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37958. * allow modification of the heightOffset value.
  37959. */
  37960. private _modifierHeightOffset;
  37961. /**
  37962. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37963. * allow modification of the rotationOffset value.
  37964. */
  37965. private _modifierRotationOffset;
  37966. /**
  37967. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  37968. * allow modification of the radius value.
  37969. */
  37970. private _modifierRadius;
  37971. }
  37972. }
  37973. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  37974. import { Nullable } from "babylonjs/types";
  37975. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  37976. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  37977. import { Observable } from "babylonjs/Misc/observable";
  37978. module "babylonjs/Cameras/freeCameraInputsManager" {
  37979. interface FreeCameraInputsManager {
  37980. /**
  37981. * @hidden
  37982. */
  37983. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  37984. /**
  37985. * Add orientation input support to the input manager.
  37986. * @returns the current input manager
  37987. */
  37988. addDeviceOrientation(): FreeCameraInputsManager;
  37989. }
  37990. }
  37991. /**
  37992. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  37993. * Screen rotation is taken into account.
  37994. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  37995. */
  37996. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  37997. private _camera;
  37998. private _screenOrientationAngle;
  37999. private _constantTranform;
  38000. private _screenQuaternion;
  38001. private _alpha;
  38002. private _beta;
  38003. private _gamma;
  38004. /**
  38005. * @hidden
  38006. */
  38007. _onDeviceOrientationChangedObservable: Observable<void>;
  38008. /**
  38009. * Instantiates a new input
  38010. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38011. */
  38012. constructor();
  38013. /**
  38014. * Define the camera controlled by the input.
  38015. */
  38016. camera: FreeCamera;
  38017. /**
  38018. * Attach the input controls to a specific dom element to get the input from.
  38019. * @param element Defines the element the controls should be listened from
  38020. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38021. */
  38022. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38023. private _orientationChanged;
  38024. private _deviceOrientation;
  38025. /**
  38026. * Detach the current controls from the specified dom element.
  38027. * @param element Defines the element to stop listening the inputs from
  38028. */
  38029. detachControl(element: Nullable<HTMLElement>): void;
  38030. /**
  38031. * Update the current camera state depending on the inputs that have been used this frame.
  38032. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38033. */
  38034. checkInputs(): void;
  38035. /**
  38036. * Gets the class name of the current intput.
  38037. * @returns the class name
  38038. */
  38039. getClassName(): string;
  38040. /**
  38041. * Get the friendly name associated with the input class.
  38042. * @returns the input friendly name
  38043. */
  38044. getSimpleName(): string;
  38045. }
  38046. }
  38047. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  38048. import { Nullable } from "babylonjs/types";
  38049. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38050. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38051. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  38052. /**
  38053. * Manage the gamepad inputs to control a free camera.
  38054. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38055. */
  38056. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  38057. /**
  38058. * Define the camera the input is attached to.
  38059. */
  38060. camera: FreeCamera;
  38061. /**
  38062. * Define the Gamepad controlling the input
  38063. */
  38064. gamepad: Nullable<Gamepad>;
  38065. /**
  38066. * Defines the gamepad rotation sensiblity.
  38067. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38068. */
  38069. gamepadAngularSensibility: number;
  38070. /**
  38071. * Defines the gamepad move sensiblity.
  38072. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38073. */
  38074. gamepadMoveSensibility: number;
  38075. private _onGamepadConnectedObserver;
  38076. private _onGamepadDisconnectedObserver;
  38077. private _cameraTransform;
  38078. private _deltaTransform;
  38079. private _vector3;
  38080. private _vector2;
  38081. /**
  38082. * Attach the input controls to a specific dom element to get the input from.
  38083. * @param element Defines the element the controls should be listened from
  38084. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38085. */
  38086. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38087. /**
  38088. * Detach the current controls from the specified dom element.
  38089. * @param element Defines the element to stop listening the inputs from
  38090. */
  38091. detachControl(element: Nullable<HTMLElement>): void;
  38092. /**
  38093. * Update the current camera state depending on the inputs that have been used this frame.
  38094. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38095. */
  38096. checkInputs(): void;
  38097. /**
  38098. * Gets the class name of the current intput.
  38099. * @returns the class name
  38100. */
  38101. getClassName(): string;
  38102. /**
  38103. * Get the friendly name associated with the input class.
  38104. * @returns the input friendly name
  38105. */
  38106. getSimpleName(): string;
  38107. }
  38108. }
  38109. declare module "babylonjs/Misc/virtualJoystick" {
  38110. import { Nullable } from "babylonjs/types";
  38111. import { Vector3 } from "babylonjs/Maths/math";
  38112. /**
  38113. * Defines the potential axis of a Joystick
  38114. */
  38115. export enum JoystickAxis {
  38116. /** X axis */
  38117. X = 0,
  38118. /** Y axis */
  38119. Y = 1,
  38120. /** Z axis */
  38121. Z = 2
  38122. }
  38123. /**
  38124. * Class used to define virtual joystick (used in touch mode)
  38125. */
  38126. export class VirtualJoystick {
  38127. /**
  38128. * Gets or sets a boolean indicating that left and right values must be inverted
  38129. */
  38130. reverseLeftRight: boolean;
  38131. /**
  38132. * Gets or sets a boolean indicating that up and down values must be inverted
  38133. */
  38134. reverseUpDown: boolean;
  38135. /**
  38136. * Gets the offset value for the position (ie. the change of the position value)
  38137. */
  38138. deltaPosition: Vector3;
  38139. /**
  38140. * Gets a boolean indicating if the virtual joystick was pressed
  38141. */
  38142. pressed: boolean;
  38143. /**
  38144. * Canvas the virtual joystick will render onto, default z-index of this is 5
  38145. */
  38146. static Canvas: Nullable<HTMLCanvasElement>;
  38147. private static _globalJoystickIndex;
  38148. private static vjCanvasContext;
  38149. private static vjCanvasWidth;
  38150. private static vjCanvasHeight;
  38151. private static halfWidth;
  38152. private _action;
  38153. private _axisTargetedByLeftAndRight;
  38154. private _axisTargetedByUpAndDown;
  38155. private _joystickSensibility;
  38156. private _inversedSensibility;
  38157. private _joystickPointerID;
  38158. private _joystickColor;
  38159. private _joystickPointerPos;
  38160. private _joystickPreviousPointerPos;
  38161. private _joystickPointerStartPos;
  38162. private _deltaJoystickVector;
  38163. private _leftJoystick;
  38164. private _touches;
  38165. private _onPointerDownHandlerRef;
  38166. private _onPointerMoveHandlerRef;
  38167. private _onPointerUpHandlerRef;
  38168. private _onResize;
  38169. /**
  38170. * Creates a new virtual joystick
  38171. * @param leftJoystick defines that the joystick is for left hand (false by default)
  38172. */
  38173. constructor(leftJoystick?: boolean);
  38174. /**
  38175. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  38176. * @param newJoystickSensibility defines the new sensibility
  38177. */
  38178. setJoystickSensibility(newJoystickSensibility: number): void;
  38179. private _onPointerDown;
  38180. private _onPointerMove;
  38181. private _onPointerUp;
  38182. /**
  38183. * Change the color of the virtual joystick
  38184. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  38185. */
  38186. setJoystickColor(newColor: string): void;
  38187. /**
  38188. * Defines a callback to call when the joystick is touched
  38189. * @param action defines the callback
  38190. */
  38191. setActionOnTouch(action: () => any): void;
  38192. /**
  38193. * Defines which axis you'd like to control for left & right
  38194. * @param axis defines the axis to use
  38195. */
  38196. setAxisForLeftRight(axis: JoystickAxis): void;
  38197. /**
  38198. * Defines which axis you'd like to control for up & down
  38199. * @param axis defines the axis to use
  38200. */
  38201. setAxisForUpDown(axis: JoystickAxis): void;
  38202. private _drawVirtualJoystick;
  38203. /**
  38204. * Release internal HTML canvas
  38205. */
  38206. releaseCanvas(): void;
  38207. }
  38208. }
  38209. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  38210. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  38211. import { Nullable } from "babylonjs/types";
  38212. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  38213. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38214. module "babylonjs/Cameras/freeCameraInputsManager" {
  38215. interface FreeCameraInputsManager {
  38216. /**
  38217. * Add virtual joystick input support to the input manager.
  38218. * @returns the current input manager
  38219. */
  38220. addVirtualJoystick(): FreeCameraInputsManager;
  38221. }
  38222. }
  38223. /**
  38224. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  38225. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  38226. */
  38227. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  38228. /**
  38229. * Defines the camera the input is attached to.
  38230. */
  38231. camera: FreeCamera;
  38232. private _leftjoystick;
  38233. private _rightjoystick;
  38234. /**
  38235. * Gets the left stick of the virtual joystick.
  38236. * @returns The virtual Joystick
  38237. */
  38238. getLeftJoystick(): VirtualJoystick;
  38239. /**
  38240. * Gets the right stick of the virtual joystick.
  38241. * @returns The virtual Joystick
  38242. */
  38243. getRightJoystick(): VirtualJoystick;
  38244. /**
  38245. * Update the current camera state depending on the inputs that have been used this frame.
  38246. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  38247. */
  38248. checkInputs(): void;
  38249. /**
  38250. * Attach the input controls to a specific dom element to get the input from.
  38251. * @param element Defines the element the controls should be listened from
  38252. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  38253. */
  38254. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  38255. /**
  38256. * Detach the current controls from the specified dom element.
  38257. * @param element Defines the element to stop listening the inputs from
  38258. */
  38259. detachControl(element: Nullable<HTMLElement>): void;
  38260. /**
  38261. * Gets the class name of the current intput.
  38262. * @returns the class name
  38263. */
  38264. getClassName(): string;
  38265. /**
  38266. * Get the friendly name associated with the input class.
  38267. * @returns the input friendly name
  38268. */
  38269. getSimpleName(): string;
  38270. }
  38271. }
  38272. declare module "babylonjs/Cameras/Inputs/index" {
  38273. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  38274. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  38275. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  38276. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  38277. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38278. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  38279. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  38280. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  38281. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  38282. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  38283. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38284. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  38285. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  38286. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  38287. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  38288. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38289. }
  38290. declare module "babylonjs/Cameras/touchCamera" {
  38291. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38292. import { Scene } from "babylonjs/scene";
  38293. import { Vector3 } from "babylonjs/Maths/math";
  38294. /**
  38295. * This represents a FPS type of camera controlled by touch.
  38296. * This is like a universal camera minus the Gamepad controls.
  38297. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38298. */
  38299. export class TouchCamera extends FreeCamera {
  38300. /**
  38301. * Defines the touch sensibility for rotation.
  38302. * The higher the faster.
  38303. */
  38304. touchAngularSensibility: number;
  38305. /**
  38306. * Defines the touch sensibility for move.
  38307. * The higher the faster.
  38308. */
  38309. touchMoveSensibility: number;
  38310. /**
  38311. * Instantiates a new touch camera.
  38312. * This represents a FPS type of camera controlled by touch.
  38313. * This is like a universal camera minus the Gamepad controls.
  38314. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38315. * @param name Define the name of the camera in the scene
  38316. * @param position Define the start position of the camera in the scene
  38317. * @param scene Define the scene the camera belongs to
  38318. */
  38319. constructor(name: string, position: Vector3, scene: Scene);
  38320. /**
  38321. * Gets the current object class name.
  38322. * @return the class name
  38323. */
  38324. getClassName(): string;
  38325. /** @hidden */
  38326. _setupInputs(): void;
  38327. }
  38328. }
  38329. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  38330. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38331. import { Scene } from "babylonjs/scene";
  38332. import { Vector3, Axis } from "babylonjs/Maths/math";
  38333. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  38334. /**
  38335. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  38336. * being tilted forward or back and left or right.
  38337. */
  38338. export class DeviceOrientationCamera extends FreeCamera {
  38339. private _initialQuaternion;
  38340. private _quaternionCache;
  38341. private _tmpDragQuaternion;
  38342. /**
  38343. * Creates a new device orientation camera
  38344. * @param name The name of the camera
  38345. * @param position The start position camera
  38346. * @param scene The scene the camera belongs to
  38347. */
  38348. constructor(name: string, position: Vector3, scene: Scene);
  38349. /**
  38350. * @hidden
  38351. * Disabled pointer input on first orientation sensor update (Default: true)
  38352. */
  38353. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  38354. private _dragFactor;
  38355. /**
  38356. * Enabled turning on the y axis when the orientation sensor is active
  38357. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  38358. */
  38359. enableHorizontalDragging(dragFactor?: number): void;
  38360. /**
  38361. * Gets the current instance class name ("DeviceOrientationCamera").
  38362. * This helps avoiding instanceof at run time.
  38363. * @returns the class name
  38364. */
  38365. getClassName(): string;
  38366. /**
  38367. * @hidden
  38368. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  38369. */
  38370. _checkInputs(): void;
  38371. /**
  38372. * Reset the camera to its default orientation on the specified axis only.
  38373. * @param axis The axis to reset
  38374. */
  38375. resetToCurrentRotation(axis?: Axis): void;
  38376. }
  38377. }
  38378. declare module "babylonjs/Cameras/universalCamera" {
  38379. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  38380. import { Scene } from "babylonjs/scene";
  38381. import { Vector3 } from "babylonjs/Maths/math";
  38382. /**
  38383. * 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,
  38384. * which still works and will still be found in many Playgrounds.
  38385. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38386. */
  38387. export class UniversalCamera extends TouchCamera {
  38388. /**
  38389. * Defines the gamepad rotation sensiblity.
  38390. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  38391. */
  38392. gamepadAngularSensibility: number;
  38393. /**
  38394. * Defines the gamepad move sensiblity.
  38395. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  38396. */
  38397. gamepadMoveSensibility: number;
  38398. /**
  38399. * 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,
  38400. * which still works and will still be found in many Playgrounds.
  38401. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38402. * @param name Define the name of the camera in the scene
  38403. * @param position Define the start position of the camera in the scene
  38404. * @param scene Define the scene the camera belongs to
  38405. */
  38406. constructor(name: string, position: Vector3, scene: Scene);
  38407. /**
  38408. * Gets the current object class name.
  38409. * @return the class name
  38410. */
  38411. getClassName(): string;
  38412. }
  38413. }
  38414. declare module "babylonjs/Cameras/gamepadCamera" {
  38415. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38416. import { Scene } from "babylonjs/scene";
  38417. import { Vector3 } from "babylonjs/Maths/math";
  38418. /**
  38419. * This represents a FPS type of camera. This is only here for back compat purpose.
  38420. * Please use the UniversalCamera instead as both are identical.
  38421. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38422. */
  38423. export class GamepadCamera extends UniversalCamera {
  38424. /**
  38425. * Instantiates a new Gamepad Camera
  38426. * This represents a FPS type of camera. This is only here for back compat purpose.
  38427. * Please use the UniversalCamera instead as both are identical.
  38428. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  38429. * @param name Define the name of the camera in the scene
  38430. * @param position Define the start position of the camera in the scene
  38431. * @param scene Define the scene the camera belongs to
  38432. */
  38433. constructor(name: string, position: Vector3, scene: Scene);
  38434. /**
  38435. * Gets the current object class name.
  38436. * @return the class name
  38437. */
  38438. getClassName(): string;
  38439. }
  38440. }
  38441. declare module "babylonjs/Shaders/pass.fragment" {
  38442. /** @hidden */
  38443. export var passPixelShader: {
  38444. name: string;
  38445. shader: string;
  38446. };
  38447. }
  38448. declare module "babylonjs/Shaders/passCube.fragment" {
  38449. /** @hidden */
  38450. export var passCubePixelShader: {
  38451. name: string;
  38452. shader: string;
  38453. };
  38454. }
  38455. declare module "babylonjs/PostProcesses/passPostProcess" {
  38456. import { Nullable } from "babylonjs/types";
  38457. import { Camera } from "babylonjs/Cameras/camera";
  38458. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38459. import { Engine } from "babylonjs/Engines/engine";
  38460. import "babylonjs/Shaders/pass.fragment";
  38461. import "babylonjs/Shaders/passCube.fragment";
  38462. /**
  38463. * PassPostProcess which produces an output the same as it's input
  38464. */
  38465. export class PassPostProcess extends PostProcess {
  38466. /**
  38467. * Creates the PassPostProcess
  38468. * @param name The name of the effect.
  38469. * @param options The required width/height ratio to downsize to before computing the render pass.
  38470. * @param camera The camera to apply the render pass to.
  38471. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38472. * @param engine The engine which the post process will be applied. (default: current engine)
  38473. * @param reusable If the post process can be reused on the same frame. (default: false)
  38474. * @param textureType The type of texture to be used when performing the post processing.
  38475. * @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)
  38476. */
  38477. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38478. }
  38479. /**
  38480. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  38481. */
  38482. export class PassCubePostProcess extends PostProcess {
  38483. private _face;
  38484. /**
  38485. * Gets or sets the cube face to display.
  38486. * * 0 is +X
  38487. * * 1 is -X
  38488. * * 2 is +Y
  38489. * * 3 is -Y
  38490. * * 4 is +Z
  38491. * * 5 is -Z
  38492. */
  38493. face: number;
  38494. /**
  38495. * Creates the PassCubePostProcess
  38496. * @param name The name of the effect.
  38497. * @param options The required width/height ratio to downsize to before computing the render pass.
  38498. * @param camera The camera to apply the render pass to.
  38499. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38500. * @param engine The engine which the post process will be applied. (default: current engine)
  38501. * @param reusable If the post process can be reused on the same frame. (default: false)
  38502. * @param textureType The type of texture to be used when performing the post processing.
  38503. * @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)
  38504. */
  38505. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  38506. }
  38507. }
  38508. declare module "babylonjs/Shaders/anaglyph.fragment" {
  38509. /** @hidden */
  38510. export var anaglyphPixelShader: {
  38511. name: string;
  38512. shader: string;
  38513. };
  38514. }
  38515. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  38516. import { Engine } from "babylonjs/Engines/engine";
  38517. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  38518. import { Camera } from "babylonjs/Cameras/camera";
  38519. import "babylonjs/Shaders/anaglyph.fragment";
  38520. /**
  38521. * Postprocess used to generate anaglyphic rendering
  38522. */
  38523. export class AnaglyphPostProcess extends PostProcess {
  38524. private _passedProcess;
  38525. /**
  38526. * Creates a new AnaglyphPostProcess
  38527. * @param name defines postprocess name
  38528. * @param options defines creation options or target ratio scale
  38529. * @param rigCameras defines cameras using this postprocess
  38530. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  38531. * @param engine defines hosting engine
  38532. * @param reusable defines if the postprocess will be reused multiple times per frame
  38533. */
  38534. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  38535. }
  38536. }
  38537. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  38538. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  38539. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38540. import { Scene } from "babylonjs/scene";
  38541. import { Vector3 } from "babylonjs/Maths/math";
  38542. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38543. /**
  38544. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  38545. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38546. */
  38547. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  38548. /**
  38549. * Creates a new AnaglyphArcRotateCamera
  38550. * @param name defines camera name
  38551. * @param alpha defines alpha angle (in radians)
  38552. * @param beta defines beta angle (in radians)
  38553. * @param radius defines radius
  38554. * @param target defines camera target
  38555. * @param interaxialDistance defines distance between each color axis
  38556. * @param scene defines the hosting scene
  38557. */
  38558. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  38559. /**
  38560. * Gets camera class name
  38561. * @returns AnaglyphArcRotateCamera
  38562. */
  38563. getClassName(): string;
  38564. }
  38565. }
  38566. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  38567. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38568. import { Scene } from "babylonjs/scene";
  38569. import { Vector3 } from "babylonjs/Maths/math";
  38570. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38571. /**
  38572. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  38573. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38574. */
  38575. export class AnaglyphFreeCamera extends FreeCamera {
  38576. /**
  38577. * Creates a new AnaglyphFreeCamera
  38578. * @param name defines camera name
  38579. * @param position defines initial position
  38580. * @param interaxialDistance defines distance between each color axis
  38581. * @param scene defines the hosting scene
  38582. */
  38583. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38584. /**
  38585. * Gets camera class name
  38586. * @returns AnaglyphFreeCamera
  38587. */
  38588. getClassName(): string;
  38589. }
  38590. }
  38591. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  38592. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38593. import { Scene } from "babylonjs/scene";
  38594. import { Vector3 } from "babylonjs/Maths/math";
  38595. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38596. /**
  38597. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  38598. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38599. */
  38600. export class AnaglyphGamepadCamera extends GamepadCamera {
  38601. /**
  38602. * Creates a new AnaglyphGamepadCamera
  38603. * @param name defines camera name
  38604. * @param position defines initial position
  38605. * @param interaxialDistance defines distance between each color axis
  38606. * @param scene defines the hosting scene
  38607. */
  38608. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38609. /**
  38610. * Gets camera class name
  38611. * @returns AnaglyphGamepadCamera
  38612. */
  38613. getClassName(): string;
  38614. }
  38615. }
  38616. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  38617. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38618. import { Scene } from "babylonjs/scene";
  38619. import { Vector3 } from "babylonjs/Maths/math";
  38620. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  38621. /**
  38622. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  38623. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  38624. */
  38625. export class AnaglyphUniversalCamera extends UniversalCamera {
  38626. /**
  38627. * Creates a new AnaglyphUniversalCamera
  38628. * @param name defines camera name
  38629. * @param position defines initial position
  38630. * @param interaxialDistance defines distance between each color axis
  38631. * @param scene defines the hosting scene
  38632. */
  38633. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  38634. /**
  38635. * Gets camera class name
  38636. * @returns AnaglyphUniversalCamera
  38637. */
  38638. getClassName(): string;
  38639. }
  38640. }
  38641. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  38642. /** @hidden */
  38643. export var stereoscopicInterlacePixelShader: {
  38644. name: string;
  38645. shader: string;
  38646. };
  38647. }
  38648. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  38649. import { Camera } from "babylonjs/Cameras/camera";
  38650. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38651. import { Engine } from "babylonjs/Engines/engine";
  38652. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  38653. /**
  38654. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  38655. */
  38656. export class StereoscopicInterlacePostProcess extends PostProcess {
  38657. private _stepSize;
  38658. private _passedProcess;
  38659. /**
  38660. * Initializes a StereoscopicInterlacePostProcess
  38661. * @param name The name of the effect.
  38662. * @param rigCameras The rig cameras to be appled to the post process
  38663. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  38664. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  38665. * @param engine The engine which the post process will be applied. (default: current engine)
  38666. * @param reusable If the post process can be reused on the same frame. (default: false)
  38667. */
  38668. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  38669. }
  38670. }
  38671. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  38672. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  38673. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38674. import { Scene } from "babylonjs/scene";
  38675. import { Vector3 } from "babylonjs/Maths/math";
  38676. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38677. /**
  38678. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  38679. * @see http://doc.babylonjs.com/features/cameras
  38680. */
  38681. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  38682. /**
  38683. * Creates a new StereoscopicArcRotateCamera
  38684. * @param name defines camera name
  38685. * @param alpha defines alpha angle (in radians)
  38686. * @param beta defines beta angle (in radians)
  38687. * @param radius defines radius
  38688. * @param target defines camera target
  38689. * @param interaxialDistance defines distance between each color axis
  38690. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38691. * @param scene defines the hosting scene
  38692. */
  38693. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38694. /**
  38695. * Gets camera class name
  38696. * @returns StereoscopicArcRotateCamera
  38697. */
  38698. getClassName(): string;
  38699. }
  38700. }
  38701. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  38702. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38703. import { Scene } from "babylonjs/scene";
  38704. import { Vector3 } from "babylonjs/Maths/math";
  38705. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38706. /**
  38707. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  38708. * @see http://doc.babylonjs.com/features/cameras
  38709. */
  38710. export class StereoscopicFreeCamera extends FreeCamera {
  38711. /**
  38712. * Creates a new StereoscopicFreeCamera
  38713. * @param name defines camera name
  38714. * @param position defines initial position
  38715. * @param interaxialDistance defines distance between each color axis
  38716. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38717. * @param scene defines the hosting scene
  38718. */
  38719. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38720. /**
  38721. * Gets camera class name
  38722. * @returns StereoscopicFreeCamera
  38723. */
  38724. getClassName(): string;
  38725. }
  38726. }
  38727. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  38728. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  38729. import { Scene } from "babylonjs/scene";
  38730. import { Vector3 } from "babylonjs/Maths/math";
  38731. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38732. /**
  38733. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  38734. * @see http://doc.babylonjs.com/features/cameras
  38735. */
  38736. export class StereoscopicGamepadCamera extends GamepadCamera {
  38737. /**
  38738. * Creates a new StereoscopicGamepadCamera
  38739. * @param name defines camera name
  38740. * @param position defines initial position
  38741. * @param interaxialDistance defines distance between each color axis
  38742. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38743. * @param scene defines the hosting scene
  38744. */
  38745. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38746. /**
  38747. * Gets camera class name
  38748. * @returns StereoscopicGamepadCamera
  38749. */
  38750. getClassName(): string;
  38751. }
  38752. }
  38753. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  38754. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  38755. import { Scene } from "babylonjs/scene";
  38756. import { Vector3 } from "babylonjs/Maths/math";
  38757. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  38758. /**
  38759. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  38760. * @see http://doc.babylonjs.com/features/cameras
  38761. */
  38762. export class StereoscopicUniversalCamera extends UniversalCamera {
  38763. /**
  38764. * Creates a new StereoscopicUniversalCamera
  38765. * @param name defines camera name
  38766. * @param position defines initial position
  38767. * @param interaxialDistance defines distance between each color axis
  38768. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  38769. * @param scene defines the hosting scene
  38770. */
  38771. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  38772. /**
  38773. * Gets camera class name
  38774. * @returns StereoscopicUniversalCamera
  38775. */
  38776. getClassName(): string;
  38777. }
  38778. }
  38779. declare module "babylonjs/Cameras/Stereoscopic/index" {
  38780. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  38781. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  38782. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  38783. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  38784. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  38785. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  38786. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  38787. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  38788. }
  38789. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  38790. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  38791. import { Scene } from "babylonjs/scene";
  38792. import { Vector3 } from "babylonjs/Maths/math";
  38793. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  38794. /**
  38795. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  38796. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38797. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38798. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38799. */
  38800. export class VirtualJoysticksCamera extends FreeCamera {
  38801. /**
  38802. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  38803. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  38804. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  38805. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  38806. * @param name Define the name of the camera in the scene
  38807. * @param position Define the start position of the camera in the scene
  38808. * @param scene Define the scene the camera belongs to
  38809. */
  38810. constructor(name: string, position: Vector3, scene: Scene);
  38811. /**
  38812. * Gets the current object class name.
  38813. * @return the class name
  38814. */
  38815. getClassName(): string;
  38816. }
  38817. }
  38818. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  38819. import { Matrix } from "babylonjs/Maths/math";
  38820. /**
  38821. * This represents all the required metrics to create a VR camera.
  38822. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  38823. */
  38824. export class VRCameraMetrics {
  38825. /**
  38826. * Define the horizontal resolution off the screen.
  38827. */
  38828. hResolution: number;
  38829. /**
  38830. * Define the vertical resolution off the screen.
  38831. */
  38832. vResolution: number;
  38833. /**
  38834. * Define the horizontal screen size.
  38835. */
  38836. hScreenSize: number;
  38837. /**
  38838. * Define the vertical screen size.
  38839. */
  38840. vScreenSize: number;
  38841. /**
  38842. * Define the vertical screen center position.
  38843. */
  38844. vScreenCenter: number;
  38845. /**
  38846. * Define the distance of the eyes to the screen.
  38847. */
  38848. eyeToScreenDistance: number;
  38849. /**
  38850. * Define the distance between both lenses
  38851. */
  38852. lensSeparationDistance: number;
  38853. /**
  38854. * Define the distance between both viewer's eyes.
  38855. */
  38856. interpupillaryDistance: number;
  38857. /**
  38858. * Define the distortion factor of the VR postprocess.
  38859. * Please, touch with care.
  38860. */
  38861. distortionK: number[];
  38862. /**
  38863. * Define the chromatic aberration correction factors for the VR post process.
  38864. */
  38865. chromaAbCorrection: number[];
  38866. /**
  38867. * Define the scale factor of the post process.
  38868. * The smaller the better but the slower.
  38869. */
  38870. postProcessScaleFactor: number;
  38871. /**
  38872. * Define an offset for the lens center.
  38873. */
  38874. lensCenterOffset: number;
  38875. /**
  38876. * Define if the current vr camera should compensate the distortion of the lense or not.
  38877. */
  38878. compensateDistortion: boolean;
  38879. /**
  38880. * Defines if multiview should be enabled when rendering (Default: false)
  38881. */
  38882. multiviewEnabled: boolean;
  38883. /**
  38884. * Gets the rendering aspect ratio based on the provided resolutions.
  38885. */
  38886. readonly aspectRatio: number;
  38887. /**
  38888. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  38889. */
  38890. readonly aspectRatioFov: number;
  38891. /**
  38892. * @hidden
  38893. */
  38894. readonly leftHMatrix: Matrix;
  38895. /**
  38896. * @hidden
  38897. */
  38898. readonly rightHMatrix: Matrix;
  38899. /**
  38900. * @hidden
  38901. */
  38902. readonly leftPreViewMatrix: Matrix;
  38903. /**
  38904. * @hidden
  38905. */
  38906. readonly rightPreViewMatrix: Matrix;
  38907. /**
  38908. * Get the default VRMetrics based on the most generic setup.
  38909. * @returns the default vr metrics
  38910. */
  38911. static GetDefault(): VRCameraMetrics;
  38912. }
  38913. }
  38914. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  38915. /** @hidden */
  38916. export var vrDistortionCorrectionPixelShader: {
  38917. name: string;
  38918. shader: string;
  38919. };
  38920. }
  38921. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  38922. import { Camera } from "babylonjs/Cameras/camera";
  38923. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38924. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38925. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  38926. /**
  38927. * VRDistortionCorrectionPostProcess used for mobile VR
  38928. */
  38929. export class VRDistortionCorrectionPostProcess extends PostProcess {
  38930. private _isRightEye;
  38931. private _distortionFactors;
  38932. private _postProcessScaleFactor;
  38933. private _lensCenterOffset;
  38934. private _scaleIn;
  38935. private _scaleFactor;
  38936. private _lensCenter;
  38937. /**
  38938. * Initializes the VRDistortionCorrectionPostProcess
  38939. * @param name The name of the effect.
  38940. * @param camera The camera to apply the render pass to.
  38941. * @param isRightEye If this is for the right eye distortion
  38942. * @param vrMetrics All the required metrics for the VR camera
  38943. */
  38944. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  38945. }
  38946. }
  38947. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  38948. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  38949. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  38950. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38951. import { Scene } from "babylonjs/scene";
  38952. import { Vector3 } from "babylonjs/Maths/math";
  38953. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  38954. import "babylonjs/Cameras/RigModes/vrRigMode";
  38955. /**
  38956. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  38957. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38958. */
  38959. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  38960. /**
  38961. * Creates a new VRDeviceOrientationArcRotateCamera
  38962. * @param name defines camera name
  38963. * @param alpha defines the camera rotation along the logitudinal axis
  38964. * @param beta defines the camera rotation along the latitudinal axis
  38965. * @param radius defines the camera distance from its target
  38966. * @param target defines the camera target
  38967. * @param scene defines the scene the camera belongs to
  38968. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38969. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38970. */
  38971. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38972. /**
  38973. * Gets camera class name
  38974. * @returns VRDeviceOrientationArcRotateCamera
  38975. */
  38976. getClassName(): string;
  38977. }
  38978. }
  38979. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  38980. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  38981. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  38982. import { Scene } from "babylonjs/scene";
  38983. import { Vector3 } from "babylonjs/Maths/math";
  38984. import "babylonjs/Cameras/RigModes/vrRigMode";
  38985. /**
  38986. * Camera used to simulate VR rendering (based on FreeCamera)
  38987. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  38988. */
  38989. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  38990. /**
  38991. * Creates a new VRDeviceOrientationFreeCamera
  38992. * @param name defines camera name
  38993. * @param position defines the start position of the camera
  38994. * @param scene defines the scene the camera belongs to
  38995. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  38996. * @param vrCameraMetrics defines the vr metrics associated to the camera
  38997. */
  38998. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  38999. /**
  39000. * Gets camera class name
  39001. * @returns VRDeviceOrientationFreeCamera
  39002. */
  39003. getClassName(): string;
  39004. }
  39005. }
  39006. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  39007. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  39008. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  39009. import { Scene } from "babylonjs/scene";
  39010. import { Vector3 } from "babylonjs/Maths/math";
  39011. /**
  39012. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  39013. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  39014. */
  39015. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  39016. /**
  39017. * Creates a new VRDeviceOrientationGamepadCamera
  39018. * @param name defines camera name
  39019. * @param position defines the start position of the camera
  39020. * @param scene defines the scene the camera belongs to
  39021. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  39022. * @param vrCameraMetrics defines the vr metrics associated to the camera
  39023. */
  39024. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  39025. /**
  39026. * Gets camera class name
  39027. * @returns VRDeviceOrientationGamepadCamera
  39028. */
  39029. getClassName(): string;
  39030. }
  39031. }
  39032. declare module "babylonjs/Gamepads/xboxGamepad" {
  39033. import { Observable } from "babylonjs/Misc/observable";
  39034. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  39035. /**
  39036. * Defines supported buttons for XBox360 compatible gamepads
  39037. */
  39038. export enum Xbox360Button {
  39039. /** A */
  39040. A = 0,
  39041. /** B */
  39042. B = 1,
  39043. /** X */
  39044. X = 2,
  39045. /** Y */
  39046. Y = 3,
  39047. /** Start */
  39048. Start = 4,
  39049. /** Back */
  39050. Back = 5,
  39051. /** Left button */
  39052. LB = 6,
  39053. /** Right button */
  39054. RB = 7,
  39055. /** Left stick */
  39056. LeftStick = 8,
  39057. /** Right stick */
  39058. RightStick = 9
  39059. }
  39060. /** Defines values for XBox360 DPad */
  39061. export enum Xbox360Dpad {
  39062. /** Up */
  39063. Up = 0,
  39064. /** Down */
  39065. Down = 1,
  39066. /** Left */
  39067. Left = 2,
  39068. /** Right */
  39069. Right = 3
  39070. }
  39071. /**
  39072. * Defines a XBox360 gamepad
  39073. */
  39074. export class Xbox360Pad extends Gamepad {
  39075. private _leftTrigger;
  39076. private _rightTrigger;
  39077. private _onlefttriggerchanged;
  39078. private _onrighttriggerchanged;
  39079. private _onbuttondown;
  39080. private _onbuttonup;
  39081. private _ondpaddown;
  39082. private _ondpadup;
  39083. /** Observable raised when a button is pressed */
  39084. onButtonDownObservable: Observable<Xbox360Button>;
  39085. /** Observable raised when a button is released */
  39086. onButtonUpObservable: Observable<Xbox360Button>;
  39087. /** Observable raised when a pad is pressed */
  39088. onPadDownObservable: Observable<Xbox360Dpad>;
  39089. /** Observable raised when a pad is released */
  39090. onPadUpObservable: Observable<Xbox360Dpad>;
  39091. private _buttonA;
  39092. private _buttonB;
  39093. private _buttonX;
  39094. private _buttonY;
  39095. private _buttonBack;
  39096. private _buttonStart;
  39097. private _buttonLB;
  39098. private _buttonRB;
  39099. private _buttonLeftStick;
  39100. private _buttonRightStick;
  39101. private _dPadUp;
  39102. private _dPadDown;
  39103. private _dPadLeft;
  39104. private _dPadRight;
  39105. private _isXboxOnePad;
  39106. /**
  39107. * Creates a new XBox360 gamepad object
  39108. * @param id defines the id of this gamepad
  39109. * @param index defines its index
  39110. * @param gamepad defines the internal HTML gamepad object
  39111. * @param xboxOne defines if it is a XBox One gamepad
  39112. */
  39113. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  39114. /**
  39115. * Defines the callback to call when left trigger is pressed
  39116. * @param callback defines the callback to use
  39117. */
  39118. onlefttriggerchanged(callback: (value: number) => void): void;
  39119. /**
  39120. * Defines the callback to call when right trigger is pressed
  39121. * @param callback defines the callback to use
  39122. */
  39123. onrighttriggerchanged(callback: (value: number) => void): void;
  39124. /**
  39125. * Gets the left trigger value
  39126. */
  39127. /**
  39128. * Sets the left trigger value
  39129. */
  39130. leftTrigger: number;
  39131. /**
  39132. * Gets the right trigger value
  39133. */
  39134. /**
  39135. * Sets the right trigger value
  39136. */
  39137. rightTrigger: number;
  39138. /**
  39139. * Defines the callback to call when a button is pressed
  39140. * @param callback defines the callback to use
  39141. */
  39142. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  39143. /**
  39144. * Defines the callback to call when a button is released
  39145. * @param callback defines the callback to use
  39146. */
  39147. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  39148. /**
  39149. * Defines the callback to call when a pad is pressed
  39150. * @param callback defines the callback to use
  39151. */
  39152. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  39153. /**
  39154. * Defines the callback to call when a pad is released
  39155. * @param callback defines the callback to use
  39156. */
  39157. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  39158. private _setButtonValue;
  39159. private _setDPadValue;
  39160. /**
  39161. * Gets the value of the `A` button
  39162. */
  39163. /**
  39164. * Sets the value of the `A` button
  39165. */
  39166. buttonA: number;
  39167. /**
  39168. * Gets the value of the `B` button
  39169. */
  39170. /**
  39171. * Sets the value of the `B` button
  39172. */
  39173. buttonB: number;
  39174. /**
  39175. * Gets the value of the `X` button
  39176. */
  39177. /**
  39178. * Sets the value of the `X` button
  39179. */
  39180. buttonX: number;
  39181. /**
  39182. * Gets the value of the `Y` button
  39183. */
  39184. /**
  39185. * Sets the value of the `Y` button
  39186. */
  39187. buttonY: number;
  39188. /**
  39189. * Gets the value of the `Start` button
  39190. */
  39191. /**
  39192. * Sets the value of the `Start` button
  39193. */
  39194. buttonStart: number;
  39195. /**
  39196. * Gets the value of the `Back` button
  39197. */
  39198. /**
  39199. * Sets the value of the `Back` button
  39200. */
  39201. buttonBack: number;
  39202. /**
  39203. * Gets the value of the `Left` button
  39204. */
  39205. /**
  39206. * Sets the value of the `Left` button
  39207. */
  39208. buttonLB: number;
  39209. /**
  39210. * Gets the value of the `Right` button
  39211. */
  39212. /**
  39213. * Sets the value of the `Right` button
  39214. */
  39215. buttonRB: number;
  39216. /**
  39217. * Gets the value of the Left joystick
  39218. */
  39219. /**
  39220. * Sets the value of the Left joystick
  39221. */
  39222. buttonLeftStick: number;
  39223. /**
  39224. * Gets the value of the Right joystick
  39225. */
  39226. /**
  39227. * Sets the value of the Right joystick
  39228. */
  39229. buttonRightStick: number;
  39230. /**
  39231. * Gets the value of D-pad up
  39232. */
  39233. /**
  39234. * Sets the value of D-pad up
  39235. */
  39236. dPadUp: number;
  39237. /**
  39238. * Gets the value of D-pad down
  39239. */
  39240. /**
  39241. * Sets the value of D-pad down
  39242. */
  39243. dPadDown: number;
  39244. /**
  39245. * Gets the value of D-pad left
  39246. */
  39247. /**
  39248. * Sets the value of D-pad left
  39249. */
  39250. dPadLeft: number;
  39251. /**
  39252. * Gets the value of D-pad right
  39253. */
  39254. /**
  39255. * Sets the value of D-pad right
  39256. */
  39257. dPadRight: number;
  39258. /**
  39259. * Force the gamepad to synchronize with device values
  39260. */
  39261. update(): void;
  39262. /**
  39263. * Disposes the gamepad
  39264. */
  39265. dispose(): void;
  39266. }
  39267. }
  39268. declare module "babylonjs/Materials/pushMaterial" {
  39269. import { Nullable } from "babylonjs/types";
  39270. import { Scene } from "babylonjs/scene";
  39271. import { Matrix } from "babylonjs/Maths/math";
  39272. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39273. import { Mesh } from "babylonjs/Meshes/mesh";
  39274. import { Material } from "babylonjs/Materials/material";
  39275. import { Effect } from "babylonjs/Materials/effect";
  39276. /**
  39277. * Base class of materials working in push mode in babylon JS
  39278. * @hidden
  39279. */
  39280. export class PushMaterial extends Material {
  39281. protected _activeEffect: Effect;
  39282. protected _normalMatrix: Matrix;
  39283. /**
  39284. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  39285. * This means that the material can keep using a previous shader while a new one is being compiled.
  39286. * This is mostly used when shader parallel compilation is supported (true by default)
  39287. */
  39288. allowShaderHotSwapping: boolean;
  39289. constructor(name: string, scene: Scene);
  39290. getEffect(): Effect;
  39291. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  39292. /**
  39293. * Binds the given world matrix to the active effect
  39294. *
  39295. * @param world the matrix to bind
  39296. */
  39297. bindOnlyWorldMatrix(world: Matrix): void;
  39298. /**
  39299. * Binds the given normal matrix to the active effect
  39300. *
  39301. * @param normalMatrix the matrix to bind
  39302. */
  39303. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  39304. bind(world: Matrix, mesh?: Mesh): void;
  39305. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  39306. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  39307. }
  39308. }
  39309. declare module "babylonjs/Materials/materialFlags" {
  39310. /**
  39311. * This groups all the flags used to control the materials channel.
  39312. */
  39313. export class MaterialFlags {
  39314. private static _DiffuseTextureEnabled;
  39315. /**
  39316. * Are diffuse textures enabled in the application.
  39317. */
  39318. static DiffuseTextureEnabled: boolean;
  39319. private static _AmbientTextureEnabled;
  39320. /**
  39321. * Are ambient textures enabled in the application.
  39322. */
  39323. static AmbientTextureEnabled: boolean;
  39324. private static _OpacityTextureEnabled;
  39325. /**
  39326. * Are opacity textures enabled in the application.
  39327. */
  39328. static OpacityTextureEnabled: boolean;
  39329. private static _ReflectionTextureEnabled;
  39330. /**
  39331. * Are reflection textures enabled in the application.
  39332. */
  39333. static ReflectionTextureEnabled: boolean;
  39334. private static _EmissiveTextureEnabled;
  39335. /**
  39336. * Are emissive textures enabled in the application.
  39337. */
  39338. static EmissiveTextureEnabled: boolean;
  39339. private static _SpecularTextureEnabled;
  39340. /**
  39341. * Are specular textures enabled in the application.
  39342. */
  39343. static SpecularTextureEnabled: boolean;
  39344. private static _BumpTextureEnabled;
  39345. /**
  39346. * Are bump textures enabled in the application.
  39347. */
  39348. static BumpTextureEnabled: boolean;
  39349. private static _LightmapTextureEnabled;
  39350. /**
  39351. * Are lightmap textures enabled in the application.
  39352. */
  39353. static LightmapTextureEnabled: boolean;
  39354. private static _RefractionTextureEnabled;
  39355. /**
  39356. * Are refraction textures enabled in the application.
  39357. */
  39358. static RefractionTextureEnabled: boolean;
  39359. private static _ColorGradingTextureEnabled;
  39360. /**
  39361. * Are color grading textures enabled in the application.
  39362. */
  39363. static ColorGradingTextureEnabled: boolean;
  39364. private static _FresnelEnabled;
  39365. /**
  39366. * Are fresnels enabled in the application.
  39367. */
  39368. static FresnelEnabled: boolean;
  39369. private static _ClearCoatTextureEnabled;
  39370. /**
  39371. * Are clear coat textures enabled in the application.
  39372. */
  39373. static ClearCoatTextureEnabled: boolean;
  39374. private static _ClearCoatBumpTextureEnabled;
  39375. /**
  39376. * Are clear coat bump textures enabled in the application.
  39377. */
  39378. static ClearCoatBumpTextureEnabled: boolean;
  39379. private static _ClearCoatTintTextureEnabled;
  39380. /**
  39381. * Are clear coat tint textures enabled in the application.
  39382. */
  39383. static ClearCoatTintTextureEnabled: boolean;
  39384. private static _SheenTextureEnabled;
  39385. /**
  39386. * Are sheen textures enabled in the application.
  39387. */
  39388. static SheenTextureEnabled: boolean;
  39389. private static _AnisotropicTextureEnabled;
  39390. /**
  39391. * Are anisotropic textures enabled in the application.
  39392. */
  39393. static AnisotropicTextureEnabled: boolean;
  39394. private static _ThicknessTextureEnabled;
  39395. /**
  39396. * Are thickness textures enabled in the application.
  39397. */
  39398. static ThicknessTextureEnabled: boolean;
  39399. }
  39400. }
  39401. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  39402. /** @hidden */
  39403. export var defaultFragmentDeclaration: {
  39404. name: string;
  39405. shader: string;
  39406. };
  39407. }
  39408. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  39409. /** @hidden */
  39410. export var defaultUboDeclaration: {
  39411. name: string;
  39412. shader: string;
  39413. };
  39414. }
  39415. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  39416. /** @hidden */
  39417. export var lightFragmentDeclaration: {
  39418. name: string;
  39419. shader: string;
  39420. };
  39421. }
  39422. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  39423. /** @hidden */
  39424. export var lightUboDeclaration: {
  39425. name: string;
  39426. shader: string;
  39427. };
  39428. }
  39429. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  39430. /** @hidden */
  39431. export var lightsFragmentFunctions: {
  39432. name: string;
  39433. shader: string;
  39434. };
  39435. }
  39436. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  39437. /** @hidden */
  39438. export var shadowsFragmentFunctions: {
  39439. name: string;
  39440. shader: string;
  39441. };
  39442. }
  39443. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  39444. /** @hidden */
  39445. export var fresnelFunction: {
  39446. name: string;
  39447. shader: string;
  39448. };
  39449. }
  39450. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  39451. /** @hidden */
  39452. export var reflectionFunction: {
  39453. name: string;
  39454. shader: string;
  39455. };
  39456. }
  39457. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  39458. /** @hidden */
  39459. export var bumpFragmentFunctions: {
  39460. name: string;
  39461. shader: string;
  39462. };
  39463. }
  39464. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  39465. /** @hidden */
  39466. export var logDepthDeclaration: {
  39467. name: string;
  39468. shader: string;
  39469. };
  39470. }
  39471. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  39472. /** @hidden */
  39473. export var bumpFragment: {
  39474. name: string;
  39475. shader: string;
  39476. };
  39477. }
  39478. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  39479. /** @hidden */
  39480. export var depthPrePass: {
  39481. name: string;
  39482. shader: string;
  39483. };
  39484. }
  39485. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  39486. /** @hidden */
  39487. export var lightFragment: {
  39488. name: string;
  39489. shader: string;
  39490. };
  39491. }
  39492. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  39493. /** @hidden */
  39494. export var logDepthFragment: {
  39495. name: string;
  39496. shader: string;
  39497. };
  39498. }
  39499. declare module "babylonjs/Shaders/default.fragment" {
  39500. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  39501. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39502. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39503. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39504. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39505. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  39506. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  39507. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  39508. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  39509. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  39510. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  39511. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  39512. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  39513. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39514. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  39515. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  39516. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  39517. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  39518. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  39519. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  39520. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  39521. /** @hidden */
  39522. export var defaultPixelShader: {
  39523. name: string;
  39524. shader: string;
  39525. };
  39526. }
  39527. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  39528. /** @hidden */
  39529. export var defaultVertexDeclaration: {
  39530. name: string;
  39531. shader: string;
  39532. };
  39533. }
  39534. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  39535. /** @hidden */
  39536. export var bumpVertexDeclaration: {
  39537. name: string;
  39538. shader: string;
  39539. };
  39540. }
  39541. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  39542. /** @hidden */
  39543. export var bumpVertex: {
  39544. name: string;
  39545. shader: string;
  39546. };
  39547. }
  39548. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  39549. /** @hidden */
  39550. export var fogVertex: {
  39551. name: string;
  39552. shader: string;
  39553. };
  39554. }
  39555. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  39556. /** @hidden */
  39557. export var shadowsVertex: {
  39558. name: string;
  39559. shader: string;
  39560. };
  39561. }
  39562. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  39563. /** @hidden */
  39564. export var pointCloudVertex: {
  39565. name: string;
  39566. shader: string;
  39567. };
  39568. }
  39569. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  39570. /** @hidden */
  39571. export var logDepthVertex: {
  39572. name: string;
  39573. shader: string;
  39574. };
  39575. }
  39576. declare module "babylonjs/Shaders/default.vertex" {
  39577. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  39578. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  39579. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  39580. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  39581. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  39582. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  39583. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  39584. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  39585. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  39586. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  39587. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  39588. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  39589. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  39590. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  39591. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  39592. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  39593. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  39594. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  39595. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  39596. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  39597. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  39598. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  39599. /** @hidden */
  39600. export var defaultVertexShader: {
  39601. name: string;
  39602. shader: string;
  39603. };
  39604. }
  39605. declare module "babylonjs/Materials/standardMaterial" {
  39606. import { SmartArray } from "babylonjs/Misc/smartArray";
  39607. import { IAnimatable } from "babylonjs/Misc/tools";
  39608. import { Nullable } from "babylonjs/types";
  39609. import { Scene } from "babylonjs/scene";
  39610. import { Matrix, Color3 } from "babylonjs/Maths/math";
  39611. import { SubMesh } from "babylonjs/Meshes/subMesh";
  39612. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  39613. import { Mesh } from "babylonjs/Meshes/mesh";
  39614. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  39615. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  39616. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  39617. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  39618. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  39619. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  39620. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  39621. import "babylonjs/Shaders/default.fragment";
  39622. import "babylonjs/Shaders/default.vertex";
  39623. /** @hidden */
  39624. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  39625. MAINUV1: boolean;
  39626. MAINUV2: boolean;
  39627. DIFFUSE: boolean;
  39628. DIFFUSEDIRECTUV: number;
  39629. AMBIENT: boolean;
  39630. AMBIENTDIRECTUV: number;
  39631. OPACITY: boolean;
  39632. OPACITYDIRECTUV: number;
  39633. OPACITYRGB: boolean;
  39634. REFLECTION: boolean;
  39635. EMISSIVE: boolean;
  39636. EMISSIVEDIRECTUV: number;
  39637. SPECULAR: boolean;
  39638. SPECULARDIRECTUV: number;
  39639. BUMP: boolean;
  39640. BUMPDIRECTUV: number;
  39641. PARALLAX: boolean;
  39642. PARALLAXOCCLUSION: boolean;
  39643. SPECULAROVERALPHA: boolean;
  39644. CLIPPLANE: boolean;
  39645. CLIPPLANE2: boolean;
  39646. CLIPPLANE3: boolean;
  39647. CLIPPLANE4: boolean;
  39648. ALPHATEST: boolean;
  39649. DEPTHPREPASS: boolean;
  39650. ALPHAFROMDIFFUSE: boolean;
  39651. POINTSIZE: boolean;
  39652. FOG: boolean;
  39653. SPECULARTERM: boolean;
  39654. DIFFUSEFRESNEL: boolean;
  39655. OPACITYFRESNEL: boolean;
  39656. REFLECTIONFRESNEL: boolean;
  39657. REFRACTIONFRESNEL: boolean;
  39658. EMISSIVEFRESNEL: boolean;
  39659. FRESNEL: boolean;
  39660. NORMAL: boolean;
  39661. UV1: boolean;
  39662. UV2: boolean;
  39663. VERTEXCOLOR: boolean;
  39664. VERTEXALPHA: boolean;
  39665. NUM_BONE_INFLUENCERS: number;
  39666. BonesPerMesh: number;
  39667. BONETEXTURE: boolean;
  39668. INSTANCES: boolean;
  39669. GLOSSINESS: boolean;
  39670. ROUGHNESS: boolean;
  39671. EMISSIVEASILLUMINATION: boolean;
  39672. LINKEMISSIVEWITHDIFFUSE: boolean;
  39673. REFLECTIONFRESNELFROMSPECULAR: boolean;
  39674. LIGHTMAP: boolean;
  39675. LIGHTMAPDIRECTUV: number;
  39676. OBJECTSPACE_NORMALMAP: boolean;
  39677. USELIGHTMAPASSHADOWMAP: boolean;
  39678. REFLECTIONMAP_3D: boolean;
  39679. REFLECTIONMAP_SPHERICAL: boolean;
  39680. REFLECTIONMAP_PLANAR: boolean;
  39681. REFLECTIONMAP_CUBIC: boolean;
  39682. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  39683. REFLECTIONMAP_PROJECTION: boolean;
  39684. REFLECTIONMAP_SKYBOX: boolean;
  39685. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  39686. REFLECTIONMAP_EXPLICIT: boolean;
  39687. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  39688. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  39689. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  39690. INVERTCUBICMAP: boolean;
  39691. LOGARITHMICDEPTH: boolean;
  39692. REFRACTION: boolean;
  39693. REFRACTIONMAP_3D: boolean;
  39694. REFLECTIONOVERALPHA: boolean;
  39695. TWOSIDEDLIGHTING: boolean;
  39696. SHADOWFLOAT: boolean;
  39697. MORPHTARGETS: boolean;
  39698. MORPHTARGETS_NORMAL: boolean;
  39699. MORPHTARGETS_TANGENT: boolean;
  39700. NUM_MORPH_INFLUENCERS: number;
  39701. NONUNIFORMSCALING: boolean;
  39702. PREMULTIPLYALPHA: boolean;
  39703. IMAGEPROCESSING: boolean;
  39704. VIGNETTE: boolean;
  39705. VIGNETTEBLENDMODEMULTIPLY: boolean;
  39706. VIGNETTEBLENDMODEOPAQUE: boolean;
  39707. TONEMAPPING: boolean;
  39708. TONEMAPPING_ACES: boolean;
  39709. CONTRAST: boolean;
  39710. COLORCURVES: boolean;
  39711. COLORGRADING: boolean;
  39712. COLORGRADING3D: boolean;
  39713. SAMPLER3DGREENDEPTH: boolean;
  39714. SAMPLER3DBGRMAP: boolean;
  39715. IMAGEPROCESSINGPOSTPROCESS: boolean;
  39716. MULTIVIEW: boolean;
  39717. /**
  39718. * If the reflection texture on this material is in linear color space
  39719. * @hidden
  39720. */
  39721. IS_REFLECTION_LINEAR: boolean;
  39722. /**
  39723. * If the refraction texture on this material is in linear color space
  39724. * @hidden
  39725. */
  39726. IS_REFRACTION_LINEAR: boolean;
  39727. EXPOSURE: boolean;
  39728. constructor();
  39729. setReflectionMode(modeToEnable: string): void;
  39730. }
  39731. /**
  39732. * This is the default material used in Babylon. It is the best trade off between quality
  39733. * and performances.
  39734. * @see http://doc.babylonjs.com/babylon101/materials
  39735. */
  39736. export class StandardMaterial extends PushMaterial {
  39737. private _diffuseTexture;
  39738. /**
  39739. * The basic texture of the material as viewed under a light.
  39740. */
  39741. diffuseTexture: Nullable<BaseTexture>;
  39742. private _ambientTexture;
  39743. /**
  39744. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  39745. */
  39746. ambientTexture: Nullable<BaseTexture>;
  39747. private _opacityTexture;
  39748. /**
  39749. * Define the transparency of the material from a texture.
  39750. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  39751. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  39752. */
  39753. opacityTexture: Nullable<BaseTexture>;
  39754. private _reflectionTexture;
  39755. /**
  39756. * Define the texture used to display the reflection.
  39757. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39758. */
  39759. reflectionTexture: Nullable<BaseTexture>;
  39760. private _emissiveTexture;
  39761. /**
  39762. * Define texture of the material as if self lit.
  39763. * This will be mixed in the final result even in the absence of light.
  39764. */
  39765. emissiveTexture: Nullable<BaseTexture>;
  39766. private _specularTexture;
  39767. /**
  39768. * Define how the color and intensity of the highlight given by the light in the material.
  39769. */
  39770. specularTexture: Nullable<BaseTexture>;
  39771. private _bumpTexture;
  39772. /**
  39773. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  39774. * 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.
  39775. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  39776. */
  39777. bumpTexture: Nullable<BaseTexture>;
  39778. private _lightmapTexture;
  39779. /**
  39780. * Complex lighting can be computationally expensive to compute at runtime.
  39781. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  39782. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  39783. */
  39784. lightmapTexture: Nullable<BaseTexture>;
  39785. private _refractionTexture;
  39786. /**
  39787. * Define the texture used to display the refraction.
  39788. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39789. */
  39790. refractionTexture: Nullable<BaseTexture>;
  39791. /**
  39792. * The color of the material lit by the environmental background lighting.
  39793. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  39794. */
  39795. ambientColor: Color3;
  39796. /**
  39797. * The basic color of the material as viewed under a light.
  39798. */
  39799. diffuseColor: Color3;
  39800. /**
  39801. * Define how the color and intensity of the highlight given by the light in the material.
  39802. */
  39803. specularColor: Color3;
  39804. /**
  39805. * Define the color of the material as if self lit.
  39806. * This will be mixed in the final result even in the absence of light.
  39807. */
  39808. emissiveColor: Color3;
  39809. /**
  39810. * Defines how sharp are the highlights in the material.
  39811. * The bigger the value the sharper giving a more glossy feeling to the result.
  39812. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  39813. */
  39814. specularPower: number;
  39815. private _useAlphaFromDiffuseTexture;
  39816. /**
  39817. * Does the transparency come from the diffuse texture alpha channel.
  39818. */
  39819. useAlphaFromDiffuseTexture: boolean;
  39820. private _useEmissiveAsIllumination;
  39821. /**
  39822. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  39823. */
  39824. useEmissiveAsIllumination: boolean;
  39825. private _linkEmissiveWithDiffuse;
  39826. /**
  39827. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  39828. * the emissive level when the final color is close to one.
  39829. */
  39830. linkEmissiveWithDiffuse: boolean;
  39831. private _useSpecularOverAlpha;
  39832. /**
  39833. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  39834. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  39835. */
  39836. useSpecularOverAlpha: boolean;
  39837. private _useReflectionOverAlpha;
  39838. /**
  39839. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  39840. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  39841. */
  39842. useReflectionOverAlpha: boolean;
  39843. private _disableLighting;
  39844. /**
  39845. * Does lights from the scene impacts this material.
  39846. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  39847. */
  39848. disableLighting: boolean;
  39849. private _useObjectSpaceNormalMap;
  39850. /**
  39851. * Allows using an object space normal map (instead of tangent space).
  39852. */
  39853. useObjectSpaceNormalMap: boolean;
  39854. private _useParallax;
  39855. /**
  39856. * Is parallax enabled or not.
  39857. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39858. */
  39859. useParallax: boolean;
  39860. private _useParallaxOcclusion;
  39861. /**
  39862. * Is parallax occlusion enabled or not.
  39863. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  39864. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  39865. */
  39866. useParallaxOcclusion: boolean;
  39867. /**
  39868. * 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.
  39869. */
  39870. parallaxScaleBias: number;
  39871. private _roughness;
  39872. /**
  39873. * Helps to define how blurry the reflections should appears in the material.
  39874. */
  39875. roughness: number;
  39876. /**
  39877. * In case of refraction, define the value of the indice of refraction.
  39878. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39879. */
  39880. indexOfRefraction: number;
  39881. /**
  39882. * Invert the refraction texture alongside the y axis.
  39883. * It can be useful with procedural textures or probe for instance.
  39884. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  39885. */
  39886. invertRefractionY: boolean;
  39887. /**
  39888. * Defines the alpha limits in alpha test mode.
  39889. */
  39890. alphaCutOff: number;
  39891. private _useLightmapAsShadowmap;
  39892. /**
  39893. * In case of light mapping, define whether the map contains light or shadow informations.
  39894. */
  39895. useLightmapAsShadowmap: boolean;
  39896. private _diffuseFresnelParameters;
  39897. /**
  39898. * Define the diffuse fresnel parameters of the material.
  39899. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39900. */
  39901. diffuseFresnelParameters: FresnelParameters;
  39902. private _opacityFresnelParameters;
  39903. /**
  39904. * Define the opacity fresnel parameters of the material.
  39905. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39906. */
  39907. opacityFresnelParameters: FresnelParameters;
  39908. private _reflectionFresnelParameters;
  39909. /**
  39910. * Define the reflection fresnel parameters of the material.
  39911. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39912. */
  39913. reflectionFresnelParameters: FresnelParameters;
  39914. private _refractionFresnelParameters;
  39915. /**
  39916. * Define the refraction fresnel parameters of the material.
  39917. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39918. */
  39919. refractionFresnelParameters: FresnelParameters;
  39920. private _emissiveFresnelParameters;
  39921. /**
  39922. * Define the emissive fresnel parameters of the material.
  39923. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39924. */
  39925. emissiveFresnelParameters: FresnelParameters;
  39926. private _useReflectionFresnelFromSpecular;
  39927. /**
  39928. * If true automatically deducts the fresnels values from the material specularity.
  39929. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  39930. */
  39931. useReflectionFresnelFromSpecular: boolean;
  39932. private _useGlossinessFromSpecularMapAlpha;
  39933. /**
  39934. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  39935. */
  39936. useGlossinessFromSpecularMapAlpha: boolean;
  39937. private _maxSimultaneousLights;
  39938. /**
  39939. * Defines the maximum number of lights that can be used in the material
  39940. */
  39941. maxSimultaneousLights: number;
  39942. private _invertNormalMapX;
  39943. /**
  39944. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  39945. */
  39946. invertNormalMapX: boolean;
  39947. private _invertNormalMapY;
  39948. /**
  39949. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  39950. */
  39951. invertNormalMapY: boolean;
  39952. private _twoSidedLighting;
  39953. /**
  39954. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  39955. */
  39956. twoSidedLighting: boolean;
  39957. /**
  39958. * Default configuration related to image processing available in the standard Material.
  39959. */
  39960. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  39961. /**
  39962. * Gets the image processing configuration used either in this material.
  39963. */
  39964. /**
  39965. * Sets the Default image processing configuration used either in the this material.
  39966. *
  39967. * If sets to null, the scene one is in use.
  39968. */
  39969. imageProcessingConfiguration: ImageProcessingConfiguration;
  39970. /**
  39971. * Keep track of the image processing observer to allow dispose and replace.
  39972. */
  39973. private _imageProcessingObserver;
  39974. /**
  39975. * Attaches a new image processing configuration to the Standard Material.
  39976. * @param configuration
  39977. */
  39978. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  39979. /**
  39980. * Gets wether the color curves effect is enabled.
  39981. */
  39982. /**
  39983. * Sets wether the color curves effect is enabled.
  39984. */
  39985. cameraColorCurvesEnabled: boolean;
  39986. /**
  39987. * Gets wether the color grading effect is enabled.
  39988. */
  39989. /**
  39990. * Gets wether the color grading effect is enabled.
  39991. */
  39992. cameraColorGradingEnabled: boolean;
  39993. /**
  39994. * Gets wether tonemapping is enabled or not.
  39995. */
  39996. /**
  39997. * Sets wether tonemapping is enabled or not
  39998. */
  39999. cameraToneMappingEnabled: boolean;
  40000. /**
  40001. * The camera exposure used on this material.
  40002. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40003. * This corresponds to a photographic exposure.
  40004. */
  40005. /**
  40006. * The camera exposure used on this material.
  40007. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  40008. * This corresponds to a photographic exposure.
  40009. */
  40010. cameraExposure: number;
  40011. /**
  40012. * Gets The camera contrast used on this material.
  40013. */
  40014. /**
  40015. * Sets The camera contrast used on this material.
  40016. */
  40017. cameraContrast: number;
  40018. /**
  40019. * Gets the Color Grading 2D Lookup Texture.
  40020. */
  40021. /**
  40022. * Sets the Color Grading 2D Lookup Texture.
  40023. */
  40024. cameraColorGradingTexture: Nullable<BaseTexture>;
  40025. /**
  40026. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40027. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40028. * 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;
  40029. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40030. */
  40031. /**
  40032. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  40033. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  40034. * 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;
  40035. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  40036. */
  40037. cameraColorCurves: Nullable<ColorCurves>;
  40038. /**
  40039. * Custom callback helping to override the default shader used in the material.
  40040. */
  40041. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  40042. protected _renderTargets: SmartArray<RenderTargetTexture>;
  40043. protected _worldViewProjectionMatrix: Matrix;
  40044. protected _globalAmbientColor: Color3;
  40045. protected _useLogarithmicDepth: boolean;
  40046. /**
  40047. * Instantiates a new standard material.
  40048. * This is the default material used in Babylon. It is the best trade off between quality
  40049. * and performances.
  40050. * @see http://doc.babylonjs.com/babylon101/materials
  40051. * @param name Define the name of the material in the scene
  40052. * @param scene Define the scene the material belong to
  40053. */
  40054. constructor(name: string, scene: Scene);
  40055. /**
  40056. * Gets a boolean indicating that current material needs to register RTT
  40057. */
  40058. readonly hasRenderTargetTextures: boolean;
  40059. /**
  40060. * Gets the current class name of the material e.g. "StandardMaterial"
  40061. * Mainly use in serialization.
  40062. * @returns the class name
  40063. */
  40064. getClassName(): string;
  40065. /**
  40066. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  40067. * You can try switching to logarithmic depth.
  40068. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  40069. */
  40070. useLogarithmicDepth: boolean;
  40071. /**
  40072. * Specifies if the material will require alpha blending
  40073. * @returns a boolean specifying if alpha blending is needed
  40074. */
  40075. needAlphaBlending(): boolean;
  40076. /**
  40077. * Specifies if this material should be rendered in alpha test mode
  40078. * @returns a boolean specifying if an alpha test is needed.
  40079. */
  40080. needAlphaTesting(): boolean;
  40081. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  40082. /**
  40083. * Get the texture used for alpha test purpose.
  40084. * @returns the diffuse texture in case of the standard material.
  40085. */
  40086. getAlphaTestTexture(): Nullable<BaseTexture>;
  40087. /**
  40088. * Get if the submesh is ready to be used and all its information available.
  40089. * Child classes can use it to update shaders
  40090. * @param mesh defines the mesh to check
  40091. * @param subMesh defines which submesh to check
  40092. * @param useInstances specifies that instances should be used
  40093. * @returns a boolean indicating that the submesh is ready or not
  40094. */
  40095. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  40096. /**
  40097. * Builds the material UBO layouts.
  40098. * Used internally during the effect preparation.
  40099. */
  40100. buildUniformLayout(): void;
  40101. /**
  40102. * Unbinds the material from the mesh
  40103. */
  40104. unbind(): void;
  40105. /**
  40106. * Binds the submesh to this material by preparing the effect and shader to draw
  40107. * @param world defines the world transformation matrix
  40108. * @param mesh defines the mesh containing the submesh
  40109. * @param subMesh defines the submesh to bind the material to
  40110. */
  40111. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  40112. /**
  40113. * Get the list of animatables in the material.
  40114. * @returns the list of animatables object used in the material
  40115. */
  40116. getAnimatables(): IAnimatable[];
  40117. /**
  40118. * Gets the active textures from the material
  40119. * @returns an array of textures
  40120. */
  40121. getActiveTextures(): BaseTexture[];
  40122. /**
  40123. * Specifies if the material uses a texture
  40124. * @param texture defines the texture to check against the material
  40125. * @returns a boolean specifying if the material uses the texture
  40126. */
  40127. hasTexture(texture: BaseTexture): boolean;
  40128. /**
  40129. * Disposes the material
  40130. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  40131. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  40132. */
  40133. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  40134. /**
  40135. * Makes a duplicate of the material, and gives it a new name
  40136. * @param name defines the new name for the duplicated material
  40137. * @returns the cloned material
  40138. */
  40139. clone(name: string): StandardMaterial;
  40140. /**
  40141. * Serializes this material in a JSON representation
  40142. * @returns the serialized material object
  40143. */
  40144. serialize(): any;
  40145. /**
  40146. * Creates a standard material from parsed material data
  40147. * @param source defines the JSON representation of the material
  40148. * @param scene defines the hosting scene
  40149. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  40150. * @returns a new standard material
  40151. */
  40152. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  40153. /**
  40154. * Are diffuse textures enabled in the application.
  40155. */
  40156. static DiffuseTextureEnabled: boolean;
  40157. /**
  40158. * Are ambient textures enabled in the application.
  40159. */
  40160. static AmbientTextureEnabled: boolean;
  40161. /**
  40162. * Are opacity textures enabled in the application.
  40163. */
  40164. static OpacityTextureEnabled: boolean;
  40165. /**
  40166. * Are reflection textures enabled in the application.
  40167. */
  40168. static ReflectionTextureEnabled: boolean;
  40169. /**
  40170. * Are emissive textures enabled in the application.
  40171. */
  40172. static EmissiveTextureEnabled: boolean;
  40173. /**
  40174. * Are specular textures enabled in the application.
  40175. */
  40176. static SpecularTextureEnabled: boolean;
  40177. /**
  40178. * Are bump textures enabled in the application.
  40179. */
  40180. static BumpTextureEnabled: boolean;
  40181. /**
  40182. * Are lightmap textures enabled in the application.
  40183. */
  40184. static LightmapTextureEnabled: boolean;
  40185. /**
  40186. * Are refraction textures enabled in the application.
  40187. */
  40188. static RefractionTextureEnabled: boolean;
  40189. /**
  40190. * Are color grading textures enabled in the application.
  40191. */
  40192. static ColorGradingTextureEnabled: boolean;
  40193. /**
  40194. * Are fresnels enabled in the application.
  40195. */
  40196. static FresnelEnabled: boolean;
  40197. }
  40198. }
  40199. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  40200. import { Scene } from "babylonjs/scene";
  40201. import { Texture } from "babylonjs/Materials/Textures/texture";
  40202. /**
  40203. * A class extending Texture allowing drawing on a texture
  40204. * @see http://doc.babylonjs.com/how_to/dynamictexture
  40205. */
  40206. export class DynamicTexture extends Texture {
  40207. private _generateMipMaps;
  40208. private _canvas;
  40209. private _context;
  40210. private _engine;
  40211. /**
  40212. * Creates a DynamicTexture
  40213. * @param name defines the name of the texture
  40214. * @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
  40215. * @param scene defines the scene where you want the texture
  40216. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  40217. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  40218. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  40219. */
  40220. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  40221. /**
  40222. * Get the current class name of the texture useful for serialization or dynamic coding.
  40223. * @returns "DynamicTexture"
  40224. */
  40225. getClassName(): string;
  40226. /**
  40227. * Gets the current state of canRescale
  40228. */
  40229. readonly canRescale: boolean;
  40230. private _recreate;
  40231. /**
  40232. * Scales the texture
  40233. * @param ratio the scale factor to apply to both width and height
  40234. */
  40235. scale(ratio: number): void;
  40236. /**
  40237. * Resizes the texture
  40238. * @param width the new width
  40239. * @param height the new height
  40240. */
  40241. scaleTo(width: number, height: number): void;
  40242. /**
  40243. * Gets the context of the canvas used by the texture
  40244. * @returns the canvas context of the dynamic texture
  40245. */
  40246. getContext(): CanvasRenderingContext2D;
  40247. /**
  40248. * Clears the texture
  40249. */
  40250. clear(): void;
  40251. /**
  40252. * Updates the texture
  40253. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40254. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  40255. */
  40256. update(invertY?: boolean, premulAlpha?: boolean): void;
  40257. /**
  40258. * Draws text onto the texture
  40259. * @param text defines the text to be drawn
  40260. * @param x defines the placement of the text from the left
  40261. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  40262. * @param font defines the font to be used with font-style, font-size, font-name
  40263. * @param color defines the color used for the text
  40264. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  40265. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  40266. * @param update defines whether texture is immediately update (default is true)
  40267. */
  40268. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  40269. /**
  40270. * Clones the texture
  40271. * @returns the clone of the texture.
  40272. */
  40273. clone(): DynamicTexture;
  40274. /**
  40275. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  40276. * @returns a serialized dynamic texture object
  40277. */
  40278. serialize(): any;
  40279. /** @hidden */
  40280. _rebuild(): void;
  40281. }
  40282. }
  40283. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  40284. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  40285. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  40286. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  40287. /** @hidden */
  40288. export var imageProcessingPixelShader: {
  40289. name: string;
  40290. shader: string;
  40291. };
  40292. }
  40293. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  40294. import { Nullable } from "babylonjs/types";
  40295. import { Color4 } from "babylonjs/Maths/math";
  40296. import { Camera } from "babylonjs/Cameras/camera";
  40297. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40298. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  40299. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40300. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  40301. import { Engine } from "babylonjs/Engines/engine";
  40302. import "babylonjs/Shaders/imageProcessing.fragment";
  40303. import "babylonjs/Shaders/postprocess.vertex";
  40304. /**
  40305. * ImageProcessingPostProcess
  40306. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  40307. */
  40308. export class ImageProcessingPostProcess extends PostProcess {
  40309. /**
  40310. * Default configuration related to image processing available in the PBR Material.
  40311. */
  40312. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  40313. /**
  40314. * Gets the image processing configuration used either in this material.
  40315. */
  40316. /**
  40317. * Sets the Default image processing configuration used either in the this material.
  40318. *
  40319. * If sets to null, the scene one is in use.
  40320. */
  40321. imageProcessingConfiguration: ImageProcessingConfiguration;
  40322. /**
  40323. * Keep track of the image processing observer to allow dispose and replace.
  40324. */
  40325. private _imageProcessingObserver;
  40326. /**
  40327. * Attaches a new image processing configuration to the PBR Material.
  40328. * @param configuration
  40329. */
  40330. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  40331. /**
  40332. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40333. */
  40334. /**
  40335. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  40336. */
  40337. colorCurves: Nullable<ColorCurves>;
  40338. /**
  40339. * Gets wether the color curves effect is enabled.
  40340. */
  40341. /**
  40342. * Sets wether the color curves effect is enabled.
  40343. */
  40344. colorCurvesEnabled: boolean;
  40345. /**
  40346. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40347. */
  40348. /**
  40349. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  40350. */
  40351. colorGradingTexture: Nullable<BaseTexture>;
  40352. /**
  40353. * Gets wether the color grading effect is enabled.
  40354. */
  40355. /**
  40356. * Gets wether the color grading effect is enabled.
  40357. */
  40358. colorGradingEnabled: boolean;
  40359. /**
  40360. * Gets exposure used in the effect.
  40361. */
  40362. /**
  40363. * Sets exposure used in the effect.
  40364. */
  40365. exposure: number;
  40366. /**
  40367. * Gets wether tonemapping is enabled or not.
  40368. */
  40369. /**
  40370. * Sets wether tonemapping is enabled or not
  40371. */
  40372. toneMappingEnabled: boolean;
  40373. /**
  40374. * Gets the type of tone mapping effect.
  40375. */
  40376. /**
  40377. * Sets the type of tone mapping effect.
  40378. */
  40379. toneMappingType: number;
  40380. /**
  40381. * Gets contrast used in the effect.
  40382. */
  40383. /**
  40384. * Sets contrast used in the effect.
  40385. */
  40386. contrast: number;
  40387. /**
  40388. * Gets Vignette stretch size.
  40389. */
  40390. /**
  40391. * Sets Vignette stretch size.
  40392. */
  40393. vignetteStretch: number;
  40394. /**
  40395. * Gets Vignette centre X Offset.
  40396. */
  40397. /**
  40398. * Sets Vignette centre X Offset.
  40399. */
  40400. vignetteCentreX: number;
  40401. /**
  40402. * Gets Vignette centre Y Offset.
  40403. */
  40404. /**
  40405. * Sets Vignette centre Y Offset.
  40406. */
  40407. vignetteCentreY: number;
  40408. /**
  40409. * Gets Vignette weight or intensity of the vignette effect.
  40410. */
  40411. /**
  40412. * Sets Vignette weight or intensity of the vignette effect.
  40413. */
  40414. vignetteWeight: number;
  40415. /**
  40416. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40417. * if vignetteEnabled is set to true.
  40418. */
  40419. /**
  40420. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  40421. * if vignetteEnabled is set to true.
  40422. */
  40423. vignetteColor: Color4;
  40424. /**
  40425. * Gets Camera field of view used by the Vignette effect.
  40426. */
  40427. /**
  40428. * Sets Camera field of view used by the Vignette effect.
  40429. */
  40430. vignetteCameraFov: number;
  40431. /**
  40432. * Gets the vignette blend mode allowing different kind of effect.
  40433. */
  40434. /**
  40435. * Sets the vignette blend mode allowing different kind of effect.
  40436. */
  40437. vignetteBlendMode: number;
  40438. /**
  40439. * Gets wether the vignette effect is enabled.
  40440. */
  40441. /**
  40442. * Sets wether the vignette effect is enabled.
  40443. */
  40444. vignetteEnabled: boolean;
  40445. private _fromLinearSpace;
  40446. /**
  40447. * Gets wether the input of the processing is in Gamma or Linear Space.
  40448. */
  40449. /**
  40450. * Sets wether the input of the processing is in Gamma or Linear Space.
  40451. */
  40452. fromLinearSpace: boolean;
  40453. /**
  40454. * Defines cache preventing GC.
  40455. */
  40456. private _defines;
  40457. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  40458. /**
  40459. * "ImageProcessingPostProcess"
  40460. * @returns "ImageProcessingPostProcess"
  40461. */
  40462. getClassName(): string;
  40463. protected _updateParameters(): void;
  40464. dispose(camera?: Camera): void;
  40465. }
  40466. }
  40467. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  40468. import { Scene } from "babylonjs/scene";
  40469. import { Color3 } from "babylonjs/Maths/math";
  40470. import { Mesh } from "babylonjs/Meshes/mesh";
  40471. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  40472. import { Nullable } from "babylonjs/types";
  40473. /**
  40474. * Class containing static functions to help procedurally build meshes
  40475. */
  40476. export class GroundBuilder {
  40477. /**
  40478. * Creates a ground mesh
  40479. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  40480. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  40481. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  40482. * @param name defines the name of the mesh
  40483. * @param options defines the options used to create the mesh
  40484. * @param scene defines the hosting scene
  40485. * @returns the ground mesh
  40486. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  40487. */
  40488. static CreateGround(name: string, options: {
  40489. width?: number;
  40490. height?: number;
  40491. subdivisions?: number;
  40492. subdivisionsX?: number;
  40493. subdivisionsY?: number;
  40494. updatable?: boolean;
  40495. }, scene: any): Mesh;
  40496. /**
  40497. * Creates a tiled ground mesh
  40498. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  40499. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  40500. * * 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
  40501. * * 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
  40502. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40503. * @param name defines the name of the mesh
  40504. * @param options defines the options used to create the mesh
  40505. * @param scene defines the hosting scene
  40506. * @returns the tiled ground mesh
  40507. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  40508. */
  40509. static CreateTiledGround(name: string, options: {
  40510. xmin: number;
  40511. zmin: number;
  40512. xmax: number;
  40513. zmax: number;
  40514. subdivisions?: {
  40515. w: number;
  40516. h: number;
  40517. };
  40518. precision?: {
  40519. w: number;
  40520. h: number;
  40521. };
  40522. updatable?: boolean;
  40523. }, scene?: Nullable<Scene>): Mesh;
  40524. /**
  40525. * Creates a ground mesh from a height map
  40526. * * The parameter `url` sets the URL of the height map image resource.
  40527. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  40528. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  40529. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  40530. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  40531. * * 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.
  40532. * * 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).
  40533. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  40534. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40535. * @param name defines the name of the mesh
  40536. * @param url defines the url to the height map
  40537. * @param options defines the options used to create the mesh
  40538. * @param scene defines the hosting scene
  40539. * @returns the ground mesh
  40540. * @see https://doc.babylonjs.com/babylon101/height_map
  40541. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  40542. */
  40543. static CreateGroundFromHeightMap(name: string, url: string, options: {
  40544. width?: number;
  40545. height?: number;
  40546. subdivisions?: number;
  40547. minHeight?: number;
  40548. maxHeight?: number;
  40549. colorFilter?: Color3;
  40550. alphaFilter?: number;
  40551. updatable?: boolean;
  40552. onReady?: (mesh: GroundMesh) => void;
  40553. }, scene?: Nullable<Scene>): GroundMesh;
  40554. }
  40555. }
  40556. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  40557. import { Vector4 } from "babylonjs/Maths/math";
  40558. import { Mesh } from "babylonjs/Meshes/mesh";
  40559. /**
  40560. * Class containing static functions to help procedurally build meshes
  40561. */
  40562. export class TorusBuilder {
  40563. /**
  40564. * Creates a torus mesh
  40565. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  40566. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  40567. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  40568. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40569. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40570. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40571. * @param name defines the name of the mesh
  40572. * @param options defines the options used to create the mesh
  40573. * @param scene defines the hosting scene
  40574. * @returns the torus mesh
  40575. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  40576. */
  40577. static CreateTorus(name: string, options: {
  40578. diameter?: number;
  40579. thickness?: number;
  40580. tessellation?: number;
  40581. updatable?: boolean;
  40582. sideOrientation?: number;
  40583. frontUVs?: Vector4;
  40584. backUVs?: Vector4;
  40585. }, scene: any): Mesh;
  40586. }
  40587. }
  40588. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  40589. import { Color4, Vector4 } from "babylonjs/Maths/math";
  40590. import { Mesh } from "babylonjs/Meshes/mesh";
  40591. /**
  40592. * Class containing static functions to help procedurally build meshes
  40593. */
  40594. export class CylinderBuilder {
  40595. /**
  40596. * Creates a cylinder or a cone mesh
  40597. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  40598. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  40599. * * 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.
  40600. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  40601. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  40602. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  40603. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  40604. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  40605. * * 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).
  40606. * * 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
  40607. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  40608. * * 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
  40609. * * 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.
  40610. * * If `enclose` is false, a ring surface is one element.
  40611. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  40612. * * 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
  40613. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  40614. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  40615. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  40616. * @param name defines the name of the mesh
  40617. * @param options defines the options used to create the mesh
  40618. * @param scene defines the hosting scene
  40619. * @returns the cylinder mesh
  40620. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  40621. */
  40622. static CreateCylinder(name: string, options: {
  40623. height?: number;
  40624. diameterTop?: number;
  40625. diameterBottom?: number;
  40626. diameter?: number;
  40627. tessellation?: number;
  40628. subdivisions?: number;
  40629. arc?: number;
  40630. faceColors?: Color4[];
  40631. faceUV?: Vector4[];
  40632. updatable?: boolean;
  40633. hasRings?: boolean;
  40634. enclose?: boolean;
  40635. sideOrientation?: number;
  40636. frontUVs?: Vector4;
  40637. backUVs?: Vector4;
  40638. }, scene: any): Mesh;
  40639. }
  40640. }
  40641. declare module "babylonjs/Gamepads/gamepadManager" {
  40642. import { Observable } from "babylonjs/Misc/observable";
  40643. import { Nullable } from "babylonjs/types";
  40644. import { Scene } from "babylonjs/scene";
  40645. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  40646. /**
  40647. * Manager for handling gamepads
  40648. */
  40649. export class GamepadManager {
  40650. private _scene?;
  40651. private _babylonGamepads;
  40652. private _oneGamepadConnected;
  40653. /** @hidden */
  40654. _isMonitoring: boolean;
  40655. private _gamepadEventSupported;
  40656. private _gamepadSupport;
  40657. /**
  40658. * observable to be triggered when the gamepad controller has been connected
  40659. */
  40660. onGamepadConnectedObservable: Observable<Gamepad>;
  40661. /**
  40662. * observable to be triggered when the gamepad controller has been disconnected
  40663. */
  40664. onGamepadDisconnectedObservable: Observable<Gamepad>;
  40665. private _onGamepadConnectedEvent;
  40666. private _onGamepadDisconnectedEvent;
  40667. /**
  40668. * Initializes the gamepad manager
  40669. * @param _scene BabylonJS scene
  40670. */
  40671. constructor(_scene?: Scene | undefined);
  40672. /**
  40673. * The gamepads in the game pad manager
  40674. */
  40675. readonly gamepads: Gamepad[];
  40676. /**
  40677. * Get the gamepad controllers based on type
  40678. * @param type The type of gamepad controller
  40679. * @returns Nullable gamepad
  40680. */
  40681. getGamepadByType(type?: number): Nullable<Gamepad>;
  40682. /**
  40683. * Disposes the gamepad manager
  40684. */
  40685. dispose(): void;
  40686. private _addNewGamepad;
  40687. private _startMonitoringGamepads;
  40688. private _stopMonitoringGamepads;
  40689. /** @hidden */
  40690. _checkGamepadsStatus(): void;
  40691. private _updateGamepadObjects;
  40692. }
  40693. }
  40694. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  40695. import { Nullable } from "babylonjs/types";
  40696. import { Scene } from "babylonjs/scene";
  40697. import { ISceneComponent } from "babylonjs/sceneComponent";
  40698. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  40699. module "babylonjs/scene" {
  40700. interface Scene {
  40701. /** @hidden */
  40702. _gamepadManager: Nullable<GamepadManager>;
  40703. /**
  40704. * Gets the gamepad manager associated with the scene
  40705. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  40706. */
  40707. gamepadManager: GamepadManager;
  40708. }
  40709. }
  40710. module "babylonjs/Cameras/freeCameraInputsManager" {
  40711. /**
  40712. * Interface representing a free camera inputs manager
  40713. */
  40714. interface FreeCameraInputsManager {
  40715. /**
  40716. * Adds gamepad input support to the FreeCameraInputsManager.
  40717. * @returns the FreeCameraInputsManager
  40718. */
  40719. addGamepad(): FreeCameraInputsManager;
  40720. }
  40721. }
  40722. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  40723. /**
  40724. * Interface representing an arc rotate camera inputs manager
  40725. */
  40726. interface ArcRotateCameraInputsManager {
  40727. /**
  40728. * Adds gamepad input support to the ArcRotateCamera InputManager.
  40729. * @returns the camera inputs manager
  40730. */
  40731. addGamepad(): ArcRotateCameraInputsManager;
  40732. }
  40733. }
  40734. /**
  40735. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  40736. */
  40737. export class GamepadSystemSceneComponent implements ISceneComponent {
  40738. /**
  40739. * The component name helpfull to identify the component in the list of scene components.
  40740. */
  40741. readonly name: string;
  40742. /**
  40743. * The scene the component belongs to.
  40744. */
  40745. scene: Scene;
  40746. /**
  40747. * Creates a new instance of the component for the given scene
  40748. * @param scene Defines the scene to register the component in
  40749. */
  40750. constructor(scene: Scene);
  40751. /**
  40752. * Registers the component in a given scene
  40753. */
  40754. register(): void;
  40755. /**
  40756. * Rebuilds the elements related to this component in case of
  40757. * context lost for instance.
  40758. */
  40759. rebuild(): void;
  40760. /**
  40761. * Disposes the component and the associated ressources
  40762. */
  40763. dispose(): void;
  40764. private _beforeCameraUpdate;
  40765. }
  40766. }
  40767. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  40768. import { Observable } from "babylonjs/Misc/observable";
  40769. import { Nullable } from "babylonjs/types";
  40770. import { Camera } from "babylonjs/Cameras/camera";
  40771. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  40772. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  40773. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  40774. import { Scene } from "babylonjs/scene";
  40775. import { Vector3, Color3 } from "babylonjs/Maths/math";
  40776. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  40777. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40778. import { Mesh } from "babylonjs/Meshes/mesh";
  40779. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40780. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  40781. import "babylonjs/Meshes/Builders/groundBuilder";
  40782. import "babylonjs/Meshes/Builders/torusBuilder";
  40783. import "babylonjs/Meshes/Builders/cylinderBuilder";
  40784. import "babylonjs/Gamepads/gamepadSceneComponent";
  40785. import "babylonjs/Animations/animatable";
  40786. /**
  40787. * Options to modify the vr teleportation behavior.
  40788. */
  40789. export interface VRTeleportationOptions {
  40790. /**
  40791. * The name of the mesh which should be used as the teleportation floor. (default: null)
  40792. */
  40793. floorMeshName?: string;
  40794. /**
  40795. * A list of meshes to be used as the teleportation floor. (default: empty)
  40796. */
  40797. floorMeshes?: Mesh[];
  40798. }
  40799. /**
  40800. * Options to modify the vr experience helper's behavior.
  40801. */
  40802. export interface VRExperienceHelperOptions extends WebVROptions {
  40803. /**
  40804. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  40805. */
  40806. createDeviceOrientationCamera?: boolean;
  40807. /**
  40808. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  40809. */
  40810. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  40811. /**
  40812. * Uses the main button on the controller to toggle the laser casted. (default: true)
  40813. */
  40814. laserToggle?: boolean;
  40815. /**
  40816. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  40817. */
  40818. floorMeshes?: Mesh[];
  40819. /**
  40820. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  40821. */
  40822. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  40823. }
  40824. /**
  40825. * Event containing information after VR has been entered
  40826. */
  40827. export class OnAfterEnteringVRObservableEvent {
  40828. /**
  40829. * If entering vr was successful
  40830. */
  40831. success: boolean;
  40832. }
  40833. /**
  40834. * Helps to quickly add VR support to an existing scene.
  40835. * See http://doc.babylonjs.com/how_to/webvr_helper
  40836. */
  40837. export class VRExperienceHelper {
  40838. /** Options to modify the vr experience helper's behavior. */
  40839. webVROptions: VRExperienceHelperOptions;
  40840. private _scene;
  40841. private _position;
  40842. private _btnVR;
  40843. private _btnVRDisplayed;
  40844. private _webVRsupported;
  40845. private _webVRready;
  40846. private _webVRrequesting;
  40847. private _webVRpresenting;
  40848. private _hasEnteredVR;
  40849. private _fullscreenVRpresenting;
  40850. private _canvas;
  40851. private _webVRCamera;
  40852. private _vrDeviceOrientationCamera;
  40853. private _deviceOrientationCamera;
  40854. private _existingCamera;
  40855. private _onKeyDown;
  40856. private _onVrDisplayPresentChange;
  40857. private _onVRDisplayChanged;
  40858. private _onVRRequestPresentStart;
  40859. private _onVRRequestPresentComplete;
  40860. /**
  40861. * Observable raised right before entering VR.
  40862. */
  40863. onEnteringVRObservable: Observable<VRExperienceHelper>;
  40864. /**
  40865. * Observable raised when entering VR has completed.
  40866. */
  40867. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  40868. /**
  40869. * Observable raised when exiting VR.
  40870. */
  40871. onExitingVRObservable: Observable<VRExperienceHelper>;
  40872. /**
  40873. * Observable raised when controller mesh is loaded.
  40874. */
  40875. onControllerMeshLoadedObservable: Observable<WebVRController>;
  40876. /** Return this.onEnteringVRObservable
  40877. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  40878. */
  40879. readonly onEnteringVR: Observable<VRExperienceHelper>;
  40880. /** Return this.onExitingVRObservable
  40881. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  40882. */
  40883. readonly onExitingVR: Observable<VRExperienceHelper>;
  40884. /** Return this.onControllerMeshLoadedObservable
  40885. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  40886. */
  40887. readonly onControllerMeshLoaded: Observable<WebVRController>;
  40888. private _rayLength;
  40889. private _useCustomVRButton;
  40890. private _teleportationRequested;
  40891. private _teleportActive;
  40892. private _floorMeshName;
  40893. private _floorMeshesCollection;
  40894. private _rotationAllowed;
  40895. private _teleportBackwardsVector;
  40896. private _teleportationTarget;
  40897. private _isDefaultTeleportationTarget;
  40898. private _postProcessMove;
  40899. private _teleportationFillColor;
  40900. private _teleportationBorderColor;
  40901. private _rotationAngle;
  40902. private _haloCenter;
  40903. private _cameraGazer;
  40904. private _padSensibilityUp;
  40905. private _padSensibilityDown;
  40906. private _leftController;
  40907. private _rightController;
  40908. /**
  40909. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  40910. */
  40911. onNewMeshSelected: Observable<AbstractMesh>;
  40912. /**
  40913. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  40914. */
  40915. onNewMeshPicked: Observable<PickingInfo>;
  40916. private _circleEase;
  40917. /**
  40918. * Observable raised before camera teleportation
  40919. */
  40920. onBeforeCameraTeleport: Observable<Vector3>;
  40921. /**
  40922. * Observable raised after camera teleportation
  40923. */
  40924. onAfterCameraTeleport: Observable<Vector3>;
  40925. /**
  40926. * Observable raised when current selected mesh gets unselected
  40927. */
  40928. onSelectedMeshUnselected: Observable<AbstractMesh>;
  40929. private _raySelectionPredicate;
  40930. /**
  40931. * To be optionaly changed by user to define custom ray selection
  40932. */
  40933. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  40934. /**
  40935. * To be optionaly changed by user to define custom selection logic (after ray selection)
  40936. */
  40937. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  40938. /**
  40939. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  40940. */
  40941. teleportationEnabled: boolean;
  40942. private _defaultHeight;
  40943. private _teleportationInitialized;
  40944. private _interactionsEnabled;
  40945. private _interactionsRequested;
  40946. private _displayGaze;
  40947. private _displayLaserPointer;
  40948. /**
  40949. * The mesh used to display where the user is going to teleport.
  40950. */
  40951. /**
  40952. * Sets the mesh to be used to display where the user is going to teleport.
  40953. */
  40954. teleportationTarget: Mesh;
  40955. /**
  40956. * 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
  40957. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  40958. * See http://doc.babylonjs.com/resources/baking_transformations
  40959. */
  40960. gazeTrackerMesh: Mesh;
  40961. /**
  40962. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  40963. */
  40964. updateGazeTrackerScale: boolean;
  40965. /**
  40966. * If the gaze trackers color should be updated when selecting meshes
  40967. */
  40968. updateGazeTrackerColor: boolean;
  40969. /**
  40970. * The gaze tracking mesh corresponding to the left controller
  40971. */
  40972. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  40973. /**
  40974. * The gaze tracking mesh corresponding to the right controller
  40975. */
  40976. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  40977. /**
  40978. * If the ray of the gaze should be displayed.
  40979. */
  40980. /**
  40981. * Sets if the ray of the gaze should be displayed.
  40982. */
  40983. displayGaze: boolean;
  40984. /**
  40985. * If the ray of the LaserPointer should be displayed.
  40986. */
  40987. /**
  40988. * Sets if the ray of the LaserPointer should be displayed.
  40989. */
  40990. displayLaserPointer: boolean;
  40991. /**
  40992. * The deviceOrientationCamera used as the camera when not in VR.
  40993. */
  40994. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  40995. /**
  40996. * Based on the current WebVR support, returns the current VR camera used.
  40997. */
  40998. readonly currentVRCamera: Nullable<Camera>;
  40999. /**
  41000. * The webVRCamera which is used when in VR.
  41001. */
  41002. readonly webVRCamera: WebVRFreeCamera;
  41003. /**
  41004. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  41005. */
  41006. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  41007. private readonly _teleportationRequestInitiated;
  41008. /**
  41009. * Defines wether or not Pointer lock should be requested when switching to
  41010. * full screen.
  41011. */
  41012. requestPointerLockOnFullScreen: boolean;
  41013. /**
  41014. * Instantiates a VRExperienceHelper.
  41015. * Helps to quickly add VR support to an existing scene.
  41016. * @param scene The scene the VRExperienceHelper belongs to.
  41017. * @param webVROptions Options to modify the vr experience helper's behavior.
  41018. */
  41019. constructor(scene: Scene,
  41020. /** Options to modify the vr experience helper's behavior. */
  41021. webVROptions?: VRExperienceHelperOptions);
  41022. private _onDefaultMeshLoaded;
  41023. private _onResize;
  41024. private _onFullscreenChange;
  41025. /**
  41026. * Gets a value indicating if we are currently in VR mode.
  41027. */
  41028. readonly isInVRMode: boolean;
  41029. private onVrDisplayPresentChange;
  41030. private onVRDisplayChanged;
  41031. private moveButtonToBottomRight;
  41032. private displayVRButton;
  41033. private updateButtonVisibility;
  41034. private _cachedAngularSensibility;
  41035. /**
  41036. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  41037. * Otherwise, will use the fullscreen API.
  41038. */
  41039. enterVR(): void;
  41040. /**
  41041. * Attempt to exit VR, or fullscreen.
  41042. */
  41043. exitVR(): void;
  41044. /**
  41045. * The position of the vr experience helper.
  41046. */
  41047. /**
  41048. * Sets the position of the vr experience helper.
  41049. */
  41050. position: Vector3;
  41051. /**
  41052. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  41053. */
  41054. enableInteractions(): void;
  41055. private readonly _noControllerIsActive;
  41056. private beforeRender;
  41057. private _isTeleportationFloor;
  41058. /**
  41059. * Adds a floor mesh to be used for teleportation.
  41060. * @param floorMesh the mesh to be used for teleportation.
  41061. */
  41062. addFloorMesh(floorMesh: Mesh): void;
  41063. /**
  41064. * Removes a floor mesh from being used for teleportation.
  41065. * @param floorMesh the mesh to be removed.
  41066. */
  41067. removeFloorMesh(floorMesh: Mesh): void;
  41068. /**
  41069. * Enables interactions and teleportation using the VR controllers and gaze.
  41070. * @param vrTeleportationOptions options to modify teleportation behavior.
  41071. */
  41072. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  41073. private _onNewGamepadConnected;
  41074. private _tryEnableInteractionOnController;
  41075. private _onNewGamepadDisconnected;
  41076. private _enableInteractionOnController;
  41077. private _checkTeleportWithRay;
  41078. private _checkRotate;
  41079. private _checkTeleportBackwards;
  41080. private _enableTeleportationOnController;
  41081. private _createTeleportationCircles;
  41082. private _displayTeleportationTarget;
  41083. private _hideTeleportationTarget;
  41084. private _rotateCamera;
  41085. private _moveTeleportationSelectorTo;
  41086. private _workingVector;
  41087. private _workingQuaternion;
  41088. private _workingMatrix;
  41089. /**
  41090. * Teleports the users feet to the desired location
  41091. * @param location The location where the user's feet should be placed
  41092. */
  41093. teleportCamera(location: Vector3): void;
  41094. private _convertNormalToDirectionOfRay;
  41095. private _castRayAndSelectObject;
  41096. private _notifySelectedMeshUnselected;
  41097. /**
  41098. * Sets the color of the laser ray from the vr controllers.
  41099. * @param color new color for the ray.
  41100. */
  41101. changeLaserColor(color: Color3): void;
  41102. /**
  41103. * Sets the color of the ray from the vr headsets gaze.
  41104. * @param color new color for the ray.
  41105. */
  41106. changeGazeColor(color: Color3): void;
  41107. /**
  41108. * Exits VR and disposes of the vr experience helper
  41109. */
  41110. dispose(): void;
  41111. /**
  41112. * Gets the name of the VRExperienceHelper class
  41113. * @returns "VRExperienceHelper"
  41114. */
  41115. getClassName(): string;
  41116. }
  41117. }
  41118. declare module "babylonjs/Cameras/VR/index" {
  41119. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  41120. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  41121. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  41122. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  41123. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  41124. export * from "babylonjs/Cameras/VR/webVRCamera";
  41125. }
  41126. declare module "babylonjs/Cameras/XR/webXRSessionManager" {
  41127. import { Observable } from "babylonjs/Misc/observable";
  41128. import { Nullable } from "babylonjs/types";
  41129. import { IDisposable, Scene } from "babylonjs/scene";
  41130. import { Vector3 } from "babylonjs/Maths/math";
  41131. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  41132. import { Ray } from "babylonjs/Culling/ray";
  41133. /**
  41134. * Manages an XRSession
  41135. * @see https://doc.babylonjs.com/how_to/webxr
  41136. */
  41137. export class WebXRSessionManager implements IDisposable {
  41138. private scene;
  41139. /**
  41140. * Fires every time a new xrFrame arrives which can be used to update the camera
  41141. */
  41142. onXRFrameObservable: Observable<any>;
  41143. /**
  41144. * Fires when the xr session is ended either by the device or manually done
  41145. */
  41146. onXRSessionEnded: Observable<any>;
  41147. /** @hidden */
  41148. _xrSession: XRSession;
  41149. /** @hidden */
  41150. _frameOfReference: XRFrameOfReference;
  41151. /** @hidden */
  41152. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  41153. /** @hidden */
  41154. _currentXRFrame: Nullable<XRFrame>;
  41155. private _xrNavigator;
  41156. private _xrDevice;
  41157. private _tmpMatrix;
  41158. /**
  41159. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  41160. * @param scene The scene which the session should be created for
  41161. */
  41162. constructor(scene: Scene);
  41163. /**
  41164. * Initializes the manager
  41165. * After initialization enterXR can be called to start an XR session
  41166. * @returns Promise which resolves after it is initialized
  41167. */
  41168. initializeAsync(): Promise<void>;
  41169. /**
  41170. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  41171. * @param sessionCreationOptions xr options to create the session with
  41172. * @param frameOfReferenceType option to configure how the xr pose is expressed
  41173. * @returns Promise which resolves after it enters XR
  41174. */
  41175. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  41176. /**
  41177. * Stops the xrSession and restores the renderloop
  41178. * @returns Promise which resolves after it exits XR
  41179. */
  41180. exitXRAsync(): Promise<void>;
  41181. /**
  41182. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41183. * @param ray ray to cast into the environment
  41184. * @returns Promise which resolves with a collision point in the environment if it exists
  41185. */
  41186. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41187. /**
  41188. * Checks if a session would be supported for the creation options specified
  41189. * @param options creation options to check if they are supported
  41190. * @returns true if supported
  41191. */
  41192. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41193. /**
  41194. * @hidden
  41195. * Converts the render layer of xrSession to a render target
  41196. * @param session session to create render target for
  41197. * @param scene scene the new render target should be created for
  41198. */
  41199. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  41200. /**
  41201. * Disposes of the session manager
  41202. */
  41203. dispose(): void;
  41204. }
  41205. }
  41206. declare module "babylonjs/Cameras/XR/webXRCamera" {
  41207. import { Scene } from "babylonjs/scene";
  41208. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  41209. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41210. /**
  41211. * WebXR Camera which holds the views for the xrSession
  41212. * @see https://doc.babylonjs.com/how_to/webxr
  41213. */
  41214. export class WebXRCamera extends FreeCamera {
  41215. private static _TmpMatrix;
  41216. /**
  41217. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  41218. * @param name the name of the camera
  41219. * @param scene the scene to add the camera to
  41220. */
  41221. constructor(name: string, scene: Scene);
  41222. private _updateNumberOfRigCameras;
  41223. /** @hidden */
  41224. _updateForDualEyeDebugging(pupilDistance?: number): void;
  41225. /**
  41226. * Updates the cameras position from the current pose information of the XR session
  41227. * @param xrSessionManager the session containing pose information
  41228. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  41229. */
  41230. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  41231. }
  41232. }
  41233. declare module "babylonjs/Cameras/XR/webXRExperienceHelper" {
  41234. import { Nullable } from "babylonjs/types";
  41235. import { Observable } from "babylonjs/Misc/observable";
  41236. import { IDisposable, Scene } from "babylonjs/scene";
  41237. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  41238. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41239. import { Ray } from "babylonjs/Culling/ray";
  41240. import { WebXRSessionManager } from "babylonjs/Cameras/XR/webXRSessionManager";
  41241. import { WebXRCamera } from "babylonjs/Cameras/XR/webXRCamera";
  41242. /**
  41243. * States of the webXR experience
  41244. */
  41245. export enum WebXRState {
  41246. /**
  41247. * Transitioning to being in XR mode
  41248. */
  41249. ENTERING_XR = 0,
  41250. /**
  41251. * Transitioning to non XR mode
  41252. */
  41253. EXITING_XR = 1,
  41254. /**
  41255. * In XR mode and presenting
  41256. */
  41257. IN_XR = 2,
  41258. /**
  41259. * Not entered XR mode
  41260. */
  41261. NOT_IN_XR = 3
  41262. }
  41263. /**
  41264. * Helper class used to enable XR
  41265. * @see https://doc.babylonjs.com/how_to/webxr
  41266. */
  41267. export class WebXRExperienceHelper implements IDisposable {
  41268. private scene;
  41269. /**
  41270. * 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
  41271. */
  41272. container: AbstractMesh;
  41273. /**
  41274. * Camera used to render xr content
  41275. */
  41276. camera: WebXRCamera;
  41277. /**
  41278. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  41279. */
  41280. state: WebXRState;
  41281. private _setState;
  41282. private static _TmpVector;
  41283. /**
  41284. * Fires when the state of the experience helper has changed
  41285. */
  41286. onStateChangedObservable: Observable<WebXRState>;
  41287. /** @hidden */
  41288. _sessionManager: WebXRSessionManager;
  41289. private _nonVRCamera;
  41290. private _originalSceneAutoClear;
  41291. private _supported;
  41292. /**
  41293. * Creates the experience helper
  41294. * @param scene the scene to attach the experience helper to
  41295. * @returns a promise for the experience helper
  41296. */
  41297. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  41298. /**
  41299. * Creates a WebXRExperienceHelper
  41300. * @param scene The scene the helper should be created in
  41301. */
  41302. private constructor();
  41303. /**
  41304. * Exits XR mode and returns the scene to its original state
  41305. * @returns promise that resolves after xr mode has exited
  41306. */
  41307. exitXRAsync(): Promise<void>;
  41308. /**
  41309. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  41310. * @param sessionCreationOptions options for the XR session
  41311. * @param frameOfReference frame of reference of the XR session
  41312. * @returns promise that resolves after xr mode has entered
  41313. */
  41314. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  41315. /**
  41316. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  41317. * @param ray ray to cast into the environment
  41318. * @returns Promise which resolves with a collision point in the environment if it exists
  41319. */
  41320. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  41321. /**
  41322. * Updates the global position of the camera by moving the camera's container
  41323. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  41324. * @param position The desired global position of the camera
  41325. */
  41326. setPositionOfCameraUsingContainer(position: Vector3): void;
  41327. /**
  41328. * Rotates the xr camera by rotating the camera's container around the camera's position
  41329. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  41330. * @param rotation the desired quaternion rotation to apply to the camera
  41331. */
  41332. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  41333. /**
  41334. * Checks if the creation options are supported by the xr session
  41335. * @param options creation options
  41336. * @returns true if supported
  41337. */
  41338. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  41339. /**
  41340. * Disposes of the experience helper
  41341. */
  41342. dispose(): void;
  41343. }
  41344. }
  41345. declare module "babylonjs/Cameras/XR/webXREnterExitUI" {
  41346. import { Nullable } from "babylonjs/types";
  41347. import { Observable } from "babylonjs/Misc/observable";
  41348. import { IDisposable, Scene } from "babylonjs/scene";
  41349. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41350. /**
  41351. * Button which can be used to enter a different mode of XR
  41352. */
  41353. export class WebXREnterExitUIButton {
  41354. /** button element */
  41355. element: HTMLElement;
  41356. /** XR initialization options for the button */
  41357. initializationOptions: XRSessionCreationOptions;
  41358. /**
  41359. * Creates a WebXREnterExitUIButton
  41360. * @param element button element
  41361. * @param initializationOptions XR initialization options for the button
  41362. */
  41363. constructor(
  41364. /** button element */
  41365. element: HTMLElement,
  41366. /** XR initialization options for the button */
  41367. initializationOptions: XRSessionCreationOptions);
  41368. /**
  41369. * Overwritable function which can be used to update the button's visuals when the state changes
  41370. * @param activeButton the current active button in the UI
  41371. */
  41372. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  41373. }
  41374. /**
  41375. * Options to create the webXR UI
  41376. */
  41377. export class WebXREnterExitUIOptions {
  41378. /**
  41379. * Context to enter xr with
  41380. */
  41381. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  41382. /**
  41383. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  41384. */
  41385. customButtons?: Array<WebXREnterExitUIButton>;
  41386. }
  41387. /**
  41388. * UI to allow the user to enter/exit XR mode
  41389. */
  41390. export class WebXREnterExitUI implements IDisposable {
  41391. private scene;
  41392. private _overlay;
  41393. private _buttons;
  41394. private _activeButton;
  41395. /**
  41396. * Fired every time the active button is changed.
  41397. *
  41398. * When xr is entered via a button that launches xr that button will be the callback parameter
  41399. *
  41400. * When exiting xr the callback parameter will be null)
  41401. */
  41402. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  41403. /**
  41404. * Creates UI to allow the user to enter/exit XR mode
  41405. * @param scene the scene to add the ui to
  41406. * @param helper the xr experience helper to enter/exit xr with
  41407. * @param options options to configure the UI
  41408. * @returns the created ui
  41409. */
  41410. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  41411. private constructor();
  41412. private _updateButtons;
  41413. /**
  41414. * Disposes of the object
  41415. */
  41416. dispose(): void;
  41417. }
  41418. }
  41419. declare module "babylonjs/Cameras/XR/webXRInput" {
  41420. import { IDisposable, Scene } from "babylonjs/scene";
  41421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41422. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41423. /**
  41424. * Represents an XR input
  41425. */
  41426. export class WebXRController {
  41427. /**
  41428. * 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
  41429. */
  41430. grip?: AbstractMesh;
  41431. /**
  41432. * Pointer which can be used to select objects or attach a visible laser to
  41433. */
  41434. pointer: AbstractMesh;
  41435. /**
  41436. * Creates the controller
  41437. * @see https://doc.babylonjs.com/how_to/webxr
  41438. * @param scene the scene which the controller should be associated to
  41439. */
  41440. constructor(scene: Scene);
  41441. /**
  41442. * Disposes of the object
  41443. */
  41444. dispose(): void;
  41445. }
  41446. /**
  41447. * XR input used to track XR inputs such as controllers/rays
  41448. */
  41449. export class WebXRInput implements IDisposable {
  41450. private helper;
  41451. /**
  41452. * XR controllers being tracked
  41453. */
  41454. controllers: Array<WebXRController>;
  41455. private _tmpMatrix;
  41456. private _frameObserver;
  41457. /**
  41458. * Initializes the WebXRInput
  41459. * @param helper experience helper which the input should be created for
  41460. */
  41461. constructor(helper: WebXRExperienceHelper);
  41462. /**
  41463. * Disposes of the object
  41464. */
  41465. dispose(): void;
  41466. }
  41467. }
  41468. declare module "babylonjs/Cameras/XR/webXRManagedOutputCanvas" {
  41469. import { Nullable } from "babylonjs/types";
  41470. import { IDisposable } from "babylonjs/scene";
  41471. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41472. /**
  41473. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  41474. */
  41475. export class WebXRManagedOutputCanvas implements IDisposable {
  41476. private _canvas;
  41477. /**
  41478. * xrpresent context of the canvas which can be used to display/mirror xr content
  41479. */
  41480. canvasContext: Nullable<WebGLRenderingContext>;
  41481. /**
  41482. * Initializes the canvas to be added/removed upon entering/exiting xr
  41483. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  41484. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  41485. */
  41486. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  41487. /**
  41488. * Disposes of the object
  41489. */
  41490. dispose(): void;
  41491. private _setManagedOutputCanvas;
  41492. private _addCanvas;
  41493. private _removeCanvas;
  41494. }
  41495. }
  41496. declare module "babylonjs/Cameras/XR/index" {
  41497. export * from "babylonjs/Cameras/XR/webXRCamera";
  41498. export * from "babylonjs/Cameras/XR/webXREnterExitUI";
  41499. export * from "babylonjs/Cameras/XR/webXRExperienceHelper";
  41500. export * from "babylonjs/Cameras/XR/webXRInput";
  41501. export * from "babylonjs/Cameras/XR/webXRManagedOutputCanvas";
  41502. export * from "babylonjs/Cameras/XR/webXRSessionManager";
  41503. }
  41504. declare module "babylonjs/Cameras/RigModes/index" {
  41505. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  41506. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  41507. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  41508. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  41509. }
  41510. declare module "babylonjs/Cameras/index" {
  41511. export * from "babylonjs/Cameras/Inputs/index";
  41512. export * from "babylonjs/Cameras/cameraInputsManager";
  41513. export * from "babylonjs/Cameras/camera";
  41514. export * from "babylonjs/Cameras/targetCamera";
  41515. export * from "babylonjs/Cameras/freeCamera";
  41516. export * from "babylonjs/Cameras/freeCameraInputsManager";
  41517. export * from "babylonjs/Cameras/touchCamera";
  41518. export * from "babylonjs/Cameras/arcRotateCamera";
  41519. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  41520. export * from "babylonjs/Cameras/deviceOrientationCamera";
  41521. export * from "babylonjs/Cameras/flyCamera";
  41522. export * from "babylonjs/Cameras/flyCameraInputsManager";
  41523. export * from "babylonjs/Cameras/followCamera";
  41524. export * from "babylonjs/Cameras/gamepadCamera";
  41525. export * from "babylonjs/Cameras/Stereoscopic/index";
  41526. export * from "babylonjs/Cameras/universalCamera";
  41527. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  41528. export * from "babylonjs/Cameras/VR/index";
  41529. export * from "babylonjs/Cameras/XR/index";
  41530. export * from "babylonjs/Cameras/RigModes/index";
  41531. }
  41532. declare module "babylonjs/Collisions/index" {
  41533. export * from "babylonjs/Collisions/collider";
  41534. export * from "babylonjs/Collisions/collisionCoordinator";
  41535. export * from "babylonjs/Collisions/pickingInfo";
  41536. export * from "babylonjs/Collisions/intersectionInfo";
  41537. }
  41538. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  41539. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  41540. import { Vector3, Plane } from "babylonjs/Maths/math";
  41541. import { Ray } from "babylonjs/Culling/ray";
  41542. /**
  41543. * Contains an array of blocks representing the octree
  41544. */
  41545. export interface IOctreeContainer<T> {
  41546. /**
  41547. * Blocks within the octree
  41548. */
  41549. blocks: Array<OctreeBlock<T>>;
  41550. }
  41551. /**
  41552. * Class used to store a cell in an octree
  41553. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41554. */
  41555. export class OctreeBlock<T> {
  41556. /**
  41557. * Gets the content of the current block
  41558. */
  41559. entries: T[];
  41560. /**
  41561. * Gets the list of block children
  41562. */
  41563. blocks: Array<OctreeBlock<T>>;
  41564. private _depth;
  41565. private _maxDepth;
  41566. private _capacity;
  41567. private _minPoint;
  41568. private _maxPoint;
  41569. private _boundingVectors;
  41570. private _creationFunc;
  41571. /**
  41572. * Creates a new block
  41573. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  41574. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  41575. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41576. * @param depth defines the current depth of this block in the octree
  41577. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  41578. * @param creationFunc defines a callback to call when an element is added to the block
  41579. */
  41580. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  41581. /**
  41582. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  41583. */
  41584. readonly capacity: number;
  41585. /**
  41586. * Gets the minimum vector (in world space) of the block's bounding box
  41587. */
  41588. readonly minPoint: Vector3;
  41589. /**
  41590. * Gets the maximum vector (in world space) of the block's bounding box
  41591. */
  41592. readonly maxPoint: Vector3;
  41593. /**
  41594. * Add a new element to this block
  41595. * @param entry defines the element to add
  41596. */
  41597. addEntry(entry: T): void;
  41598. /**
  41599. * Remove an element from this block
  41600. * @param entry defines the element to remove
  41601. */
  41602. removeEntry(entry: T): void;
  41603. /**
  41604. * Add an array of elements to this block
  41605. * @param entries defines the array of elements to add
  41606. */
  41607. addEntries(entries: T[]): void;
  41608. /**
  41609. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  41610. * @param frustumPlanes defines the frustum planes to test
  41611. * @param selection defines the array to store current content if selection is positive
  41612. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41613. */
  41614. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41615. /**
  41616. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  41617. * @param sphereCenter defines the bounding sphere center
  41618. * @param sphereRadius defines the bounding sphere radius
  41619. * @param selection defines the array to store current content if selection is positive
  41620. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41621. */
  41622. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  41623. /**
  41624. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  41625. * @param ray defines the ray to test with
  41626. * @param selection defines the array to store current content if selection is positive
  41627. */
  41628. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  41629. /**
  41630. * Subdivide the content into child blocks (this block will then be empty)
  41631. */
  41632. createInnerBlocks(): void;
  41633. /**
  41634. * @hidden
  41635. */
  41636. 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;
  41637. }
  41638. }
  41639. declare module "babylonjs/Culling/Octrees/octree" {
  41640. import { SmartArray } from "babylonjs/Misc/smartArray";
  41641. import { Vector3, Plane } from "babylonjs/Maths/math";
  41642. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41643. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41644. import { Ray } from "babylonjs/Culling/ray";
  41645. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  41646. /**
  41647. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  41648. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41649. */
  41650. export class Octree<T> {
  41651. /** 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.) */
  41652. maxDepth: number;
  41653. /**
  41654. * Blocks within the octree containing objects
  41655. */
  41656. blocks: Array<OctreeBlock<T>>;
  41657. /**
  41658. * Content stored in the octree
  41659. */
  41660. dynamicContent: T[];
  41661. private _maxBlockCapacity;
  41662. private _selectionContent;
  41663. private _creationFunc;
  41664. /**
  41665. * Creates a octree
  41666. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41667. * @param creationFunc function to be used to instatiate the octree
  41668. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  41669. * @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.)
  41670. */
  41671. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  41672. /** 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.) */
  41673. maxDepth?: number);
  41674. /**
  41675. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  41676. * @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);
  41677. * @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);
  41678. * @param entries meshes to be added to the octree blocks
  41679. */
  41680. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  41681. /**
  41682. * Adds a mesh to the octree
  41683. * @param entry Mesh to add to the octree
  41684. */
  41685. addMesh(entry: T): void;
  41686. /**
  41687. * Remove an element from the octree
  41688. * @param entry defines the element to remove
  41689. */
  41690. removeMesh(entry: T): void;
  41691. /**
  41692. * Selects an array of meshes within the frustum
  41693. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  41694. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  41695. * @returns array of meshes within the frustum
  41696. */
  41697. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  41698. /**
  41699. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  41700. * @param sphereCenter defines the bounding sphere center
  41701. * @param sphereRadius defines the bounding sphere radius
  41702. * @param allowDuplicate defines if the selection array can contains duplicated entries
  41703. * @returns an array of objects that intersect the sphere
  41704. */
  41705. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  41706. /**
  41707. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  41708. * @param ray defines the ray to test with
  41709. * @returns array of intersected objects
  41710. */
  41711. intersectsRay(ray: Ray): SmartArray<T>;
  41712. /**
  41713. * Adds a mesh into the octree block if it intersects the block
  41714. */
  41715. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  41716. /**
  41717. * Adds a submesh into the octree block if it intersects the block
  41718. */
  41719. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  41720. }
  41721. }
  41722. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  41723. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  41724. import { Scene } from "babylonjs/scene";
  41725. import { SubMesh } from "babylonjs/Meshes/subMesh";
  41726. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41727. import { Ray } from "babylonjs/Culling/ray";
  41728. import { Octree } from "babylonjs/Culling/Octrees/octree";
  41729. import { Collider } from "babylonjs/Collisions/collider";
  41730. module "babylonjs/scene" {
  41731. interface Scene {
  41732. /**
  41733. * @hidden
  41734. * Backing Filed
  41735. */
  41736. _selectionOctree: Octree<AbstractMesh>;
  41737. /**
  41738. * Gets the octree used to boost mesh selection (picking)
  41739. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41740. */
  41741. selectionOctree: Octree<AbstractMesh>;
  41742. /**
  41743. * Creates or updates the octree used to boost selection (picking)
  41744. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41745. * @param maxCapacity defines the maximum capacity per leaf
  41746. * @param maxDepth defines the maximum depth of the octree
  41747. * @returns an octree of AbstractMesh
  41748. */
  41749. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  41750. }
  41751. }
  41752. module "babylonjs/Meshes/abstractMesh" {
  41753. interface AbstractMesh {
  41754. /**
  41755. * @hidden
  41756. * Backing Field
  41757. */
  41758. _submeshesOctree: Octree<SubMesh>;
  41759. /**
  41760. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  41761. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  41762. * @param maxCapacity defines the maximum size of each block (64 by default)
  41763. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  41764. * @returns the new octree
  41765. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  41766. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  41767. */
  41768. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  41769. }
  41770. }
  41771. /**
  41772. * Defines the octree scene component responsible to manage any octrees
  41773. * in a given scene.
  41774. */
  41775. export class OctreeSceneComponent {
  41776. /**
  41777. * The component name helpfull to identify the component in the list of scene components.
  41778. */
  41779. readonly name: string;
  41780. /**
  41781. * The scene the component belongs to.
  41782. */
  41783. scene: Scene;
  41784. /**
  41785. * Indicates if the meshes have been checked to make sure they are isEnabled()
  41786. */
  41787. readonly checksIsEnabled: boolean;
  41788. /**
  41789. * Creates a new instance of the component for the given scene
  41790. * @param scene Defines the scene to register the component in
  41791. */
  41792. constructor(scene: Scene);
  41793. /**
  41794. * Registers the component in a given scene
  41795. */
  41796. register(): void;
  41797. /**
  41798. * Return the list of active meshes
  41799. * @returns the list of active meshes
  41800. */
  41801. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41802. /**
  41803. * Return the list of active sub meshes
  41804. * @param mesh The mesh to get the candidates sub meshes from
  41805. * @returns the list of active sub meshes
  41806. */
  41807. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41808. private _tempRay;
  41809. /**
  41810. * Return the list of sub meshes intersecting with a given local ray
  41811. * @param mesh defines the mesh to find the submesh for
  41812. * @param localRay defines the ray in local space
  41813. * @returns the list of intersecting sub meshes
  41814. */
  41815. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  41816. /**
  41817. * Return the list of sub meshes colliding with a collider
  41818. * @param mesh defines the mesh to find the submesh for
  41819. * @param collider defines the collider to evaluate the collision against
  41820. * @returns the list of colliding sub meshes
  41821. */
  41822. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  41823. /**
  41824. * Rebuilds the elements related to this component in case of
  41825. * context lost for instance.
  41826. */
  41827. rebuild(): void;
  41828. /**
  41829. * Disposes the component and the associated ressources.
  41830. */
  41831. dispose(): void;
  41832. }
  41833. }
  41834. declare module "babylonjs/Culling/Octrees/index" {
  41835. export * from "babylonjs/Culling/Octrees/octree";
  41836. export * from "babylonjs/Culling/Octrees/octreeBlock";
  41837. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  41838. }
  41839. declare module "babylonjs/Culling/index" {
  41840. export * from "babylonjs/Culling/boundingBox";
  41841. export * from "babylonjs/Culling/boundingInfo";
  41842. export * from "babylonjs/Culling/boundingSphere";
  41843. export * from "babylonjs/Culling/Octrees/index";
  41844. export * from "babylonjs/Culling/ray";
  41845. }
  41846. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  41847. import { IDisposable, Scene } from "babylonjs/scene";
  41848. import { Nullable } from "babylonjs/types";
  41849. import { Observable } from "babylonjs/Misc/observable";
  41850. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41851. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  41852. /**
  41853. * Renders a layer on top of an existing scene
  41854. */
  41855. export class UtilityLayerRenderer implements IDisposable {
  41856. /** the original scene that will be rendered on top of */
  41857. originalScene: Scene;
  41858. private _pointerCaptures;
  41859. private _lastPointerEvents;
  41860. private static _DefaultUtilityLayer;
  41861. private static _DefaultKeepDepthUtilityLayer;
  41862. private _sharedGizmoLight;
  41863. /**
  41864. * @hidden
  41865. * Light which used by gizmos to get light shading
  41866. */
  41867. _getSharedGizmoLight(): HemisphericLight;
  41868. /**
  41869. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  41870. */
  41871. pickUtilitySceneFirst: boolean;
  41872. /**
  41873. * 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)
  41874. */
  41875. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  41876. /**
  41877. * 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)
  41878. */
  41879. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  41880. /**
  41881. * The scene that is rendered on top of the original scene
  41882. */
  41883. utilityLayerScene: Scene;
  41884. /**
  41885. * If the utility layer should automatically be rendered on top of existing scene
  41886. */
  41887. shouldRender: boolean;
  41888. /**
  41889. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  41890. */
  41891. onlyCheckPointerDownEvents: boolean;
  41892. /**
  41893. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  41894. */
  41895. processAllEvents: boolean;
  41896. /**
  41897. * Observable raised when the pointer move from the utility layer scene to the main scene
  41898. */
  41899. onPointerOutObservable: Observable<number>;
  41900. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  41901. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  41902. private _afterRenderObserver;
  41903. private _sceneDisposeObserver;
  41904. private _originalPointerObserver;
  41905. /**
  41906. * Instantiates a UtilityLayerRenderer
  41907. * @param originalScene the original scene that will be rendered on top of
  41908. * @param handleEvents boolean indicating if the utility layer should handle events
  41909. */
  41910. constructor(
  41911. /** the original scene that will be rendered on top of */
  41912. originalScene: Scene, handleEvents?: boolean);
  41913. private _notifyObservers;
  41914. /**
  41915. * Renders the utility layers scene on top of the original scene
  41916. */
  41917. render(): void;
  41918. /**
  41919. * Disposes of the renderer
  41920. */
  41921. dispose(): void;
  41922. private _updateCamera;
  41923. }
  41924. }
  41925. declare module "babylonjs/Gizmos/gizmo" {
  41926. import { Nullable } from "babylonjs/types";
  41927. import { IDisposable } from "babylonjs/scene";
  41928. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41929. import { Mesh } from "babylonjs/Meshes/mesh";
  41930. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  41931. /**
  41932. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  41933. */
  41934. export class Gizmo implements IDisposable {
  41935. /** The utility layer the gizmo will be added to */
  41936. gizmoLayer: UtilityLayerRenderer;
  41937. /**
  41938. * The root mesh of the gizmo
  41939. */
  41940. _rootMesh: Mesh;
  41941. private _attachedMesh;
  41942. /**
  41943. * Ratio for the scale of the gizmo (Default: 1)
  41944. */
  41945. scaleRatio: number;
  41946. /**
  41947. * If a custom mesh has been set (Default: false)
  41948. */
  41949. protected _customMeshSet: boolean;
  41950. /**
  41951. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  41952. * * When set, interactions will be enabled
  41953. */
  41954. attachedMesh: Nullable<AbstractMesh>;
  41955. /**
  41956. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  41957. * @param mesh The mesh to replace the default mesh of the gizmo
  41958. */
  41959. setCustomMesh(mesh: Mesh): void;
  41960. /**
  41961. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  41962. */
  41963. updateGizmoRotationToMatchAttachedMesh: boolean;
  41964. /**
  41965. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  41966. */
  41967. updateGizmoPositionToMatchAttachedMesh: boolean;
  41968. /**
  41969. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  41970. */
  41971. protected _updateScale: boolean;
  41972. protected _interactionsEnabled: boolean;
  41973. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  41974. private _beforeRenderObserver;
  41975. private _tempVector;
  41976. /**
  41977. * Creates a gizmo
  41978. * @param gizmoLayer The utility layer the gizmo will be added to
  41979. */
  41980. constructor(
  41981. /** The utility layer the gizmo will be added to */
  41982. gizmoLayer?: UtilityLayerRenderer);
  41983. /**
  41984. * Updates the gizmo to match the attached mesh's position/rotation
  41985. */
  41986. protected _update(): void;
  41987. /**
  41988. * Disposes of the gizmo
  41989. */
  41990. dispose(): void;
  41991. }
  41992. }
  41993. declare module "babylonjs/Gizmos/axisDragGizmo" {
  41994. import { Observable } from "babylonjs/Misc/observable";
  41995. import { Nullable } from "babylonjs/types";
  41996. import { Vector3, Color3 } from "babylonjs/Maths/math";
  41997. import { TransformNode } from "babylonjs/Meshes/transformNode";
  41998. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  41999. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  42000. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  42001. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  42002. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  42003. import { Scene } from "babylonjs/scene";
  42004. /**
  42005. * Single axis drag gizmo
  42006. */
  42007. export class AxisDragGizmo extends Gizmo {
  42008. /**
  42009. * Drag behavior responsible for the gizmos dragging interactions
  42010. */
  42011. dragBehavior: PointerDragBehavior;
  42012. private _pointerObserver;
  42013. /**
  42014. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  42015. */
  42016. snapDistance: number;
  42017. /**
  42018. * Event that fires each time the gizmo snaps to a new location.
  42019. * * snapDistance is the the change in distance
  42020. */
  42021. onSnapObservable: Observable<{
  42022. snapDistance: number;
  42023. }>;
  42024. /** @hidden */
  42025. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  42026. /** @hidden */
  42027. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  42028. /**
  42029. * Creates an AxisDragGizmo
  42030. * @param gizmoLayer The utility layer the gizmo will be added to
  42031. * @param dragAxis The axis which the gizmo will be able to drag on
  42032. * @param color The color of the gizmo
  42033. */
  42034. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  42035. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  42036. /**
  42037. * Disposes of the gizmo
  42038. */
  42039. dispose(): void;
  42040. }
  42041. }
  42042. declare module "babylonjs/Debug/axesViewer" {
  42043. import { Vector3 } from "babylonjs/Maths/math";
  42044. import { Nullable } from "babylonjs/types";
  42045. import { Scene } from "babylonjs/scene";
  42046. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42047. /**
  42048. * The Axes viewer will show 3 axes in a specific point in space
  42049. */
  42050. export class AxesViewer {
  42051. private _xAxis;
  42052. private _yAxis;
  42053. private _zAxis;
  42054. private _scaleLinesFactor;
  42055. private _instanced;
  42056. /**
  42057. * Gets the hosting scene
  42058. */
  42059. scene: Scene;
  42060. /**
  42061. * Gets or sets a number used to scale line length
  42062. */
  42063. scaleLines: number;
  42064. /** Gets the node hierarchy used to render x-axis */
  42065. readonly xAxis: TransformNode;
  42066. /** Gets the node hierarchy used to render y-axis */
  42067. readonly yAxis: TransformNode;
  42068. /** Gets the node hierarchy used to render z-axis */
  42069. readonly zAxis: TransformNode;
  42070. /**
  42071. * Creates a new AxesViewer
  42072. * @param scene defines the hosting scene
  42073. * @param scaleLines defines a number used to scale line length (1 by default)
  42074. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  42075. * @param xAxis defines the node hierarchy used to render the x-axis
  42076. * @param yAxis defines the node hierarchy used to render the y-axis
  42077. * @param zAxis defines the node hierarchy used to render the z-axis
  42078. */
  42079. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  42080. /**
  42081. * Force the viewer to update
  42082. * @param position defines the position of the viewer
  42083. * @param xaxis defines the x axis of the viewer
  42084. * @param yaxis defines the y axis of the viewer
  42085. * @param zaxis defines the z axis of the viewer
  42086. */
  42087. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  42088. /**
  42089. * Creates an instance of this axes viewer.
  42090. * @returns a new axes viewer with instanced meshes
  42091. */
  42092. createInstance(): AxesViewer;
  42093. /** Releases resources */
  42094. dispose(): void;
  42095. private static _SetRenderingGroupId;
  42096. }
  42097. }
  42098. declare module "babylonjs/Debug/boneAxesViewer" {
  42099. import { Nullable } from "babylonjs/types";
  42100. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  42101. import { Vector3 } from "babylonjs/Maths/math";
  42102. import { Mesh } from "babylonjs/Meshes/mesh";
  42103. import { Bone } from "babylonjs/Bones/bone";
  42104. import { Scene } from "babylonjs/scene";
  42105. /**
  42106. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  42107. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  42108. */
  42109. export class BoneAxesViewer extends AxesViewer {
  42110. /**
  42111. * Gets or sets the target mesh where to display the axes viewer
  42112. */
  42113. mesh: Nullable<Mesh>;
  42114. /**
  42115. * Gets or sets the target bone where to display the axes viewer
  42116. */
  42117. bone: Nullable<Bone>;
  42118. /** Gets current position */
  42119. pos: Vector3;
  42120. /** Gets direction of X axis */
  42121. xaxis: Vector3;
  42122. /** Gets direction of Y axis */
  42123. yaxis: Vector3;
  42124. /** Gets direction of Z axis */
  42125. zaxis: Vector3;
  42126. /**
  42127. * Creates a new BoneAxesViewer
  42128. * @param scene defines the hosting scene
  42129. * @param bone defines the target bone
  42130. * @param mesh defines the target mesh
  42131. * @param scaleLines defines a scaling factor for line length (1 by default)
  42132. */
  42133. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  42134. /**
  42135. * Force the viewer to update
  42136. */
  42137. update(): void;
  42138. /** Releases resources */
  42139. dispose(): void;
  42140. }
  42141. }
  42142. declare module "babylonjs/Debug/debugLayer" {
  42143. import { Observable } from "babylonjs/Misc/observable";
  42144. import { Scene } from "babylonjs/scene";
  42145. /**
  42146. * Interface used to define scene explorer extensibility option
  42147. */
  42148. export interface IExplorerExtensibilityOption {
  42149. /**
  42150. * Define the option label
  42151. */
  42152. label: string;
  42153. /**
  42154. * Defines the action to execute on click
  42155. */
  42156. action: (entity: any) => void;
  42157. }
  42158. /**
  42159. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  42160. */
  42161. export interface IExplorerExtensibilityGroup {
  42162. /**
  42163. * Defines a predicate to test if a given type mut be extended
  42164. */
  42165. predicate: (entity: any) => boolean;
  42166. /**
  42167. * Gets the list of options added to a type
  42168. */
  42169. entries: IExplorerExtensibilityOption[];
  42170. }
  42171. /**
  42172. * Interface used to define the options to use to create the Inspector
  42173. */
  42174. export interface IInspectorOptions {
  42175. /**
  42176. * Display in overlay mode (default: false)
  42177. */
  42178. overlay?: boolean;
  42179. /**
  42180. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  42181. */
  42182. globalRoot?: HTMLElement;
  42183. /**
  42184. * Display the Scene explorer
  42185. */
  42186. showExplorer?: boolean;
  42187. /**
  42188. * Display the property inspector
  42189. */
  42190. showInspector?: boolean;
  42191. /**
  42192. * Display in embed mode (both panes on the right)
  42193. */
  42194. embedMode?: boolean;
  42195. /**
  42196. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  42197. */
  42198. handleResize?: boolean;
  42199. /**
  42200. * Allow the panes to popup (default: true)
  42201. */
  42202. enablePopup?: boolean;
  42203. /**
  42204. * Allow the panes to be closed by users (default: true)
  42205. */
  42206. enableClose?: boolean;
  42207. /**
  42208. * Optional list of extensibility entries
  42209. */
  42210. explorerExtensibility?: IExplorerExtensibilityGroup[];
  42211. /**
  42212. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  42213. */
  42214. inspectorURL?: string;
  42215. }
  42216. module "babylonjs/scene" {
  42217. interface Scene {
  42218. /**
  42219. * @hidden
  42220. * Backing field
  42221. */
  42222. _debugLayer: DebugLayer;
  42223. /**
  42224. * Gets the debug layer (aka Inspector) associated with the scene
  42225. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42226. */
  42227. debugLayer: DebugLayer;
  42228. }
  42229. }
  42230. /**
  42231. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42232. * what is happening in your scene
  42233. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42234. */
  42235. export class DebugLayer {
  42236. /**
  42237. * Define the url to get the inspector script from.
  42238. * By default it uses the babylonjs CDN.
  42239. * @ignoreNaming
  42240. */
  42241. static InspectorURL: string;
  42242. private _scene;
  42243. private BJSINSPECTOR;
  42244. /**
  42245. * Observable triggered when a property is changed through the inspector.
  42246. */
  42247. onPropertyChangedObservable: Observable<{
  42248. object: any;
  42249. property: string;
  42250. value: any;
  42251. initialValue: any;
  42252. }>;
  42253. /**
  42254. * Instantiates a new debug layer.
  42255. * The debug layer (aka Inspector) is the go to tool in order to better understand
  42256. * what is happening in your scene
  42257. * @see http://doc.babylonjs.com/features/playground_debuglayer
  42258. * @param scene Defines the scene to inspect
  42259. */
  42260. constructor(scene: Scene);
  42261. /** Creates the inspector window. */
  42262. private _createInspector;
  42263. /**
  42264. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  42265. * @param entity defines the entity to select
  42266. * @param lineContainerTitle defines the specific block to highlight
  42267. */
  42268. select(entity: any, lineContainerTitle?: string): void;
  42269. /** Get the inspector from bundle or global */
  42270. private _getGlobalInspector;
  42271. /**
  42272. * Get if the inspector is visible or not.
  42273. * @returns true if visible otherwise, false
  42274. */
  42275. isVisible(): boolean;
  42276. /**
  42277. * Hide the inspector and close its window.
  42278. */
  42279. hide(): void;
  42280. /**
  42281. * Launch the debugLayer.
  42282. * @param config Define the configuration of the inspector
  42283. * @return a promise fulfilled when the debug layer is visible
  42284. */
  42285. show(config?: IInspectorOptions): Promise<DebugLayer>;
  42286. }
  42287. }
  42288. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  42289. import { Nullable } from "babylonjs/types";
  42290. import { Scene } from "babylonjs/scene";
  42291. import { Vector4, Color4 } from "babylonjs/Maths/math";
  42292. import { Mesh } from "babylonjs/Meshes/mesh";
  42293. /**
  42294. * Class containing static functions to help procedurally build meshes
  42295. */
  42296. export class BoxBuilder {
  42297. /**
  42298. * Creates a box mesh
  42299. * * The parameter `size` sets the size (float) of each box side (default 1)
  42300. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  42301. * * 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)
  42302. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  42303. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42304. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42305. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42306. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  42307. * @param name defines the name of the mesh
  42308. * @param options defines the options used to create the mesh
  42309. * @param scene defines the hosting scene
  42310. * @returns the box mesh
  42311. */
  42312. static CreateBox(name: string, options: {
  42313. size?: number;
  42314. width?: number;
  42315. height?: number;
  42316. depth?: number;
  42317. faceUV?: Vector4[];
  42318. faceColors?: Color4[];
  42319. sideOrientation?: number;
  42320. frontUVs?: Vector4;
  42321. backUVs?: Vector4;
  42322. wrap?: boolean;
  42323. topBaseAt?: number;
  42324. bottomBaseAt?: number;
  42325. updatable?: boolean;
  42326. }, scene?: Nullable<Scene>): Mesh;
  42327. }
  42328. }
  42329. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  42330. import { Vector4 } from "babylonjs/Maths/math";
  42331. import { Mesh } from "babylonjs/Meshes/mesh";
  42332. /**
  42333. * Class containing static functions to help procedurally build meshes
  42334. */
  42335. export class SphereBuilder {
  42336. /**
  42337. * Creates a sphere mesh
  42338. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  42339. * * 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`)
  42340. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  42341. * * 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
  42342. * * 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)
  42343. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  42344. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  42345. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42346. * @param name defines the name of the mesh
  42347. * @param options defines the options used to create the mesh
  42348. * @param scene defines the hosting scene
  42349. * @returns the sphere mesh
  42350. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  42351. */
  42352. static CreateSphere(name: string, options: {
  42353. segments?: number;
  42354. diameter?: number;
  42355. diameterX?: number;
  42356. diameterY?: number;
  42357. diameterZ?: number;
  42358. arc?: number;
  42359. slice?: number;
  42360. sideOrientation?: number;
  42361. frontUVs?: Vector4;
  42362. backUVs?: Vector4;
  42363. updatable?: boolean;
  42364. }, scene: any): Mesh;
  42365. }
  42366. }
  42367. declare module "babylonjs/Debug/physicsViewer" {
  42368. import { Nullable } from "babylonjs/types";
  42369. import { Scene } from "babylonjs/scene";
  42370. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42371. import { Mesh } from "babylonjs/Meshes/mesh";
  42372. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  42373. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  42374. /**
  42375. * Used to show the physics impostor around the specific mesh
  42376. */
  42377. export class PhysicsViewer {
  42378. /** @hidden */
  42379. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  42380. /** @hidden */
  42381. protected _meshes: Array<Nullable<AbstractMesh>>;
  42382. /** @hidden */
  42383. protected _scene: Nullable<Scene>;
  42384. /** @hidden */
  42385. protected _numMeshes: number;
  42386. /** @hidden */
  42387. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  42388. private _renderFunction;
  42389. private _utilityLayer;
  42390. private _debugBoxMesh;
  42391. private _debugSphereMesh;
  42392. private _debugCylinderMesh;
  42393. private _debugMaterial;
  42394. private _debugMeshMeshes;
  42395. /**
  42396. * Creates a new PhysicsViewer
  42397. * @param scene defines the hosting scene
  42398. */
  42399. constructor(scene: Scene);
  42400. /** @hidden */
  42401. protected _updateDebugMeshes(): void;
  42402. /**
  42403. * Renders a specified physic impostor
  42404. * @param impostor defines the impostor to render
  42405. * @param targetMesh defines the mesh represented by the impostor
  42406. * @returns the new debug mesh used to render the impostor
  42407. */
  42408. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  42409. /**
  42410. * Hides a specified physic impostor
  42411. * @param impostor defines the impostor to hide
  42412. */
  42413. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  42414. private _getDebugMaterial;
  42415. private _getDebugBoxMesh;
  42416. private _getDebugSphereMesh;
  42417. private _getDebugCylinderMesh;
  42418. private _getDebugMeshMesh;
  42419. private _getDebugMesh;
  42420. /** Releases all resources */
  42421. dispose(): void;
  42422. }
  42423. }
  42424. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  42425. import { Vector3, Color4 } from "babylonjs/Maths/math";
  42426. import { Nullable } from "babylonjs/types";
  42427. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42428. import { Scene } from "babylonjs/scene";
  42429. /**
  42430. * Class containing static functions to help procedurally build meshes
  42431. */
  42432. export class LinesBuilder {
  42433. /**
  42434. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  42435. * * 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
  42436. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  42437. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  42438. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  42439. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  42440. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  42441. * * 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
  42442. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  42443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42444. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  42445. * @param name defines the name of the new line system
  42446. * @param options defines the options used to create the line system
  42447. * @param scene defines the hosting scene
  42448. * @returns a new line system mesh
  42449. */
  42450. static CreateLineSystem(name: string, options: {
  42451. lines: Vector3[][];
  42452. updatable?: boolean;
  42453. instance?: Nullable<LinesMesh>;
  42454. colors?: Nullable<Color4[][]>;
  42455. useVertexAlpha?: boolean;
  42456. }, scene: Nullable<Scene>): LinesMesh;
  42457. /**
  42458. * Creates a line mesh
  42459. * 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
  42460. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42461. * * The parameter `points` is an array successive Vector3
  42462. * * 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
  42463. * * The optional parameter `colors` is an array of successive Color4, one per line point
  42464. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  42465. * * When updating an instance, remember that only point positions can change, not the number of points
  42466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42467. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  42468. * @param name defines the name of the new line system
  42469. * @param options defines the options used to create the line system
  42470. * @param scene defines the hosting scene
  42471. * @returns a new line mesh
  42472. */
  42473. static CreateLines(name: string, options: {
  42474. points: Vector3[];
  42475. updatable?: boolean;
  42476. instance?: Nullable<LinesMesh>;
  42477. colors?: Color4[];
  42478. useVertexAlpha?: boolean;
  42479. }, scene?: Nullable<Scene>): LinesMesh;
  42480. /**
  42481. * Creates a dashed line mesh
  42482. * * 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
  42483. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  42484. * * The parameter `points` is an array successive Vector3
  42485. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  42486. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  42487. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  42488. * * 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
  42489. * * When updating an instance, remember that only point positions can change, not the number of points
  42490. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  42491. * @param name defines the name of the mesh
  42492. * @param options defines the options used to create the mesh
  42493. * @param scene defines the hosting scene
  42494. * @returns the dashed line mesh
  42495. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  42496. */
  42497. static CreateDashedLines(name: string, options: {
  42498. points: Vector3[];
  42499. dashSize?: number;
  42500. gapSize?: number;
  42501. dashNb?: number;
  42502. updatable?: boolean;
  42503. instance?: LinesMesh;
  42504. }, scene?: Nullable<Scene>): LinesMesh;
  42505. }
  42506. }
  42507. declare module "babylonjs/Debug/rayHelper" {
  42508. import { Nullable } from "babylonjs/types";
  42509. import { Ray } from "babylonjs/Culling/ray";
  42510. import { Vector3, Color3 } from "babylonjs/Maths/math";
  42511. import { Scene } from "babylonjs/scene";
  42512. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42513. import "babylonjs/Meshes/Builders/linesBuilder";
  42514. /**
  42515. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42516. * in order to better appreciate the issue one might have.
  42517. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42518. */
  42519. export class RayHelper {
  42520. /**
  42521. * Defines the ray we are currently tryin to visualize.
  42522. */
  42523. ray: Nullable<Ray>;
  42524. private _renderPoints;
  42525. private _renderLine;
  42526. private _renderFunction;
  42527. private _scene;
  42528. private _updateToMeshFunction;
  42529. private _attachedToMesh;
  42530. private _meshSpaceDirection;
  42531. private _meshSpaceOrigin;
  42532. /**
  42533. * Helper function to create a colored helper in a scene in one line.
  42534. * @param ray Defines the ray we are currently tryin to visualize
  42535. * @param scene Defines the scene the ray is used in
  42536. * @param color Defines the color we want to see the ray in
  42537. * @returns The newly created ray helper.
  42538. */
  42539. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  42540. /**
  42541. * Instantiate a new ray helper.
  42542. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  42543. * in order to better appreciate the issue one might have.
  42544. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  42545. * @param ray Defines the ray we are currently tryin to visualize
  42546. */
  42547. constructor(ray: Ray);
  42548. /**
  42549. * Shows the ray we are willing to debug.
  42550. * @param scene Defines the scene the ray needs to be rendered in
  42551. * @param color Defines the color the ray needs to be rendered in
  42552. */
  42553. show(scene: Scene, color?: Color3): void;
  42554. /**
  42555. * Hides the ray we are debugging.
  42556. */
  42557. hide(): void;
  42558. private _render;
  42559. /**
  42560. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  42561. * @param mesh Defines the mesh we want the helper attached to
  42562. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  42563. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  42564. * @param length Defines the length of the ray
  42565. */
  42566. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  42567. /**
  42568. * Detach the ray helper from the mesh it has previously been attached to.
  42569. */
  42570. detachFromMesh(): void;
  42571. private _updateToMesh;
  42572. /**
  42573. * Dispose the helper and release its associated resources.
  42574. */
  42575. dispose(): void;
  42576. }
  42577. }
  42578. declare module "babylonjs/Debug/skeletonViewer" {
  42579. import { Color3 } from "babylonjs/Maths/math";
  42580. import { Scene } from "babylonjs/scene";
  42581. import { Nullable } from "babylonjs/types";
  42582. import { Skeleton } from "babylonjs/Bones/skeleton";
  42583. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42584. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  42585. /**
  42586. * Class used to render a debug view of a given skeleton
  42587. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  42588. */
  42589. export class SkeletonViewer {
  42590. /** defines the skeleton to render */
  42591. skeleton: Skeleton;
  42592. /** defines the mesh attached to the skeleton */
  42593. mesh: AbstractMesh;
  42594. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42595. autoUpdateBonesMatrices: boolean;
  42596. /** defines the rendering group id to use with the viewer */
  42597. renderingGroupId: number;
  42598. /** Gets or sets the color used to render the skeleton */
  42599. color: Color3;
  42600. private _scene;
  42601. private _debugLines;
  42602. private _debugMesh;
  42603. private _isEnabled;
  42604. private _renderFunction;
  42605. private _utilityLayer;
  42606. /**
  42607. * Returns the mesh used to render the bones
  42608. */
  42609. readonly debugMesh: Nullable<LinesMesh>;
  42610. /**
  42611. * Creates a new SkeletonViewer
  42612. * @param skeleton defines the skeleton to render
  42613. * @param mesh defines the mesh attached to the skeleton
  42614. * @param scene defines the hosting scene
  42615. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  42616. * @param renderingGroupId defines the rendering group id to use with the viewer
  42617. */
  42618. constructor(
  42619. /** defines the skeleton to render */
  42620. skeleton: Skeleton,
  42621. /** defines the mesh attached to the skeleton */
  42622. mesh: AbstractMesh, scene: Scene,
  42623. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  42624. autoUpdateBonesMatrices?: boolean,
  42625. /** defines the rendering group id to use with the viewer */
  42626. renderingGroupId?: number);
  42627. /** Gets or sets a boolean indicating if the viewer is enabled */
  42628. isEnabled: boolean;
  42629. private _getBonePosition;
  42630. private _getLinesForBonesWithLength;
  42631. private _getLinesForBonesNoLength;
  42632. /** Update the viewer to sync with current skeleton state */
  42633. update(): void;
  42634. /** Release associated resources */
  42635. dispose(): void;
  42636. }
  42637. }
  42638. declare module "babylonjs/Debug/index" {
  42639. export * from "babylonjs/Debug/axesViewer";
  42640. export * from "babylonjs/Debug/boneAxesViewer";
  42641. export * from "babylonjs/Debug/debugLayer";
  42642. export * from "babylonjs/Debug/physicsViewer";
  42643. export * from "babylonjs/Debug/rayHelper";
  42644. export * from "babylonjs/Debug/skeletonViewer";
  42645. }
  42646. declare module "babylonjs/Engines/nullEngine" {
  42647. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  42648. import { Scene } from "babylonjs/scene";
  42649. import { Matrix, Color3, Color4, Viewport } from "babylonjs/Maths/math";
  42650. import { Engine } from "babylonjs/Engines/engine";
  42651. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  42652. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  42653. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  42654. import { Effect } from "babylonjs/Materials/effect";
  42655. /**
  42656. * Options to create the null engine
  42657. */
  42658. export class NullEngineOptions {
  42659. /**
  42660. * Render width (Default: 512)
  42661. */
  42662. renderWidth: number;
  42663. /**
  42664. * Render height (Default: 256)
  42665. */
  42666. renderHeight: number;
  42667. /**
  42668. * Texture size (Default: 512)
  42669. */
  42670. textureSize: number;
  42671. /**
  42672. * If delta time between frames should be constant
  42673. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42674. */
  42675. deterministicLockstep: boolean;
  42676. /**
  42677. * Maximum about of steps between frames (Default: 4)
  42678. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42679. */
  42680. lockstepMaxSteps: number;
  42681. }
  42682. /**
  42683. * The null engine class provides support for headless version of babylon.js.
  42684. * This can be used in server side scenario or for testing purposes
  42685. */
  42686. export class NullEngine extends Engine {
  42687. private _options;
  42688. /**
  42689. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  42690. */
  42691. isDeterministicLockStep(): boolean;
  42692. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  42693. getLockstepMaxSteps(): number;
  42694. /**
  42695. * Sets hardware scaling, used to save performance if needed
  42696. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  42697. */
  42698. getHardwareScalingLevel(): number;
  42699. constructor(options?: NullEngineOptions);
  42700. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42701. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  42702. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  42703. getRenderWidth(useScreen?: boolean): number;
  42704. getRenderHeight(useScreen?: boolean): number;
  42705. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  42706. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  42707. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  42708. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  42709. bindSamplers(effect: Effect): void;
  42710. enableEffect(effect: Effect): void;
  42711. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  42712. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  42713. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  42714. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  42715. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  42716. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  42717. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  42718. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  42719. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  42720. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  42721. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  42722. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  42723. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  42724. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  42725. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  42726. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42727. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  42728. setFloat(uniform: WebGLUniformLocation, value: number): void;
  42729. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  42730. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  42731. setBool(uniform: WebGLUniformLocation, bool: number): void;
  42732. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  42733. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  42734. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  42735. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  42736. bindBuffers(vertexBuffers: {
  42737. [key: string]: VertexBuffer;
  42738. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  42739. wipeCaches(bruteForce?: boolean): void;
  42740. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  42741. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  42742. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  42743. /** @hidden */
  42744. _createTexture(): WebGLTexture;
  42745. /** @hidden */
  42746. _releaseTexture(texture: InternalTexture): void;
  42747. 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;
  42748. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  42749. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  42750. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  42751. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  42752. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  42753. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  42754. areAllEffectsReady(): boolean;
  42755. /**
  42756. * @hidden
  42757. * Get the current error code of the webGL context
  42758. * @returns the error code
  42759. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  42760. */
  42761. getError(): number;
  42762. /** @hidden */
  42763. _getUnpackAlignement(): number;
  42764. /** @hidden */
  42765. _unpackFlipY(value: boolean): void;
  42766. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  42767. /**
  42768. * Updates a dynamic vertex buffer.
  42769. * @param vertexBuffer the vertex buffer to update
  42770. * @param data the data used to update the vertex buffer
  42771. * @param byteOffset the byte offset of the data (optional)
  42772. * @param byteLength the byte length of the data (optional)
  42773. */
  42774. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  42775. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  42776. /** @hidden */
  42777. _bindTexture(channel: number, texture: InternalTexture): void;
  42778. /** @hidden */
  42779. _releaseBuffer(buffer: WebGLBuffer): boolean;
  42780. releaseEffects(): void;
  42781. displayLoadingUI(): void;
  42782. hideLoadingUI(): void;
  42783. /** @hidden */
  42784. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42785. /** @hidden */
  42786. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42787. /** @hidden */
  42788. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  42789. /** @hidden */
  42790. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  42791. }
  42792. }
  42793. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  42794. import { Nullable, int } from "babylonjs/types";
  42795. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  42796. /** @hidden */
  42797. export class _OcclusionDataStorage {
  42798. /** @hidden */
  42799. occlusionInternalRetryCounter: number;
  42800. /** @hidden */
  42801. isOcclusionQueryInProgress: boolean;
  42802. /** @hidden */
  42803. isOccluded: boolean;
  42804. /** @hidden */
  42805. occlusionRetryCount: number;
  42806. /** @hidden */
  42807. occlusionType: number;
  42808. /** @hidden */
  42809. occlusionQueryAlgorithmType: number;
  42810. }
  42811. module "babylonjs/Engines/engine" {
  42812. interface Engine {
  42813. /**
  42814. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  42815. * @return the new query
  42816. */
  42817. createQuery(): WebGLQuery;
  42818. /**
  42819. * Delete and release a webGL query
  42820. * @param query defines the query to delete
  42821. * @return the current engine
  42822. */
  42823. deleteQuery(query: WebGLQuery): Engine;
  42824. /**
  42825. * Check if a given query has resolved and got its value
  42826. * @param query defines the query to check
  42827. * @returns true if the query got its value
  42828. */
  42829. isQueryResultAvailable(query: WebGLQuery): boolean;
  42830. /**
  42831. * Gets the value of a given query
  42832. * @param query defines the query to check
  42833. * @returns the value of the query
  42834. */
  42835. getQueryResult(query: WebGLQuery): number;
  42836. /**
  42837. * Initiates an occlusion query
  42838. * @param algorithmType defines the algorithm to use
  42839. * @param query defines the query to use
  42840. * @returns the current engine
  42841. * @see http://doc.babylonjs.com/features/occlusionquery
  42842. */
  42843. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  42844. /**
  42845. * Ends an occlusion query
  42846. * @see http://doc.babylonjs.com/features/occlusionquery
  42847. * @param algorithmType defines the algorithm to use
  42848. * @returns the current engine
  42849. */
  42850. endOcclusionQuery(algorithmType: number): Engine;
  42851. /**
  42852. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  42853. * Please note that only one query can be issued at a time
  42854. * @returns a time token used to track the time span
  42855. */
  42856. startTimeQuery(): Nullable<_TimeToken>;
  42857. /**
  42858. * Ends a time query
  42859. * @param token defines the token used to measure the time span
  42860. * @returns the time spent (in ns)
  42861. */
  42862. endTimeQuery(token: _TimeToken): int;
  42863. /** @hidden */
  42864. _currentNonTimestampToken: Nullable<_TimeToken>;
  42865. /** @hidden */
  42866. _createTimeQuery(): WebGLQuery;
  42867. /** @hidden */
  42868. _deleteTimeQuery(query: WebGLQuery): void;
  42869. /** @hidden */
  42870. _getGlAlgorithmType(algorithmType: number): number;
  42871. /** @hidden */
  42872. _getTimeQueryResult(query: WebGLQuery): any;
  42873. /** @hidden */
  42874. _getTimeQueryAvailability(query: WebGLQuery): any;
  42875. }
  42876. }
  42877. module "babylonjs/Meshes/abstractMesh" {
  42878. interface AbstractMesh {
  42879. /**
  42880. * Backing filed
  42881. * @hidden
  42882. */
  42883. __occlusionDataStorage: _OcclusionDataStorage;
  42884. /**
  42885. * Access property
  42886. * @hidden
  42887. */
  42888. _occlusionDataStorage: _OcclusionDataStorage;
  42889. /**
  42890. * 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.
  42891. * The default value is -1 which means don't break the query and wait till the result
  42892. * @see http://doc.babylonjs.com/features/occlusionquery
  42893. */
  42894. occlusionRetryCount: number;
  42895. /**
  42896. * 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:
  42897. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  42898. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  42899. * * 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.
  42900. * @see http://doc.babylonjs.com/features/occlusionquery
  42901. */
  42902. occlusionType: number;
  42903. /**
  42904. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  42905. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  42906. * * 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.
  42907. * @see http://doc.babylonjs.com/features/occlusionquery
  42908. */
  42909. occlusionQueryAlgorithmType: number;
  42910. /**
  42911. * 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
  42912. * @see http://doc.babylonjs.com/features/occlusionquery
  42913. */
  42914. isOccluded: boolean;
  42915. /**
  42916. * Flag to check the progress status of the query
  42917. * @see http://doc.babylonjs.com/features/occlusionquery
  42918. */
  42919. isOcclusionQueryInProgress: boolean;
  42920. }
  42921. }
  42922. }
  42923. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  42924. import { Nullable } from "babylonjs/types";
  42925. /** @hidden */
  42926. export var _forceTransformFeedbackToBundle: boolean;
  42927. module "babylonjs/Engines/engine" {
  42928. interface Engine {
  42929. /**
  42930. * Creates a webGL transform feedback object
  42931. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  42932. * @returns the webGL transform feedback object
  42933. */
  42934. createTransformFeedback(): WebGLTransformFeedback;
  42935. /**
  42936. * Delete a webGL transform feedback object
  42937. * @param value defines the webGL transform feedback object to delete
  42938. */
  42939. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  42940. /**
  42941. * Bind a webGL transform feedback object to the webgl context
  42942. * @param value defines the webGL transform feedback object to bind
  42943. */
  42944. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  42945. /**
  42946. * Begins a transform feedback operation
  42947. * @param usePoints defines if points or triangles must be used
  42948. */
  42949. beginTransformFeedback(usePoints: boolean): void;
  42950. /**
  42951. * Ends a transform feedback operation
  42952. */
  42953. endTransformFeedback(): void;
  42954. /**
  42955. * Specify the varyings to use with transform feedback
  42956. * @param program defines the associated webGL program
  42957. * @param value defines the list of strings representing the varying names
  42958. */
  42959. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  42960. /**
  42961. * Bind a webGL buffer for a transform feedback operation
  42962. * @param value defines the webGL buffer to bind
  42963. */
  42964. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  42965. }
  42966. }
  42967. }
  42968. declare module "babylonjs/Engines/Extensions/index" {
  42969. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  42970. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  42971. export * from "babylonjs/Engines/Extensions/engine.multiview";
  42972. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  42973. }
  42974. declare module "babylonjs/Engines/index" {
  42975. export * from "babylonjs/Engines/constants";
  42976. export * from "babylonjs/Engines/engine";
  42977. export * from "babylonjs/Engines/engineStore";
  42978. export * from "babylonjs/Engines/nullEngine";
  42979. export * from "babylonjs/Engines/Extensions/index";
  42980. }
  42981. declare module "babylonjs/Events/clipboardEvents" {
  42982. /**
  42983. * Gather the list of clipboard event types as constants.
  42984. */
  42985. export class ClipboardEventTypes {
  42986. /**
  42987. * The clipboard event is fired when a copy command is active (pressed).
  42988. */
  42989. static readonly COPY: number;
  42990. /**
  42991. * The clipboard event is fired when a cut command is active (pressed).
  42992. */
  42993. static readonly CUT: number;
  42994. /**
  42995. * The clipboard event is fired when a paste command is active (pressed).
  42996. */
  42997. static readonly PASTE: number;
  42998. }
  42999. /**
  43000. * This class is used to store clipboard related info for the onClipboardObservable event.
  43001. */
  43002. export class ClipboardInfo {
  43003. /**
  43004. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43005. */
  43006. type: number;
  43007. /**
  43008. * Defines the related dom event
  43009. */
  43010. event: ClipboardEvent;
  43011. /**
  43012. *Creates an instance of ClipboardInfo.
  43013. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  43014. * @param event Defines the related dom event
  43015. */
  43016. constructor(
  43017. /**
  43018. * Defines the type of event (BABYLON.ClipboardEventTypes)
  43019. */
  43020. type: number,
  43021. /**
  43022. * Defines the related dom event
  43023. */
  43024. event: ClipboardEvent);
  43025. /**
  43026. * Get the clipboard event's type from the keycode.
  43027. * @param keyCode Defines the keyCode for the current keyboard event.
  43028. * @return {number}
  43029. */
  43030. static GetTypeFromCharacter(keyCode: number): number;
  43031. }
  43032. }
  43033. declare module "babylonjs/Events/index" {
  43034. export * from "babylonjs/Events/keyboardEvents";
  43035. export * from "babylonjs/Events/pointerEvents";
  43036. export * from "babylonjs/Events/clipboardEvents";
  43037. }
  43038. declare module "babylonjs/Loading/sceneLoader" {
  43039. import { Observable } from "babylonjs/Misc/observable";
  43040. import { Nullable } from "babylonjs/types";
  43041. import { Scene } from "babylonjs/scene";
  43042. import { Engine } from "babylonjs/Engines/engine";
  43043. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43044. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  43045. import { AssetContainer } from "babylonjs/assetContainer";
  43046. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  43047. import { Skeleton } from "babylonjs/Bones/skeleton";
  43048. /**
  43049. * Class used to represent data loading progression
  43050. */
  43051. export class SceneLoaderProgressEvent {
  43052. /** defines if data length to load can be evaluated */
  43053. readonly lengthComputable: boolean;
  43054. /** defines the loaded data length */
  43055. readonly loaded: number;
  43056. /** defines the data length to load */
  43057. readonly total: number;
  43058. /**
  43059. * Create a new progress event
  43060. * @param lengthComputable defines if data length to load can be evaluated
  43061. * @param loaded defines the loaded data length
  43062. * @param total defines the data length to load
  43063. */
  43064. constructor(
  43065. /** defines if data length to load can be evaluated */
  43066. lengthComputable: boolean,
  43067. /** defines the loaded data length */
  43068. loaded: number,
  43069. /** defines the data length to load */
  43070. total: number);
  43071. /**
  43072. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  43073. * @param event defines the source event
  43074. * @returns a new SceneLoaderProgressEvent
  43075. */
  43076. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  43077. }
  43078. /**
  43079. * Interface used by SceneLoader plugins to define supported file extensions
  43080. */
  43081. export interface ISceneLoaderPluginExtensions {
  43082. /**
  43083. * Defines the list of supported extensions
  43084. */
  43085. [extension: string]: {
  43086. isBinary: boolean;
  43087. };
  43088. }
  43089. /**
  43090. * Interface used by SceneLoader plugin factory
  43091. */
  43092. export interface ISceneLoaderPluginFactory {
  43093. /**
  43094. * Defines the name of the factory
  43095. */
  43096. name: string;
  43097. /**
  43098. * Function called to create a new plugin
  43099. * @return the new plugin
  43100. */
  43101. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  43102. /**
  43103. * Boolean indicating if the plugin can direct load specific data
  43104. */
  43105. canDirectLoad?: (data: string) => boolean;
  43106. }
  43107. /**
  43108. * Interface used to define a SceneLoader plugin
  43109. */
  43110. export interface ISceneLoaderPlugin {
  43111. /**
  43112. * The friendly name of this plugin.
  43113. */
  43114. name: string;
  43115. /**
  43116. * The file extensions supported by this plugin.
  43117. */
  43118. extensions: string | ISceneLoaderPluginExtensions;
  43119. /**
  43120. * Import meshes into a scene.
  43121. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43122. * @param scene The scene to import into
  43123. * @param data The data to import
  43124. * @param rootUrl The root url for scene and resources
  43125. * @param meshes The meshes array to import into
  43126. * @param particleSystems The particle systems array to import into
  43127. * @param skeletons The skeletons array to import into
  43128. * @param onError The callback when import fails
  43129. * @returns True if successful or false otherwise
  43130. */
  43131. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  43132. /**
  43133. * Load into a scene.
  43134. * @param scene The scene to load into
  43135. * @param data The data to import
  43136. * @param rootUrl The root url for scene and resources
  43137. * @param onError The callback when import fails
  43138. * @returns true if successful or false otherwise
  43139. */
  43140. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  43141. /**
  43142. * The callback that returns true if the data can be directly loaded.
  43143. */
  43144. canDirectLoad?: (data: string) => boolean;
  43145. /**
  43146. * The callback that allows custom handling of the root url based on the response url.
  43147. */
  43148. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43149. /**
  43150. * Load into an asset container.
  43151. * @param scene The scene to load into
  43152. * @param data The data to import
  43153. * @param rootUrl The root url for scene and resources
  43154. * @param onError The callback when import fails
  43155. * @returns The loaded asset container
  43156. */
  43157. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  43158. }
  43159. /**
  43160. * Interface used to define an async SceneLoader plugin
  43161. */
  43162. export interface ISceneLoaderPluginAsync {
  43163. /**
  43164. * The friendly name of this plugin.
  43165. */
  43166. name: string;
  43167. /**
  43168. * The file extensions supported by this plugin.
  43169. */
  43170. extensions: string | ISceneLoaderPluginExtensions;
  43171. /**
  43172. * Import meshes into a scene.
  43173. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43174. * @param scene The scene to import into
  43175. * @param data The data to import
  43176. * @param rootUrl The root url for scene and resources
  43177. * @param onProgress The callback when the load progresses
  43178. * @param fileName Defines the name of the file to load
  43179. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  43180. */
  43181. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  43182. meshes: AbstractMesh[];
  43183. particleSystems: IParticleSystem[];
  43184. skeletons: Skeleton[];
  43185. animationGroups: AnimationGroup[];
  43186. }>;
  43187. /**
  43188. * Load into a scene.
  43189. * @param scene The scene to load into
  43190. * @param data The data to import
  43191. * @param rootUrl The root url for scene and resources
  43192. * @param onProgress The callback when the load progresses
  43193. * @param fileName Defines the name of the file to load
  43194. * @returns Nothing
  43195. */
  43196. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  43197. /**
  43198. * The callback that returns true if the data can be directly loaded.
  43199. */
  43200. canDirectLoad?: (data: string) => boolean;
  43201. /**
  43202. * The callback that allows custom handling of the root url based on the response url.
  43203. */
  43204. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  43205. /**
  43206. * Load into an asset container.
  43207. * @param scene The scene to load into
  43208. * @param data The data to import
  43209. * @param rootUrl The root url for scene and resources
  43210. * @param onProgress The callback when the load progresses
  43211. * @param fileName Defines the name of the file to load
  43212. * @returns The loaded asset container
  43213. */
  43214. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  43215. }
  43216. /**
  43217. * Class used to load scene from various file formats using registered plugins
  43218. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  43219. */
  43220. export class SceneLoader {
  43221. /**
  43222. * No logging while loading
  43223. */
  43224. static readonly NO_LOGGING: number;
  43225. /**
  43226. * Minimal logging while loading
  43227. */
  43228. static readonly MINIMAL_LOGGING: number;
  43229. /**
  43230. * Summary logging while loading
  43231. */
  43232. static readonly SUMMARY_LOGGING: number;
  43233. /**
  43234. * Detailled logging while loading
  43235. */
  43236. static readonly DETAILED_LOGGING: number;
  43237. /**
  43238. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  43239. */
  43240. static ForceFullSceneLoadingForIncremental: boolean;
  43241. /**
  43242. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  43243. */
  43244. static ShowLoadingScreen: boolean;
  43245. /**
  43246. * Defines the current logging level (while loading the scene)
  43247. * @ignorenaming
  43248. */
  43249. static loggingLevel: number;
  43250. /**
  43251. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  43252. */
  43253. static CleanBoneMatrixWeights: boolean;
  43254. /**
  43255. * Event raised when a plugin is used to load a scene
  43256. */
  43257. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  43258. private static _registeredPlugins;
  43259. private static _getDefaultPlugin;
  43260. private static _getPluginForExtension;
  43261. private static _getPluginForDirectLoad;
  43262. private static _getPluginForFilename;
  43263. private static _getDirectLoad;
  43264. private static _loadData;
  43265. private static _getFileInfo;
  43266. /**
  43267. * Gets a plugin that can load the given extension
  43268. * @param extension defines the extension to load
  43269. * @returns a plugin or null if none works
  43270. */
  43271. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  43272. /**
  43273. * Gets a boolean indicating that the given extension can be loaded
  43274. * @param extension defines the extension to load
  43275. * @returns true if the extension is supported
  43276. */
  43277. static IsPluginForExtensionAvailable(extension: string): boolean;
  43278. /**
  43279. * Adds a new plugin to the list of registered plugins
  43280. * @param plugin defines the plugin to add
  43281. */
  43282. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  43283. /**
  43284. * Import meshes into a scene
  43285. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43286. * @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)
  43287. * @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)
  43288. * @param scene the instance of BABYLON.Scene to append to
  43289. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  43290. * @param onProgress a callback with a progress event for each file being loaded
  43291. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43292. * @param pluginExtension the extension used to determine the plugin
  43293. * @returns The loaded plugin
  43294. */
  43295. 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>;
  43296. /**
  43297. * Import meshes into a scene
  43298. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  43299. * @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)
  43300. * @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)
  43301. * @param scene the instance of BABYLON.Scene to append to
  43302. * @param onProgress a callback with a progress event for each file being loaded
  43303. * @param pluginExtension the extension used to determine the plugin
  43304. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  43305. */
  43306. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  43307. meshes: AbstractMesh[];
  43308. particleSystems: IParticleSystem[];
  43309. skeletons: Skeleton[];
  43310. animationGroups: AnimationGroup[];
  43311. }>;
  43312. /**
  43313. * Load a scene
  43314. * @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)
  43315. * @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)
  43316. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43317. * @param onSuccess a callback with the scene when import succeeds
  43318. * @param onProgress a callback with a progress event for each file being loaded
  43319. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43320. * @param pluginExtension the extension used to determine the plugin
  43321. * @returns The loaded plugin
  43322. */
  43323. 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>;
  43324. /**
  43325. * Load a scene
  43326. * @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)
  43327. * @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)
  43328. * @param engine is the instance of BABYLON.Engine to use to create the scene
  43329. * @param onProgress a callback with a progress event for each file being loaded
  43330. * @param pluginExtension the extension used to determine the plugin
  43331. * @returns The loaded scene
  43332. */
  43333. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43334. /**
  43335. * Append a scene
  43336. * @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)
  43337. * @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)
  43338. * @param scene is the instance of BABYLON.Scene to append to
  43339. * @param onSuccess a callback with the scene when import succeeds
  43340. * @param onProgress a callback with a progress event for each file being loaded
  43341. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43342. * @param pluginExtension the extension used to determine the plugin
  43343. * @returns The loaded plugin
  43344. */
  43345. 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>;
  43346. /**
  43347. * Append a scene
  43348. * @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)
  43349. * @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)
  43350. * @param scene is the instance of BABYLON.Scene to append to
  43351. * @param onProgress a callback with a progress event for each file being loaded
  43352. * @param pluginExtension the extension used to determine the plugin
  43353. * @returns The given scene
  43354. */
  43355. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  43356. /**
  43357. * Load a scene into an asset container
  43358. * @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)
  43359. * @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)
  43360. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  43361. * @param onSuccess a callback with the scene when import succeeds
  43362. * @param onProgress a callback with a progress event for each file being loaded
  43363. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  43364. * @param pluginExtension the extension used to determine the plugin
  43365. * @returns The loaded plugin
  43366. */
  43367. 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>;
  43368. /**
  43369. * Load a scene into an asset container
  43370. * @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)
  43371. * @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)
  43372. * @param scene is the instance of Scene to append to
  43373. * @param onProgress a callback with a progress event for each file being loaded
  43374. * @param pluginExtension the extension used to determine the plugin
  43375. * @returns The loaded asset container
  43376. */
  43377. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  43378. }
  43379. }
  43380. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  43381. import { Scene } from "babylonjs/scene";
  43382. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43383. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43384. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43385. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43386. /**
  43387. * Google Daydream controller
  43388. */
  43389. export class DaydreamController extends WebVRController {
  43390. /**
  43391. * Base Url for the controller model.
  43392. */
  43393. static MODEL_BASE_URL: string;
  43394. /**
  43395. * File name for the controller model.
  43396. */
  43397. static MODEL_FILENAME: string;
  43398. /**
  43399. * Gamepad Id prefix used to identify Daydream Controller.
  43400. */
  43401. static readonly GAMEPAD_ID_PREFIX: string;
  43402. /**
  43403. * Creates a new DaydreamController from a gamepad
  43404. * @param vrGamepad the gamepad that the controller should be created from
  43405. */
  43406. constructor(vrGamepad: any);
  43407. /**
  43408. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43409. * @param scene scene in which to add meshes
  43410. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43411. */
  43412. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43413. /**
  43414. * Called once for each button that changed state since the last frame
  43415. * @param buttonIdx Which button index changed
  43416. * @param state New state of the button
  43417. * @param changes Which properties on the state changed since last frame
  43418. */
  43419. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43420. }
  43421. }
  43422. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  43423. import { Scene } from "babylonjs/scene";
  43424. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43425. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43426. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43427. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43428. /**
  43429. * Gear VR Controller
  43430. */
  43431. export class GearVRController extends WebVRController {
  43432. /**
  43433. * Base Url for the controller model.
  43434. */
  43435. static MODEL_BASE_URL: string;
  43436. /**
  43437. * File name for the controller model.
  43438. */
  43439. static MODEL_FILENAME: string;
  43440. /**
  43441. * Gamepad Id prefix used to identify this controller.
  43442. */
  43443. static readonly GAMEPAD_ID_PREFIX: string;
  43444. private readonly _buttonIndexToObservableNameMap;
  43445. /**
  43446. * Creates a new GearVRController from a gamepad
  43447. * @param vrGamepad the gamepad that the controller should be created from
  43448. */
  43449. constructor(vrGamepad: any);
  43450. /**
  43451. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43452. * @param scene scene in which to add meshes
  43453. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43454. */
  43455. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43456. /**
  43457. * Called once for each button that changed state since the last frame
  43458. * @param buttonIdx Which button index changed
  43459. * @param state New state of the button
  43460. * @param changes Which properties on the state changed since last frame
  43461. */
  43462. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43463. }
  43464. }
  43465. declare module "babylonjs/Gamepads/Controllers/genericController" {
  43466. import { Scene } from "babylonjs/scene";
  43467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43468. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43469. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43470. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43471. /**
  43472. * Generic Controller
  43473. */
  43474. export class GenericController extends WebVRController {
  43475. /**
  43476. * Base Url for the controller model.
  43477. */
  43478. static readonly MODEL_BASE_URL: string;
  43479. /**
  43480. * File name for the controller model.
  43481. */
  43482. static readonly MODEL_FILENAME: string;
  43483. /**
  43484. * Creates a new GenericController from a gamepad
  43485. * @param vrGamepad the gamepad that the controller should be created from
  43486. */
  43487. constructor(vrGamepad: any);
  43488. /**
  43489. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43490. * @param scene scene in which to add meshes
  43491. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43492. */
  43493. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43494. /**
  43495. * Called once for each button that changed state since the last frame
  43496. * @param buttonIdx Which button index changed
  43497. * @param state New state of the button
  43498. * @param changes Which properties on the state changed since last frame
  43499. */
  43500. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43501. }
  43502. }
  43503. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  43504. import { Observable } from "babylonjs/Misc/observable";
  43505. import { Scene } from "babylonjs/scene";
  43506. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43507. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43508. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43509. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43510. /**
  43511. * Oculus Touch Controller
  43512. */
  43513. export class OculusTouchController extends WebVRController {
  43514. /**
  43515. * Base Url for the controller model.
  43516. */
  43517. static MODEL_BASE_URL: string;
  43518. /**
  43519. * File name for the left controller model.
  43520. */
  43521. static MODEL_LEFT_FILENAME: string;
  43522. /**
  43523. * File name for the right controller model.
  43524. */
  43525. static MODEL_RIGHT_FILENAME: string;
  43526. /**
  43527. * Fired when the secondary trigger on this controller is modified
  43528. */
  43529. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  43530. /**
  43531. * Fired when the thumb rest on this controller is modified
  43532. */
  43533. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  43534. /**
  43535. * Creates a new OculusTouchController from a gamepad
  43536. * @param vrGamepad the gamepad that the controller should be created from
  43537. */
  43538. constructor(vrGamepad: any);
  43539. /**
  43540. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43541. * @param scene scene in which to add meshes
  43542. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43543. */
  43544. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43545. /**
  43546. * Fired when the A button on this controller is modified
  43547. */
  43548. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43549. /**
  43550. * Fired when the B button on this controller is modified
  43551. */
  43552. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43553. /**
  43554. * Fired when the X button on this controller is modified
  43555. */
  43556. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43557. /**
  43558. * Fired when the Y button on this controller is modified
  43559. */
  43560. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43561. /**
  43562. * Called once for each button that changed state since the last frame
  43563. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  43564. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  43565. * 2) secondary trigger (same)
  43566. * 3) A (right) X (left), touch, pressed = value
  43567. * 4) B / Y
  43568. * 5) thumb rest
  43569. * @param buttonIdx Which button index changed
  43570. * @param state New state of the button
  43571. * @param changes Which properties on the state changed since last frame
  43572. */
  43573. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43574. }
  43575. }
  43576. declare module "babylonjs/Gamepads/Controllers/viveController" {
  43577. import { Scene } from "babylonjs/scene";
  43578. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43579. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43580. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43581. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43582. import { Observable } from "babylonjs/Misc/observable";
  43583. /**
  43584. * Vive Controller
  43585. */
  43586. export class ViveController extends WebVRController {
  43587. /**
  43588. * Base Url for the controller model.
  43589. */
  43590. static MODEL_BASE_URL: string;
  43591. /**
  43592. * File name for the controller model.
  43593. */
  43594. static MODEL_FILENAME: string;
  43595. /**
  43596. * Creates a new ViveController from a gamepad
  43597. * @param vrGamepad the gamepad that the controller should be created from
  43598. */
  43599. constructor(vrGamepad: any);
  43600. /**
  43601. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43602. * @param scene scene in which to add meshes
  43603. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43604. */
  43605. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  43606. /**
  43607. * Fired when the left button on this controller is modified
  43608. */
  43609. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43610. /**
  43611. * Fired when the right button on this controller is modified
  43612. */
  43613. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43614. /**
  43615. * Fired when the menu button on this controller is modified
  43616. */
  43617. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43618. /**
  43619. * Called once for each button that changed state since the last frame
  43620. * Vive mapping:
  43621. * 0: touchpad
  43622. * 1: trigger
  43623. * 2: left AND right buttons
  43624. * 3: menu button
  43625. * @param buttonIdx Which button index changed
  43626. * @param state New state of the button
  43627. * @param changes Which properties on the state changed since last frame
  43628. */
  43629. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43630. }
  43631. }
  43632. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  43633. import { Observable } from "babylonjs/Misc/observable";
  43634. import { Scene } from "babylonjs/scene";
  43635. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43636. import { Ray } from "babylonjs/Culling/ray";
  43637. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  43638. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43639. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  43640. /**
  43641. * Defines the WindowsMotionController object that the state of the windows motion controller
  43642. */
  43643. export class WindowsMotionController extends WebVRController {
  43644. /**
  43645. * The base url used to load the left and right controller models
  43646. */
  43647. static MODEL_BASE_URL: string;
  43648. /**
  43649. * The name of the left controller model file
  43650. */
  43651. static MODEL_LEFT_FILENAME: string;
  43652. /**
  43653. * The name of the right controller model file
  43654. */
  43655. static MODEL_RIGHT_FILENAME: string;
  43656. /**
  43657. * The controller name prefix for this controller type
  43658. */
  43659. static readonly GAMEPAD_ID_PREFIX: string;
  43660. /**
  43661. * The controller id pattern for this controller type
  43662. */
  43663. private static readonly GAMEPAD_ID_PATTERN;
  43664. private _loadedMeshInfo;
  43665. private readonly _mapping;
  43666. /**
  43667. * Fired when the trackpad on this controller is clicked
  43668. */
  43669. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  43670. /**
  43671. * Fired when the trackpad on this controller is modified
  43672. */
  43673. onTrackpadValuesChangedObservable: Observable<StickValues>;
  43674. /**
  43675. * The current x and y values of this controller's trackpad
  43676. */
  43677. trackpad: StickValues;
  43678. /**
  43679. * Creates a new WindowsMotionController from a gamepad
  43680. * @param vrGamepad the gamepad that the controller should be created from
  43681. */
  43682. constructor(vrGamepad: any);
  43683. /**
  43684. * Fired when the trigger on this controller is modified
  43685. */
  43686. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43687. /**
  43688. * Fired when the menu button on this controller is modified
  43689. */
  43690. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43691. /**
  43692. * Fired when the grip button on this controller is modified
  43693. */
  43694. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43695. /**
  43696. * Fired when the thumbstick button on this controller is modified
  43697. */
  43698. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43699. /**
  43700. * Fired when the touchpad button on this controller is modified
  43701. */
  43702. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  43703. /**
  43704. * Fired when the touchpad values on this controller are modified
  43705. */
  43706. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  43707. private _updateTrackpad;
  43708. /**
  43709. * Called once per frame by the engine.
  43710. */
  43711. update(): void;
  43712. /**
  43713. * Called once for each button that changed state since the last frame
  43714. * @param buttonIdx Which button index changed
  43715. * @param state New state of the button
  43716. * @param changes Which properties on the state changed since last frame
  43717. */
  43718. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  43719. /**
  43720. * Moves the buttons on the controller mesh based on their current state
  43721. * @param buttonName the name of the button to move
  43722. * @param buttonValue the value of the button which determines the buttons new position
  43723. */
  43724. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  43725. /**
  43726. * Moves the axis on the controller mesh based on its current state
  43727. * @param axis the index of the axis
  43728. * @param axisValue the value of the axis which determines the meshes new position
  43729. * @hidden
  43730. */
  43731. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  43732. /**
  43733. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  43734. * @param scene scene in which to add meshes
  43735. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  43736. */
  43737. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  43738. /**
  43739. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  43740. * can be transformed by button presses and axes values, based on this._mapping.
  43741. *
  43742. * @param scene scene in which the meshes exist
  43743. * @param meshes list of meshes that make up the controller model to process
  43744. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  43745. */
  43746. private processModel;
  43747. private createMeshInfo;
  43748. /**
  43749. * Gets the ray of the controller in the direction the controller is pointing
  43750. * @param length the length the resulting ray should be
  43751. * @returns a ray in the direction the controller is pointing
  43752. */
  43753. getForwardRay(length?: number): Ray;
  43754. /**
  43755. * Disposes of the controller
  43756. */
  43757. dispose(): void;
  43758. }
  43759. }
  43760. declare module "babylonjs/Gamepads/Controllers/index" {
  43761. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  43762. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  43763. export * from "babylonjs/Gamepads/Controllers/genericController";
  43764. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  43765. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  43766. export * from "babylonjs/Gamepads/Controllers/viveController";
  43767. export * from "babylonjs/Gamepads/Controllers/webVRController";
  43768. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  43769. }
  43770. declare module "babylonjs/Gamepads/index" {
  43771. export * from "babylonjs/Gamepads/Controllers/index";
  43772. export * from "babylonjs/Gamepads/gamepad";
  43773. export * from "babylonjs/Gamepads/gamepadManager";
  43774. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  43775. export * from "babylonjs/Gamepads/xboxGamepad";
  43776. }
  43777. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  43778. import { Observable } from "babylonjs/Misc/observable";
  43779. import { Nullable } from "babylonjs/types";
  43780. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43781. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43782. import { Mesh } from "babylonjs/Meshes/mesh";
  43783. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43784. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43785. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43786. /**
  43787. * Single axis scale gizmo
  43788. */
  43789. export class AxisScaleGizmo extends Gizmo {
  43790. private _coloredMaterial;
  43791. /**
  43792. * Drag behavior responsible for the gizmos dragging interactions
  43793. */
  43794. dragBehavior: PointerDragBehavior;
  43795. private _pointerObserver;
  43796. /**
  43797. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  43798. */
  43799. snapDistance: number;
  43800. /**
  43801. * Event that fires each time the gizmo snaps to a new location.
  43802. * * snapDistance is the the change in distance
  43803. */
  43804. onSnapObservable: Observable<{
  43805. snapDistance: number;
  43806. }>;
  43807. /**
  43808. * If the scaling operation should be done on all axis (default: false)
  43809. */
  43810. uniformScaling: boolean;
  43811. /**
  43812. * Creates an AxisScaleGizmo
  43813. * @param gizmoLayer The utility layer the gizmo will be added to
  43814. * @param dragAxis The axis which the gizmo will be able to scale on
  43815. * @param color The color of the gizmo
  43816. */
  43817. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43818. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43819. /**
  43820. * Disposes of the gizmo
  43821. */
  43822. dispose(): void;
  43823. /**
  43824. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  43825. * @param mesh The mesh to replace the default mesh of the gizmo
  43826. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  43827. */
  43828. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  43829. }
  43830. }
  43831. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  43832. import { Observable } from "babylonjs/Misc/observable";
  43833. import { Nullable } from "babylonjs/types";
  43834. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43835. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43836. import { Mesh } from "babylonjs/Meshes/mesh";
  43837. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43838. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43839. import "babylonjs/Meshes/Builders/boxBuilder";
  43840. /**
  43841. * Bounding box gizmo
  43842. */
  43843. export class BoundingBoxGizmo extends Gizmo {
  43844. private _lineBoundingBox;
  43845. private _rotateSpheresParent;
  43846. private _scaleBoxesParent;
  43847. private _boundingDimensions;
  43848. private _renderObserver;
  43849. private _pointerObserver;
  43850. private _scaleDragSpeed;
  43851. private _tmpQuaternion;
  43852. private _tmpVector;
  43853. private _tmpRotationMatrix;
  43854. /**
  43855. * 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)
  43856. */
  43857. ignoreChildren: boolean;
  43858. /**
  43859. * 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)
  43860. */
  43861. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  43862. /**
  43863. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  43864. */
  43865. rotationSphereSize: number;
  43866. /**
  43867. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  43868. */
  43869. scaleBoxSize: number;
  43870. /**
  43871. * 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)
  43872. */
  43873. fixedDragMeshScreenSize: boolean;
  43874. /**
  43875. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  43876. */
  43877. fixedDragMeshScreenSizeDistanceFactor: number;
  43878. /**
  43879. * Fired when a rotation sphere or scale box is dragged
  43880. */
  43881. onDragStartObservable: Observable<{}>;
  43882. /**
  43883. * Fired when a scale box is dragged
  43884. */
  43885. onScaleBoxDragObservable: Observable<{}>;
  43886. /**
  43887. * Fired when a scale box drag is ended
  43888. */
  43889. onScaleBoxDragEndObservable: Observable<{}>;
  43890. /**
  43891. * Fired when a rotation sphere is dragged
  43892. */
  43893. onRotationSphereDragObservable: Observable<{}>;
  43894. /**
  43895. * Fired when a rotation sphere drag is ended
  43896. */
  43897. onRotationSphereDragEndObservable: Observable<{}>;
  43898. /**
  43899. * 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)
  43900. */
  43901. scalePivot: Nullable<Vector3>;
  43902. /**
  43903. * Mesh used as a pivot to rotate the attached mesh
  43904. */
  43905. private _anchorMesh;
  43906. private _existingMeshScale;
  43907. private _dragMesh;
  43908. private pointerDragBehavior;
  43909. private coloredMaterial;
  43910. private hoverColoredMaterial;
  43911. /**
  43912. * Sets the color of the bounding box gizmo
  43913. * @param color the color to set
  43914. */
  43915. setColor(color: Color3): void;
  43916. /**
  43917. * Creates an BoundingBoxGizmo
  43918. * @param gizmoLayer The utility layer the gizmo will be added to
  43919. * @param color The color of the gizmo
  43920. */
  43921. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  43922. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  43923. private _selectNode;
  43924. /**
  43925. * Updates the bounding box information for the Gizmo
  43926. */
  43927. updateBoundingBox(): void;
  43928. private _updateRotationSpheres;
  43929. private _updateScaleBoxes;
  43930. /**
  43931. * Enables rotation on the specified axis and disables rotation on the others
  43932. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  43933. */
  43934. setEnabledRotationAxis(axis: string): void;
  43935. /**
  43936. * Enables/disables scaling
  43937. * @param enable if scaling should be enabled
  43938. */
  43939. setEnabledScaling(enable: boolean): void;
  43940. private _updateDummy;
  43941. /**
  43942. * Enables a pointer drag behavior on the bounding box of the gizmo
  43943. */
  43944. enableDragBehavior(): void;
  43945. /**
  43946. * Disposes of the gizmo
  43947. */
  43948. dispose(): void;
  43949. /**
  43950. * 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)
  43951. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  43952. * @returns the bounding box mesh with the passed in mesh as a child
  43953. */
  43954. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  43955. /**
  43956. * CustomMeshes are not supported by this gizmo
  43957. * @param mesh The mesh to replace the default mesh of the gizmo
  43958. */
  43959. setCustomMesh(mesh: Mesh): void;
  43960. }
  43961. }
  43962. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  43963. import { Observable } from "babylonjs/Misc/observable";
  43964. import { Nullable } from "babylonjs/types";
  43965. import { Vector3, Color3 } from "babylonjs/Maths/math";
  43966. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43967. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  43968. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  43969. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  43970. import "babylonjs/Meshes/Builders/linesBuilder";
  43971. /**
  43972. * Single plane rotation gizmo
  43973. */
  43974. export class PlaneRotationGizmo extends Gizmo {
  43975. /**
  43976. * Drag behavior responsible for the gizmos dragging interactions
  43977. */
  43978. dragBehavior: PointerDragBehavior;
  43979. private _pointerObserver;
  43980. /**
  43981. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  43982. */
  43983. snapDistance: number;
  43984. /**
  43985. * Event that fires each time the gizmo snaps to a new location.
  43986. * * snapDistance is the the change in distance
  43987. */
  43988. onSnapObservable: Observable<{
  43989. snapDistance: number;
  43990. }>;
  43991. /**
  43992. * Creates a PlaneRotationGizmo
  43993. * @param gizmoLayer The utility layer the gizmo will be added to
  43994. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  43995. * @param color The color of the gizmo
  43996. * @param tessellation Amount of tessellation to be used when creating rotation circles
  43997. */
  43998. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  43999. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  44000. /**
  44001. * Disposes of the gizmo
  44002. */
  44003. dispose(): void;
  44004. }
  44005. }
  44006. declare module "babylonjs/Gizmos/rotationGizmo" {
  44007. import { Observable } from "babylonjs/Misc/observable";
  44008. import { Nullable } from "babylonjs/types";
  44009. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44010. import { Mesh } from "babylonjs/Meshes/mesh";
  44011. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44012. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  44013. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44014. /**
  44015. * Gizmo that enables rotating a mesh along 3 axis
  44016. */
  44017. export class RotationGizmo extends Gizmo {
  44018. /**
  44019. * Internal gizmo used for interactions on the x axis
  44020. */
  44021. xGizmo: PlaneRotationGizmo;
  44022. /**
  44023. * Internal gizmo used for interactions on the y axis
  44024. */
  44025. yGizmo: PlaneRotationGizmo;
  44026. /**
  44027. * Internal gizmo used for interactions on the z axis
  44028. */
  44029. zGizmo: PlaneRotationGizmo;
  44030. /** Fires an event when any of it's sub gizmos are dragged */
  44031. onDragStartObservable: Observable<{}>;
  44032. /** Fires an event when any of it's sub gizmos are released from dragging */
  44033. onDragEndObservable: Observable<{}>;
  44034. attachedMesh: Nullable<AbstractMesh>;
  44035. /**
  44036. * Creates a RotationGizmo
  44037. * @param gizmoLayer The utility layer the gizmo will be added to
  44038. * @param tessellation Amount of tessellation to be used when creating rotation circles
  44039. */
  44040. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  44041. updateGizmoRotationToMatchAttachedMesh: boolean;
  44042. /**
  44043. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44044. */
  44045. snapDistance: number;
  44046. /**
  44047. * Ratio for the scale of the gizmo (Default: 1)
  44048. */
  44049. scaleRatio: number;
  44050. /**
  44051. * Disposes of the gizmo
  44052. */
  44053. dispose(): void;
  44054. /**
  44055. * CustomMeshes are not supported by this gizmo
  44056. * @param mesh The mesh to replace the default mesh of the gizmo
  44057. */
  44058. setCustomMesh(mesh: Mesh): void;
  44059. }
  44060. }
  44061. declare module "babylonjs/Gizmos/positionGizmo" {
  44062. import { Observable } from "babylonjs/Misc/observable";
  44063. import { Nullable } from "babylonjs/types";
  44064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44065. import { Mesh } from "babylonjs/Meshes/mesh";
  44066. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44067. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  44068. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44069. /**
  44070. * Gizmo that enables dragging a mesh along 3 axis
  44071. */
  44072. export class PositionGizmo extends Gizmo {
  44073. /**
  44074. * Internal gizmo used for interactions on the x axis
  44075. */
  44076. xGizmo: AxisDragGizmo;
  44077. /**
  44078. * Internal gizmo used for interactions on the y axis
  44079. */
  44080. yGizmo: AxisDragGizmo;
  44081. /**
  44082. * Internal gizmo used for interactions on the z axis
  44083. */
  44084. zGizmo: AxisDragGizmo;
  44085. /** Fires an event when any of it's sub gizmos are dragged */
  44086. onDragStartObservable: Observable<{}>;
  44087. /** Fires an event when any of it's sub gizmos are released from dragging */
  44088. onDragEndObservable: Observable<{}>;
  44089. attachedMesh: Nullable<AbstractMesh>;
  44090. /**
  44091. * Creates a PositionGizmo
  44092. * @param gizmoLayer The utility layer the gizmo will be added to
  44093. */
  44094. constructor(gizmoLayer?: UtilityLayerRenderer);
  44095. updateGizmoRotationToMatchAttachedMesh: boolean;
  44096. /**
  44097. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44098. */
  44099. snapDistance: number;
  44100. /**
  44101. * Ratio for the scale of the gizmo (Default: 1)
  44102. */
  44103. scaleRatio: number;
  44104. /**
  44105. * Disposes of the gizmo
  44106. */
  44107. dispose(): void;
  44108. /**
  44109. * CustomMeshes are not supported by this gizmo
  44110. * @param mesh The mesh to replace the default mesh of the gizmo
  44111. */
  44112. setCustomMesh(mesh: Mesh): void;
  44113. }
  44114. }
  44115. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  44116. import { Scene } from "babylonjs/scene";
  44117. import { Color4, Vector4 } from "babylonjs/Maths/math";
  44118. import { Mesh } from "babylonjs/Meshes/mesh";
  44119. import { Nullable } from "babylonjs/types";
  44120. /**
  44121. * Class containing static functions to help procedurally build meshes
  44122. */
  44123. export class PolyhedronBuilder {
  44124. /**
  44125. * Creates a polyhedron mesh
  44126. * * 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
  44127. * * The parameter `size` (positive float, default 1) sets the polygon size
  44128. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  44129. * * 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`
  44130. * * 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
  44131. * * 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)`)
  44132. * * 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
  44133. * * 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
  44134. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  44135. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  44136. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  44137. * @param name defines the name of the mesh
  44138. * @param options defines the options used to create the mesh
  44139. * @param scene defines the hosting scene
  44140. * @returns the polyhedron mesh
  44141. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  44142. */
  44143. static CreatePolyhedron(name: string, options: {
  44144. type?: number;
  44145. size?: number;
  44146. sizeX?: number;
  44147. sizeY?: number;
  44148. sizeZ?: number;
  44149. custom?: any;
  44150. faceUV?: Vector4[];
  44151. faceColors?: Color4[];
  44152. flat?: boolean;
  44153. updatable?: boolean;
  44154. sideOrientation?: number;
  44155. frontUVs?: Vector4;
  44156. backUVs?: Vector4;
  44157. }, scene?: Nullable<Scene>): Mesh;
  44158. }
  44159. }
  44160. declare module "babylonjs/Gizmos/scaleGizmo" {
  44161. import { Observable } from "babylonjs/Misc/observable";
  44162. import { Nullable } from "babylonjs/types";
  44163. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44164. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44165. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  44166. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44167. /**
  44168. * Gizmo that enables scaling a mesh along 3 axis
  44169. */
  44170. export class ScaleGizmo extends Gizmo {
  44171. /**
  44172. * Internal gizmo used for interactions on the x axis
  44173. */
  44174. xGizmo: AxisScaleGizmo;
  44175. /**
  44176. * Internal gizmo used for interactions on the y axis
  44177. */
  44178. yGizmo: AxisScaleGizmo;
  44179. /**
  44180. * Internal gizmo used for interactions on the z axis
  44181. */
  44182. zGizmo: AxisScaleGizmo;
  44183. /**
  44184. * Internal gizmo used to scale all axis equally
  44185. */
  44186. uniformScaleGizmo: AxisScaleGizmo;
  44187. /** Fires an event when any of it's sub gizmos are dragged */
  44188. onDragStartObservable: Observable<{}>;
  44189. /** Fires an event when any of it's sub gizmos are released from dragging */
  44190. onDragEndObservable: Observable<{}>;
  44191. attachedMesh: Nullable<AbstractMesh>;
  44192. /**
  44193. * Creates a ScaleGizmo
  44194. * @param gizmoLayer The utility layer the gizmo will be added to
  44195. */
  44196. constructor(gizmoLayer?: UtilityLayerRenderer);
  44197. updateGizmoRotationToMatchAttachedMesh: boolean;
  44198. /**
  44199. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  44200. */
  44201. snapDistance: number;
  44202. /**
  44203. * Ratio for the scale of the gizmo (Default: 1)
  44204. */
  44205. scaleRatio: number;
  44206. /**
  44207. * Disposes of the gizmo
  44208. */
  44209. dispose(): void;
  44210. }
  44211. }
  44212. declare module "babylonjs/Gizmos/gizmoManager" {
  44213. import { Observable } from "babylonjs/Misc/observable";
  44214. import { Nullable } from "babylonjs/types";
  44215. import { Scene, IDisposable } from "babylonjs/scene";
  44216. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44217. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  44218. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  44219. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  44220. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  44221. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  44222. /**
  44223. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  44224. */
  44225. export class GizmoManager implements IDisposable {
  44226. private scene;
  44227. /**
  44228. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  44229. */
  44230. gizmos: {
  44231. positionGizmo: Nullable<PositionGizmo>;
  44232. rotationGizmo: Nullable<RotationGizmo>;
  44233. scaleGizmo: Nullable<ScaleGizmo>;
  44234. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  44235. };
  44236. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  44237. clearGizmoOnEmptyPointerEvent: boolean;
  44238. /** Fires an event when the manager is attached to a mesh */
  44239. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  44240. private _gizmosEnabled;
  44241. private _pointerObserver;
  44242. private _attachedMesh;
  44243. private _boundingBoxColor;
  44244. private _defaultUtilityLayer;
  44245. private _defaultKeepDepthUtilityLayer;
  44246. /**
  44247. * When bounding box gizmo is enabled, this can be used to track drag/end events
  44248. */
  44249. boundingBoxDragBehavior: SixDofDragBehavior;
  44250. /**
  44251. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  44252. */
  44253. attachableMeshes: Nullable<Array<AbstractMesh>>;
  44254. /**
  44255. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  44256. */
  44257. usePointerToAttachGizmos: boolean;
  44258. /**
  44259. * Instatiates a gizmo manager
  44260. * @param scene the scene to overlay the gizmos on top of
  44261. */
  44262. constructor(scene: Scene);
  44263. /**
  44264. * Attaches a set of gizmos to the specified mesh
  44265. * @param mesh The mesh the gizmo's should be attached to
  44266. */
  44267. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  44268. /**
  44269. * If the position gizmo is enabled
  44270. */
  44271. positionGizmoEnabled: boolean;
  44272. /**
  44273. * If the rotation gizmo is enabled
  44274. */
  44275. rotationGizmoEnabled: boolean;
  44276. /**
  44277. * If the scale gizmo is enabled
  44278. */
  44279. scaleGizmoEnabled: boolean;
  44280. /**
  44281. * If the boundingBox gizmo is enabled
  44282. */
  44283. boundingBoxGizmoEnabled: boolean;
  44284. /**
  44285. * Disposes of the gizmo manager
  44286. */
  44287. dispose(): void;
  44288. }
  44289. }
  44290. declare module "babylonjs/Lights/directionalLight" {
  44291. import { Camera } from "babylonjs/Cameras/camera";
  44292. import { Scene } from "babylonjs/scene";
  44293. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44294. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44295. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44296. import { Effect } from "babylonjs/Materials/effect";
  44297. /**
  44298. * A directional light is defined by a direction (what a surprise!).
  44299. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  44300. * 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.
  44301. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44302. */
  44303. export class DirectionalLight extends ShadowLight {
  44304. private _shadowFrustumSize;
  44305. /**
  44306. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  44307. */
  44308. /**
  44309. * Specifies a fix frustum size for the shadow generation.
  44310. */
  44311. shadowFrustumSize: number;
  44312. private _shadowOrthoScale;
  44313. /**
  44314. * Gets the shadow projection scale against the optimal computed one.
  44315. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44316. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44317. */
  44318. /**
  44319. * Sets the shadow projection scale against the optimal computed one.
  44320. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  44321. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  44322. */
  44323. shadowOrthoScale: number;
  44324. /**
  44325. * Automatically compute the projection matrix to best fit (including all the casters)
  44326. * on each frame.
  44327. */
  44328. autoUpdateExtends: boolean;
  44329. private _orthoLeft;
  44330. private _orthoRight;
  44331. private _orthoTop;
  44332. private _orthoBottom;
  44333. /**
  44334. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  44335. * The directional light is emitted from everywhere in the given direction.
  44336. * It can cast shadows.
  44337. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44338. * @param name The friendly name of the light
  44339. * @param direction The direction of the light
  44340. * @param scene The scene the light belongs to
  44341. */
  44342. constructor(name: string, direction: Vector3, scene: Scene);
  44343. /**
  44344. * Returns the string "DirectionalLight".
  44345. * @return The class name
  44346. */
  44347. getClassName(): string;
  44348. /**
  44349. * Returns the integer 1.
  44350. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44351. */
  44352. getTypeID(): number;
  44353. /**
  44354. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  44355. * Returns the DirectionalLight Shadow projection matrix.
  44356. */
  44357. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44358. /**
  44359. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  44360. * Returns the DirectionalLight Shadow projection matrix.
  44361. */
  44362. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  44363. /**
  44364. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  44365. * Returns the DirectionalLight Shadow projection matrix.
  44366. */
  44367. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44368. protected _buildUniformLayout(): void;
  44369. /**
  44370. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  44371. * @param effect The effect to update
  44372. * @param lightIndex The index of the light in the effect to update
  44373. * @returns The directional light
  44374. */
  44375. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  44376. /**
  44377. * Gets the minZ used for shadow according to both the scene and the light.
  44378. *
  44379. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44380. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44381. * @param activeCamera The camera we are returning the min for
  44382. * @returns the depth min z
  44383. */
  44384. getDepthMinZ(activeCamera: Camera): number;
  44385. /**
  44386. * Gets the maxZ used for shadow according to both the scene and the light.
  44387. *
  44388. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  44389. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  44390. * @param activeCamera The camera we are returning the max for
  44391. * @returns the depth max z
  44392. */
  44393. getDepthMaxZ(activeCamera: Camera): number;
  44394. /**
  44395. * Prepares the list of defines specific to the light type.
  44396. * @param defines the list of defines
  44397. * @param lightIndex defines the index of the light for the effect
  44398. */
  44399. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44400. }
  44401. }
  44402. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  44403. import { Mesh } from "babylonjs/Meshes/mesh";
  44404. /**
  44405. * Class containing static functions to help procedurally build meshes
  44406. */
  44407. export class HemisphereBuilder {
  44408. /**
  44409. * Creates a hemisphere mesh
  44410. * @param name defines the name of the mesh
  44411. * @param options defines the options used to create the mesh
  44412. * @param scene defines the hosting scene
  44413. * @returns the hemisphere mesh
  44414. */
  44415. static CreateHemisphere(name: string, options: {
  44416. segments?: number;
  44417. diameter?: number;
  44418. sideOrientation?: number;
  44419. }, scene: any): Mesh;
  44420. }
  44421. }
  44422. declare module "babylonjs/Lights/spotLight" {
  44423. import { Nullable } from "babylonjs/types";
  44424. import { Scene } from "babylonjs/scene";
  44425. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  44426. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44427. import { Effect } from "babylonjs/Materials/effect";
  44428. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44429. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  44430. /**
  44431. * A spot light is defined by a position, a direction, an angle, and an exponent.
  44432. * These values define a cone of light starting from the position, emitting toward the direction.
  44433. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  44434. * and the exponent defines the speed of the decay of the light with distance (reach).
  44435. * Documentation: https://doc.babylonjs.com/babylon101/lights
  44436. */
  44437. export class SpotLight extends ShadowLight {
  44438. private _angle;
  44439. private _innerAngle;
  44440. private _cosHalfAngle;
  44441. private _lightAngleScale;
  44442. private _lightAngleOffset;
  44443. /**
  44444. * Gets the cone angle of the spot light in Radians.
  44445. */
  44446. /**
  44447. * Sets the cone angle of the spot light in Radians.
  44448. */
  44449. angle: number;
  44450. /**
  44451. * Only used in gltf falloff mode, this defines the angle where
  44452. * the directional falloff will start before cutting at angle which could be seen
  44453. * as outer angle.
  44454. */
  44455. /**
  44456. * Only used in gltf falloff mode, this defines the angle where
  44457. * the directional falloff will start before cutting at angle which could be seen
  44458. * as outer angle.
  44459. */
  44460. innerAngle: number;
  44461. private _shadowAngleScale;
  44462. /**
  44463. * Allows scaling the angle of the light for shadow generation only.
  44464. */
  44465. /**
  44466. * Allows scaling the angle of the light for shadow generation only.
  44467. */
  44468. shadowAngleScale: number;
  44469. /**
  44470. * The light decay speed with the distance from the emission spot.
  44471. */
  44472. exponent: number;
  44473. private _projectionTextureMatrix;
  44474. /**
  44475. * Allows reading the projecton texture
  44476. */
  44477. readonly projectionTextureMatrix: Matrix;
  44478. protected _projectionTextureLightNear: number;
  44479. /**
  44480. * Gets the near clip of the Spotlight for texture projection.
  44481. */
  44482. /**
  44483. * Sets the near clip of the Spotlight for texture projection.
  44484. */
  44485. projectionTextureLightNear: number;
  44486. protected _projectionTextureLightFar: number;
  44487. /**
  44488. * Gets the far clip of the Spotlight for texture projection.
  44489. */
  44490. /**
  44491. * Sets the far clip of the Spotlight for texture projection.
  44492. */
  44493. projectionTextureLightFar: number;
  44494. protected _projectionTextureUpDirection: Vector3;
  44495. /**
  44496. * Gets the Up vector of the Spotlight for texture projection.
  44497. */
  44498. /**
  44499. * Sets the Up vector of the Spotlight for texture projection.
  44500. */
  44501. projectionTextureUpDirection: Vector3;
  44502. private _projectionTexture;
  44503. /**
  44504. * Gets the projection texture of the light.
  44505. */
  44506. /**
  44507. * Sets the projection texture of the light.
  44508. */
  44509. projectionTexture: Nullable<BaseTexture>;
  44510. private _projectionTextureViewLightDirty;
  44511. private _projectionTextureProjectionLightDirty;
  44512. private _projectionTextureDirty;
  44513. private _projectionTextureViewTargetVector;
  44514. private _projectionTextureViewLightMatrix;
  44515. private _projectionTextureProjectionLightMatrix;
  44516. private _projectionTextureScalingMatrix;
  44517. /**
  44518. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  44519. * It can cast shadows.
  44520. * Documentation : https://doc.babylonjs.com/babylon101/lights
  44521. * @param name The light friendly name
  44522. * @param position The position of the spot light in the scene
  44523. * @param direction The direction of the light in the scene
  44524. * @param angle The cone angle of the light in Radians
  44525. * @param exponent The light decay speed with the distance from the emission spot
  44526. * @param scene The scene the lights belongs to
  44527. */
  44528. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  44529. /**
  44530. * Returns the string "SpotLight".
  44531. * @returns the class name
  44532. */
  44533. getClassName(): string;
  44534. /**
  44535. * Returns the integer 2.
  44536. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  44537. */
  44538. getTypeID(): number;
  44539. /**
  44540. * Overrides the direction setter to recompute the projection texture view light Matrix.
  44541. */
  44542. protected _setDirection(value: Vector3): void;
  44543. /**
  44544. * Overrides the position setter to recompute the projection texture view light Matrix.
  44545. */
  44546. protected _setPosition(value: Vector3): void;
  44547. /**
  44548. * 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.
  44549. * Returns the SpotLight.
  44550. */
  44551. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  44552. protected _computeProjectionTextureViewLightMatrix(): void;
  44553. protected _computeProjectionTextureProjectionLightMatrix(): void;
  44554. /**
  44555. * Main function for light texture projection matrix computing.
  44556. */
  44557. protected _computeProjectionTextureMatrix(): void;
  44558. protected _buildUniformLayout(): void;
  44559. private _computeAngleValues;
  44560. /**
  44561. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  44562. * @param effect The effect to update
  44563. * @param lightIndex The index of the light in the effect to update
  44564. * @returns The spot light
  44565. */
  44566. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  44567. /**
  44568. * Disposes the light and the associated resources.
  44569. */
  44570. dispose(): void;
  44571. /**
  44572. * Prepares the list of defines specific to the light type.
  44573. * @param defines the list of defines
  44574. * @param lightIndex defines the index of the light for the effect
  44575. */
  44576. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  44577. }
  44578. }
  44579. declare module "babylonjs/Gizmos/lightGizmo" {
  44580. import { Nullable } from "babylonjs/types";
  44581. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  44582. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  44583. import { Light } from "babylonjs/Lights/light";
  44584. /**
  44585. * Gizmo that enables viewing a light
  44586. */
  44587. export class LightGizmo extends Gizmo {
  44588. private _lightMesh;
  44589. private _material;
  44590. /**
  44591. * Creates a LightGizmo
  44592. * @param gizmoLayer The utility layer the gizmo will be added to
  44593. */
  44594. constructor(gizmoLayer?: UtilityLayerRenderer);
  44595. private _light;
  44596. /**
  44597. * The light that the gizmo is attached to
  44598. */
  44599. light: Nullable<Light>;
  44600. /**
  44601. * @hidden
  44602. * Updates the gizmo to match the attached mesh's position/rotation
  44603. */
  44604. protected _update(): void;
  44605. private static _Scale;
  44606. /**
  44607. * Creates the lines for a light mesh
  44608. */
  44609. private static _createLightLines;
  44610. private static _CreateHemisphericLightMesh;
  44611. private static _CreatePointLightMesh;
  44612. private static _CreateSpotLightMesh;
  44613. private static _CreateDirectionalLightMesh;
  44614. }
  44615. }
  44616. declare module "babylonjs/Gizmos/index" {
  44617. export * from "babylonjs/Gizmos/axisDragGizmo";
  44618. export * from "babylonjs/Gizmos/axisScaleGizmo";
  44619. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  44620. export * from "babylonjs/Gizmos/gizmo";
  44621. export * from "babylonjs/Gizmos/gizmoManager";
  44622. export * from "babylonjs/Gizmos/planeRotationGizmo";
  44623. export * from "babylonjs/Gizmos/positionGizmo";
  44624. export * from "babylonjs/Gizmos/rotationGizmo";
  44625. export * from "babylonjs/Gizmos/scaleGizmo";
  44626. export * from "babylonjs/Gizmos/lightGizmo";
  44627. }
  44628. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  44629. /** @hidden */
  44630. export var backgroundFragmentDeclaration: {
  44631. name: string;
  44632. shader: string;
  44633. };
  44634. }
  44635. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  44636. /** @hidden */
  44637. export var backgroundUboDeclaration: {
  44638. name: string;
  44639. shader: string;
  44640. };
  44641. }
  44642. declare module "babylonjs/Shaders/background.fragment" {
  44643. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  44644. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44645. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  44646. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  44647. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44648. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44649. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44650. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  44651. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  44652. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  44653. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  44654. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  44655. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  44656. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  44657. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  44658. /** @hidden */
  44659. export var backgroundPixelShader: {
  44660. name: string;
  44661. shader: string;
  44662. };
  44663. }
  44664. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  44665. /** @hidden */
  44666. export var backgroundVertexDeclaration: {
  44667. name: string;
  44668. shader: string;
  44669. };
  44670. }
  44671. declare module "babylonjs/Shaders/background.vertex" {
  44672. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  44673. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  44674. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  44675. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  44676. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  44677. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  44678. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  44679. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  44680. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  44681. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  44682. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  44683. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  44684. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  44685. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  44686. /** @hidden */
  44687. export var backgroundVertexShader: {
  44688. name: string;
  44689. shader: string;
  44690. };
  44691. }
  44692. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  44693. import { Nullable, int, float } from "babylonjs/types";
  44694. import { Scene } from "babylonjs/scene";
  44695. import { Matrix, Vector3, Color3 } from "babylonjs/Maths/math";
  44696. import { SubMesh } from "babylonjs/Meshes/subMesh";
  44697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44698. import { Mesh } from "babylonjs/Meshes/mesh";
  44699. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  44700. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  44701. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  44702. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  44703. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  44704. import "babylonjs/Shaders/background.fragment";
  44705. import "babylonjs/Shaders/background.vertex";
  44706. /**
  44707. * Background material used to create an efficient environement around your scene.
  44708. */
  44709. export class BackgroundMaterial extends PushMaterial {
  44710. /**
  44711. * Standard reflectance value at parallel view angle.
  44712. */
  44713. static StandardReflectance0: number;
  44714. /**
  44715. * Standard reflectance value at grazing angle.
  44716. */
  44717. static StandardReflectance90: number;
  44718. protected _primaryColor: Color3;
  44719. /**
  44720. * Key light Color (multiply against the environement texture)
  44721. */
  44722. primaryColor: Color3;
  44723. protected __perceptualColor: Nullable<Color3>;
  44724. /**
  44725. * Experimental Internal Use Only.
  44726. *
  44727. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  44728. * This acts as a helper to set the primary color to a more "human friendly" value.
  44729. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  44730. * output color as close as possible from the chosen value.
  44731. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  44732. * part of lighting setup.)
  44733. */
  44734. _perceptualColor: Nullable<Color3>;
  44735. protected _primaryColorShadowLevel: float;
  44736. /**
  44737. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  44738. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  44739. */
  44740. primaryColorShadowLevel: float;
  44741. protected _primaryColorHighlightLevel: float;
  44742. /**
  44743. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  44744. * The primary color is used at the level chosen to define what the white area would look.
  44745. */
  44746. primaryColorHighlightLevel: float;
  44747. protected _reflectionTexture: Nullable<BaseTexture>;
  44748. /**
  44749. * Reflection Texture used in the material.
  44750. * Should be author in a specific way for the best result (refer to the documentation).
  44751. */
  44752. reflectionTexture: Nullable<BaseTexture>;
  44753. protected _reflectionBlur: float;
  44754. /**
  44755. * Reflection Texture level of blur.
  44756. *
  44757. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  44758. * texture twice.
  44759. */
  44760. reflectionBlur: float;
  44761. protected _diffuseTexture: Nullable<BaseTexture>;
  44762. /**
  44763. * Diffuse Texture used in the material.
  44764. * Should be author in a specific way for the best result (refer to the documentation).
  44765. */
  44766. diffuseTexture: Nullable<BaseTexture>;
  44767. protected _shadowLights: Nullable<IShadowLight[]>;
  44768. /**
  44769. * Specify the list of lights casting shadow on the material.
  44770. * All scene shadow lights will be included if null.
  44771. */
  44772. shadowLights: Nullable<IShadowLight[]>;
  44773. protected _shadowLevel: float;
  44774. /**
  44775. * Helps adjusting the shadow to a softer level if required.
  44776. * 0 means black shadows and 1 means no shadows.
  44777. */
  44778. shadowLevel: float;
  44779. protected _sceneCenter: Vector3;
  44780. /**
  44781. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  44782. * It is usually zero but might be interesting to modify according to your setup.
  44783. */
  44784. sceneCenter: Vector3;
  44785. protected _opacityFresnel: boolean;
  44786. /**
  44787. * This helps specifying that the material is falling off to the sky box at grazing angle.
  44788. * This helps ensuring a nice transition when the camera goes under the ground.
  44789. */
  44790. opacityFresnel: boolean;
  44791. protected _reflectionFresnel: boolean;
  44792. /**
  44793. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  44794. * This helps adding a mirror texture on the ground.
  44795. */
  44796. reflectionFresnel: boolean;
  44797. protected _reflectionFalloffDistance: number;
  44798. /**
  44799. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  44800. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  44801. */
  44802. reflectionFalloffDistance: number;
  44803. protected _reflectionAmount: number;
  44804. /**
  44805. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  44806. */
  44807. reflectionAmount: number;
  44808. protected _reflectionReflectance0: number;
  44809. /**
  44810. * This specifies the weight of the reflection at grazing angle.
  44811. */
  44812. reflectionReflectance0: number;
  44813. protected _reflectionReflectance90: number;
  44814. /**
  44815. * This specifies the weight of the reflection at a perpendicular point of view.
  44816. */
  44817. reflectionReflectance90: number;
  44818. /**
  44819. * Sets the reflection reflectance fresnel values according to the default standard
  44820. * empirically know to work well :-)
  44821. */
  44822. reflectionStandardFresnelWeight: number;
  44823. protected _useRGBColor: boolean;
  44824. /**
  44825. * Helps to directly use the maps channels instead of their level.
  44826. */
  44827. useRGBColor: boolean;
  44828. protected _enableNoise: boolean;
  44829. /**
  44830. * This helps reducing the banding effect that could occur on the background.
  44831. */
  44832. enableNoise: boolean;
  44833. /**
  44834. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  44835. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  44836. * Recommended to be keep at 1.0 except for special cases.
  44837. */
  44838. fovMultiplier: number;
  44839. private _fovMultiplier;
  44840. /**
  44841. * Enable the FOV adjustment feature controlled by fovMultiplier.
  44842. */
  44843. useEquirectangularFOV: boolean;
  44844. private _maxSimultaneousLights;
  44845. /**
  44846. * Number of Simultaneous lights allowed on the material.
  44847. */
  44848. maxSimultaneousLights: int;
  44849. /**
  44850. * Default configuration related to image processing available in the Background Material.
  44851. */
  44852. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  44853. /**
  44854. * Keep track of the image processing observer to allow dispose and replace.
  44855. */
  44856. private _imageProcessingObserver;
  44857. /**
  44858. * Attaches a new image processing configuration to the PBR Material.
  44859. * @param configuration (if null the scene configuration will be use)
  44860. */
  44861. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  44862. /**
  44863. * Gets the image processing configuration used either in this material.
  44864. */
  44865. /**
  44866. * Sets the Default image processing configuration used either in the this material.
  44867. *
  44868. * If sets to null, the scene one is in use.
  44869. */
  44870. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  44871. /**
  44872. * Gets wether the color curves effect is enabled.
  44873. */
  44874. /**
  44875. * Sets wether the color curves effect is enabled.
  44876. */
  44877. cameraColorCurvesEnabled: boolean;
  44878. /**
  44879. * Gets wether the color grading effect is enabled.
  44880. */
  44881. /**
  44882. * Gets wether the color grading effect is enabled.
  44883. */
  44884. cameraColorGradingEnabled: boolean;
  44885. /**
  44886. * Gets wether tonemapping is enabled or not.
  44887. */
  44888. /**
  44889. * Sets wether tonemapping is enabled or not
  44890. */
  44891. cameraToneMappingEnabled: boolean;
  44892. /**
  44893. * The camera exposure used on this material.
  44894. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44895. * This corresponds to a photographic exposure.
  44896. */
  44897. /**
  44898. * The camera exposure used on this material.
  44899. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  44900. * This corresponds to a photographic exposure.
  44901. */
  44902. cameraExposure: float;
  44903. /**
  44904. * Gets The camera contrast used on this material.
  44905. */
  44906. /**
  44907. * Sets The camera contrast used on this material.
  44908. */
  44909. cameraContrast: float;
  44910. /**
  44911. * Gets the Color Grading 2D Lookup Texture.
  44912. */
  44913. /**
  44914. * Sets the Color Grading 2D Lookup Texture.
  44915. */
  44916. cameraColorGradingTexture: Nullable<BaseTexture>;
  44917. /**
  44918. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44919. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44920. * 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;
  44921. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44922. */
  44923. /**
  44924. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  44925. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  44926. * 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;
  44927. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  44928. */
  44929. cameraColorCurves: Nullable<ColorCurves>;
  44930. /**
  44931. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  44932. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  44933. */
  44934. switchToBGR: boolean;
  44935. private _renderTargets;
  44936. private _reflectionControls;
  44937. private _white;
  44938. private _primaryShadowColor;
  44939. private _primaryHighlightColor;
  44940. /**
  44941. * Instantiates a Background Material in the given scene
  44942. * @param name The friendly name of the material
  44943. * @param scene The scene to add the material to
  44944. */
  44945. constructor(name: string, scene: Scene);
  44946. /**
  44947. * Gets a boolean indicating that current material needs to register RTT
  44948. */
  44949. readonly hasRenderTargetTextures: boolean;
  44950. /**
  44951. * The entire material has been created in order to prevent overdraw.
  44952. * @returns false
  44953. */
  44954. needAlphaTesting(): boolean;
  44955. /**
  44956. * The entire material has been created in order to prevent overdraw.
  44957. * @returns true if blending is enable
  44958. */
  44959. needAlphaBlending(): boolean;
  44960. /**
  44961. * Checks wether the material is ready to be rendered for a given mesh.
  44962. * @param mesh The mesh to render
  44963. * @param subMesh The submesh to check against
  44964. * @param useInstances Specify wether or not the material is used with instances
  44965. * @returns true if all the dependencies are ready (Textures, Effects...)
  44966. */
  44967. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  44968. /**
  44969. * Compute the primary color according to the chosen perceptual color.
  44970. */
  44971. private _computePrimaryColorFromPerceptualColor;
  44972. /**
  44973. * Compute the highlights and shadow colors according to their chosen levels.
  44974. */
  44975. private _computePrimaryColors;
  44976. /**
  44977. * Build the uniform buffer used in the material.
  44978. */
  44979. buildUniformLayout(): void;
  44980. /**
  44981. * Unbind the material.
  44982. */
  44983. unbind(): void;
  44984. /**
  44985. * Bind only the world matrix to the material.
  44986. * @param world The world matrix to bind.
  44987. */
  44988. bindOnlyWorldMatrix(world: Matrix): void;
  44989. /**
  44990. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  44991. * @param world The world matrix to bind.
  44992. * @param subMesh The submesh to bind for.
  44993. */
  44994. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  44995. /**
  44996. * Dispose the material.
  44997. * @param forceDisposeEffect Force disposal of the associated effect.
  44998. * @param forceDisposeTextures Force disposal of the associated textures.
  44999. */
  45000. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  45001. /**
  45002. * Clones the material.
  45003. * @param name The cloned name.
  45004. * @returns The cloned material.
  45005. */
  45006. clone(name: string): BackgroundMaterial;
  45007. /**
  45008. * Serializes the current material to its JSON representation.
  45009. * @returns The JSON representation.
  45010. */
  45011. serialize(): any;
  45012. /**
  45013. * Gets the class name of the material
  45014. * @returns "BackgroundMaterial"
  45015. */
  45016. getClassName(): string;
  45017. /**
  45018. * Parse a JSON input to create back a background material.
  45019. * @param source The JSON data to parse
  45020. * @param scene The scene to create the parsed material in
  45021. * @param rootUrl The root url of the assets the material depends upon
  45022. * @returns the instantiated BackgroundMaterial.
  45023. */
  45024. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  45025. }
  45026. }
  45027. declare module "babylonjs/Helpers/environmentHelper" {
  45028. import { Observable } from "babylonjs/Misc/observable";
  45029. import { Nullable } from "babylonjs/types";
  45030. import { Scene } from "babylonjs/scene";
  45031. import { Vector3, Color3 } from "babylonjs/Maths/math";
  45032. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45033. import { Mesh } from "babylonjs/Meshes/mesh";
  45034. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45035. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  45036. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45037. import "babylonjs/Meshes/Builders/planeBuilder";
  45038. import "babylonjs/Meshes/Builders/boxBuilder";
  45039. /**
  45040. * Represents the different options available during the creation of
  45041. * a Environment helper.
  45042. *
  45043. * This can control the default ground, skybox and image processing setup of your scene.
  45044. */
  45045. export interface IEnvironmentHelperOptions {
  45046. /**
  45047. * Specifies wether or not to create a ground.
  45048. * True by default.
  45049. */
  45050. createGround: boolean;
  45051. /**
  45052. * Specifies the ground size.
  45053. * 15 by default.
  45054. */
  45055. groundSize: number;
  45056. /**
  45057. * The texture used on the ground for the main color.
  45058. * Comes from the BabylonJS CDN by default.
  45059. *
  45060. * Remarks: Can be either a texture or a url.
  45061. */
  45062. groundTexture: string | BaseTexture;
  45063. /**
  45064. * The color mixed in the ground texture by default.
  45065. * BabylonJS clearColor by default.
  45066. */
  45067. groundColor: Color3;
  45068. /**
  45069. * Specifies the ground opacity.
  45070. * 1 by default.
  45071. */
  45072. groundOpacity: number;
  45073. /**
  45074. * Enables the ground to receive shadows.
  45075. * True by default.
  45076. */
  45077. enableGroundShadow: boolean;
  45078. /**
  45079. * Helps preventing the shadow to be fully black on the ground.
  45080. * 0.5 by default.
  45081. */
  45082. groundShadowLevel: number;
  45083. /**
  45084. * Creates a mirror texture attach to the ground.
  45085. * false by default.
  45086. */
  45087. enableGroundMirror: boolean;
  45088. /**
  45089. * Specifies the ground mirror size ratio.
  45090. * 0.3 by default as the default kernel is 64.
  45091. */
  45092. groundMirrorSizeRatio: number;
  45093. /**
  45094. * Specifies the ground mirror blur kernel size.
  45095. * 64 by default.
  45096. */
  45097. groundMirrorBlurKernel: number;
  45098. /**
  45099. * Specifies the ground mirror visibility amount.
  45100. * 1 by default
  45101. */
  45102. groundMirrorAmount: number;
  45103. /**
  45104. * Specifies the ground mirror reflectance weight.
  45105. * This uses the standard weight of the background material to setup the fresnel effect
  45106. * of the mirror.
  45107. * 1 by default.
  45108. */
  45109. groundMirrorFresnelWeight: number;
  45110. /**
  45111. * Specifies the ground mirror Falloff distance.
  45112. * This can helps reducing the size of the reflection.
  45113. * 0 by Default.
  45114. */
  45115. groundMirrorFallOffDistance: number;
  45116. /**
  45117. * Specifies the ground mirror texture type.
  45118. * Unsigned Int by Default.
  45119. */
  45120. groundMirrorTextureType: number;
  45121. /**
  45122. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  45123. * the shown objects.
  45124. */
  45125. groundYBias: number;
  45126. /**
  45127. * Specifies wether or not to create a skybox.
  45128. * True by default.
  45129. */
  45130. createSkybox: boolean;
  45131. /**
  45132. * Specifies the skybox size.
  45133. * 20 by default.
  45134. */
  45135. skyboxSize: number;
  45136. /**
  45137. * The texture used on the skybox for the main color.
  45138. * Comes from the BabylonJS CDN by default.
  45139. *
  45140. * Remarks: Can be either a texture or a url.
  45141. */
  45142. skyboxTexture: string | BaseTexture;
  45143. /**
  45144. * The color mixed in the skybox texture by default.
  45145. * BabylonJS clearColor by default.
  45146. */
  45147. skyboxColor: Color3;
  45148. /**
  45149. * The background rotation around the Y axis of the scene.
  45150. * This helps aligning the key lights of your scene with the background.
  45151. * 0 by default.
  45152. */
  45153. backgroundYRotation: number;
  45154. /**
  45155. * Compute automatically the size of the elements to best fit with the scene.
  45156. */
  45157. sizeAuto: boolean;
  45158. /**
  45159. * Default position of the rootMesh if autoSize is not true.
  45160. */
  45161. rootPosition: Vector3;
  45162. /**
  45163. * Sets up the image processing in the scene.
  45164. * true by default.
  45165. */
  45166. setupImageProcessing: boolean;
  45167. /**
  45168. * The texture used as your environment texture in the scene.
  45169. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  45170. *
  45171. * Remarks: Can be either a texture or a url.
  45172. */
  45173. environmentTexture: string | BaseTexture;
  45174. /**
  45175. * The value of the exposure to apply to the scene.
  45176. * 0.6 by default if setupImageProcessing is true.
  45177. */
  45178. cameraExposure: number;
  45179. /**
  45180. * The value of the contrast to apply to the scene.
  45181. * 1.6 by default if setupImageProcessing is true.
  45182. */
  45183. cameraContrast: number;
  45184. /**
  45185. * Specifies wether or not tonemapping should be enabled in the scene.
  45186. * true by default if setupImageProcessing is true.
  45187. */
  45188. toneMappingEnabled: boolean;
  45189. }
  45190. /**
  45191. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  45192. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  45193. * It also helps with the default setup of your imageProcessing configuration.
  45194. */
  45195. export class EnvironmentHelper {
  45196. /**
  45197. * Default ground texture URL.
  45198. */
  45199. private static _groundTextureCDNUrl;
  45200. /**
  45201. * Default skybox texture URL.
  45202. */
  45203. private static _skyboxTextureCDNUrl;
  45204. /**
  45205. * Default environment texture URL.
  45206. */
  45207. private static _environmentTextureCDNUrl;
  45208. /**
  45209. * Creates the default options for the helper.
  45210. */
  45211. private static _getDefaultOptions;
  45212. private _rootMesh;
  45213. /**
  45214. * Gets the root mesh created by the helper.
  45215. */
  45216. readonly rootMesh: Mesh;
  45217. private _skybox;
  45218. /**
  45219. * Gets the skybox created by the helper.
  45220. */
  45221. readonly skybox: Nullable<Mesh>;
  45222. private _skyboxTexture;
  45223. /**
  45224. * Gets the skybox texture created by the helper.
  45225. */
  45226. readonly skyboxTexture: Nullable<BaseTexture>;
  45227. private _skyboxMaterial;
  45228. /**
  45229. * Gets the skybox material created by the helper.
  45230. */
  45231. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  45232. private _ground;
  45233. /**
  45234. * Gets the ground mesh created by the helper.
  45235. */
  45236. readonly ground: Nullable<Mesh>;
  45237. private _groundTexture;
  45238. /**
  45239. * Gets the ground texture created by the helper.
  45240. */
  45241. readonly groundTexture: Nullable<BaseTexture>;
  45242. private _groundMirror;
  45243. /**
  45244. * Gets the ground mirror created by the helper.
  45245. */
  45246. readonly groundMirror: Nullable<MirrorTexture>;
  45247. /**
  45248. * Gets the ground mirror render list to helps pushing the meshes
  45249. * you wish in the ground reflection.
  45250. */
  45251. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  45252. private _groundMaterial;
  45253. /**
  45254. * Gets the ground material created by the helper.
  45255. */
  45256. readonly groundMaterial: Nullable<BackgroundMaterial>;
  45257. /**
  45258. * Stores the creation options.
  45259. */
  45260. private readonly _scene;
  45261. private _options;
  45262. /**
  45263. * This observable will be notified with any error during the creation of the environment,
  45264. * mainly texture creation errors.
  45265. */
  45266. onErrorObservable: Observable<{
  45267. message?: string;
  45268. exception?: any;
  45269. }>;
  45270. /**
  45271. * constructor
  45272. * @param options Defines the options we want to customize the helper
  45273. * @param scene The scene to add the material to
  45274. */
  45275. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  45276. /**
  45277. * Updates the background according to the new options
  45278. * @param options
  45279. */
  45280. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  45281. /**
  45282. * Sets the primary color of all the available elements.
  45283. * @param color the main color to affect to the ground and the background
  45284. */
  45285. setMainColor(color: Color3): void;
  45286. /**
  45287. * Setup the image processing according to the specified options.
  45288. */
  45289. private _setupImageProcessing;
  45290. /**
  45291. * Setup the environment texture according to the specified options.
  45292. */
  45293. private _setupEnvironmentTexture;
  45294. /**
  45295. * Setup the background according to the specified options.
  45296. */
  45297. private _setupBackground;
  45298. /**
  45299. * Get the scene sizes according to the setup.
  45300. */
  45301. private _getSceneSize;
  45302. /**
  45303. * Setup the ground according to the specified options.
  45304. */
  45305. private _setupGround;
  45306. /**
  45307. * Setup the ground material according to the specified options.
  45308. */
  45309. private _setupGroundMaterial;
  45310. /**
  45311. * Setup the ground diffuse texture according to the specified options.
  45312. */
  45313. private _setupGroundDiffuseTexture;
  45314. /**
  45315. * Setup the ground mirror texture according to the specified options.
  45316. */
  45317. private _setupGroundMirrorTexture;
  45318. /**
  45319. * Setup the ground to receive the mirror texture.
  45320. */
  45321. private _setupMirrorInGroundMaterial;
  45322. /**
  45323. * Setup the skybox according to the specified options.
  45324. */
  45325. private _setupSkybox;
  45326. /**
  45327. * Setup the skybox material according to the specified options.
  45328. */
  45329. private _setupSkyboxMaterial;
  45330. /**
  45331. * Setup the skybox reflection texture according to the specified options.
  45332. */
  45333. private _setupSkyboxReflectionTexture;
  45334. private _errorHandler;
  45335. /**
  45336. * Dispose all the elements created by the Helper.
  45337. */
  45338. dispose(): void;
  45339. }
  45340. }
  45341. declare module "babylonjs/Helpers/photoDome" {
  45342. import { Observable } from "babylonjs/Misc/observable";
  45343. import { Nullable } from "babylonjs/types";
  45344. import { Scene } from "babylonjs/scene";
  45345. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45346. import { Mesh } from "babylonjs/Meshes/mesh";
  45347. import { Texture } from "babylonjs/Materials/Textures/texture";
  45348. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  45349. import "babylonjs/Meshes/Builders/sphereBuilder";
  45350. /**
  45351. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  45352. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  45353. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  45354. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  45355. */
  45356. export class PhotoDome extends TransformNode {
  45357. private _useDirectMapping;
  45358. /**
  45359. * The texture being displayed on the sphere
  45360. */
  45361. protected _photoTexture: Texture;
  45362. /**
  45363. * Gets or sets the texture being displayed on the sphere
  45364. */
  45365. photoTexture: Texture;
  45366. /**
  45367. * Observable raised when an error occured while loading the 360 image
  45368. */
  45369. onLoadErrorObservable: Observable<string>;
  45370. /**
  45371. * The skybox material
  45372. */
  45373. protected _material: BackgroundMaterial;
  45374. /**
  45375. * The surface used for the skybox
  45376. */
  45377. protected _mesh: Mesh;
  45378. /**
  45379. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  45380. * Also see the options.resolution property.
  45381. */
  45382. fovMultiplier: number;
  45383. /**
  45384. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  45385. * @param name Element's name, child elements will append suffixes for their own names.
  45386. * @param urlsOfPhoto defines the url of the photo to display
  45387. * @param options defines an object containing optional or exposed sub element properties
  45388. * @param onError defines a callback called when an error occured while loading the texture
  45389. */
  45390. constructor(name: string, urlOfPhoto: string, options: {
  45391. resolution?: number;
  45392. size?: number;
  45393. useDirectMapping?: boolean;
  45394. faceForward?: boolean;
  45395. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  45396. /**
  45397. * Releases resources associated with this node.
  45398. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  45399. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  45400. */
  45401. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  45402. }
  45403. }
  45404. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  45405. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  45406. /** @hidden */
  45407. export var rgbdDecodePixelShader: {
  45408. name: string;
  45409. shader: string;
  45410. };
  45411. }
  45412. declare module "babylonjs/Misc/brdfTextureTools" {
  45413. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45414. import { Scene } from "babylonjs/scene";
  45415. import "babylonjs/Shaders/rgbdDecode.fragment";
  45416. /**
  45417. * Class used to host texture specific utilities
  45418. */
  45419. export class BRDFTextureTools {
  45420. /**
  45421. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  45422. * @param texture the texture to expand.
  45423. */
  45424. private static _ExpandDefaultBRDFTexture;
  45425. /**
  45426. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  45427. * @param scene defines the hosting scene
  45428. * @returns the environment BRDF texture
  45429. */
  45430. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  45431. private static _environmentBRDFBase64Texture;
  45432. }
  45433. }
  45434. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  45435. import { Nullable } from "babylonjs/types";
  45436. import { IAnimatable } from "babylonjs/Misc/tools";
  45437. import { Color3 } from "babylonjs/Maths/math";
  45438. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45439. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45440. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45441. import { Engine } from "babylonjs/Engines/engine";
  45442. import { Scene } from "babylonjs/scene";
  45443. /**
  45444. * @hidden
  45445. */
  45446. export interface IMaterialClearCoatDefines {
  45447. CLEARCOAT: boolean;
  45448. CLEARCOAT_DEFAULTIOR: boolean;
  45449. CLEARCOAT_TEXTURE: boolean;
  45450. CLEARCOAT_TEXTUREDIRECTUV: number;
  45451. CLEARCOAT_BUMP: boolean;
  45452. CLEARCOAT_BUMPDIRECTUV: number;
  45453. CLEARCOAT_TINT: boolean;
  45454. CLEARCOAT_TINT_TEXTURE: boolean;
  45455. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  45456. /** @hidden */
  45457. _areTexturesDirty: boolean;
  45458. }
  45459. /**
  45460. * Define the code related to the clear coat parameters of the pbr material.
  45461. */
  45462. export class PBRClearCoatConfiguration {
  45463. /**
  45464. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45465. * The default fits with a polyurethane material.
  45466. */
  45467. private static readonly _DefaultIndiceOfRefraction;
  45468. private _isEnabled;
  45469. /**
  45470. * Defines if the clear coat is enabled in the material.
  45471. */
  45472. isEnabled: boolean;
  45473. /**
  45474. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  45475. */
  45476. intensity: number;
  45477. /**
  45478. * Defines the clear coat layer roughness.
  45479. */
  45480. roughness: number;
  45481. private _indiceOfRefraction;
  45482. /**
  45483. * Defines the indice of refraction of the clear coat.
  45484. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  45485. * The default fits with a polyurethane material.
  45486. * Changing the default value is more performance intensive.
  45487. */
  45488. indiceOfRefraction: number;
  45489. private _texture;
  45490. /**
  45491. * Stores the clear coat values in a texture.
  45492. */
  45493. texture: Nullable<BaseTexture>;
  45494. private _bumpTexture;
  45495. /**
  45496. * Define the clear coat specific bump texture.
  45497. */
  45498. bumpTexture: Nullable<BaseTexture>;
  45499. private _isTintEnabled;
  45500. /**
  45501. * Defines if the clear coat tint is enabled in the material.
  45502. */
  45503. isTintEnabled: boolean;
  45504. /**
  45505. * Defines the clear coat tint of the material.
  45506. * This is only use if tint is enabled
  45507. */
  45508. tintColor: Color3;
  45509. /**
  45510. * Defines the distance at which the tint color should be found in the
  45511. * clear coat media.
  45512. * This is only use if tint is enabled
  45513. */
  45514. tintColorAtDistance: number;
  45515. /**
  45516. * Defines the clear coat layer thickness.
  45517. * This is only use if tint is enabled
  45518. */
  45519. tintThickness: number;
  45520. private _tintTexture;
  45521. /**
  45522. * Stores the clear tint values in a texture.
  45523. * rgb is tint
  45524. * a is a thickness factor
  45525. */
  45526. tintTexture: Nullable<BaseTexture>;
  45527. /** @hidden */
  45528. private _internalMarkAllSubMeshesAsTexturesDirty;
  45529. /** @hidden */
  45530. _markAllSubMeshesAsTexturesDirty(): void;
  45531. /**
  45532. * Instantiate a new istance of clear coat configuration.
  45533. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45534. */
  45535. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45536. /**
  45537. * Gets wehter the submesh is ready to be used or not.
  45538. * @param defines the list of "defines" to update.
  45539. * @param scene defines the scene the material belongs to.
  45540. * @param engine defines the engine the material belongs to.
  45541. * @param disableBumpMap defines wether the material disables bump or not.
  45542. * @returns - boolean indicating that the submesh is ready or not.
  45543. */
  45544. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  45545. /**
  45546. * Checks to see if a texture is used in the material.
  45547. * @param defines the list of "defines" to update.
  45548. * @param scene defines the scene to the material belongs to.
  45549. */
  45550. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  45551. /**
  45552. * Binds the material data.
  45553. * @param uniformBuffer defines the Uniform buffer to fill in.
  45554. * @param scene defines the scene the material belongs to.
  45555. * @param engine defines the engine the material belongs to.
  45556. * @param disableBumpMap defines wether the material disables bump or not.
  45557. * @param isFrozen defines wether the material is frozen or not.
  45558. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  45559. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  45560. */
  45561. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  45562. /**
  45563. * Checks to see if a texture is used in the material.
  45564. * @param texture - Base texture to use.
  45565. * @returns - Boolean specifying if a texture is used in the material.
  45566. */
  45567. hasTexture(texture: BaseTexture): boolean;
  45568. /**
  45569. * Returns an array of the actively used textures.
  45570. * @param activeTextures Array of BaseTextures
  45571. */
  45572. getActiveTextures(activeTextures: BaseTexture[]): void;
  45573. /**
  45574. * Returns the animatable textures.
  45575. * @param animatables Array of animatable textures.
  45576. */
  45577. getAnimatables(animatables: IAnimatable[]): void;
  45578. /**
  45579. * Disposes the resources of the material.
  45580. * @param forceDisposeTextures - Forces the disposal of all textures.
  45581. */
  45582. dispose(forceDisposeTextures?: boolean): void;
  45583. /**
  45584. * Get the current class name of the texture useful for serialization or dynamic coding.
  45585. * @returns "PBRClearCoatConfiguration"
  45586. */
  45587. getClassName(): string;
  45588. /**
  45589. * Add fallbacks to the effect fallbacks list.
  45590. * @param defines defines the Base texture to use.
  45591. * @param fallbacks defines the current fallback list.
  45592. * @param currentRank defines the current fallback rank.
  45593. * @returns the new fallback rank.
  45594. */
  45595. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45596. /**
  45597. * Add the required uniforms to the current list.
  45598. * @param uniforms defines the current uniform list.
  45599. */
  45600. static AddUniforms(uniforms: string[]): void;
  45601. /**
  45602. * Add the required samplers to the current list.
  45603. * @param samplers defines the current sampler list.
  45604. */
  45605. static AddSamplers(samplers: string[]): void;
  45606. /**
  45607. * Add the required uniforms to the current buffer.
  45608. * @param uniformBuffer defines the current uniform buffer.
  45609. */
  45610. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45611. /**
  45612. * Makes a duplicate of the current configuration into another one.
  45613. * @param clearCoatConfiguration define the config where to copy the info
  45614. */
  45615. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  45616. /**
  45617. * Serializes this clear coat configuration.
  45618. * @returns - An object with the serialized config.
  45619. */
  45620. serialize(): any;
  45621. /**
  45622. * Parses a Clear Coat Configuration from a serialized object.
  45623. * @param source - Serialized object.
  45624. */
  45625. parse(source: any): void;
  45626. }
  45627. }
  45628. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  45629. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45631. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45632. import { Vector2 } from "babylonjs/Maths/math";
  45633. import { Scene } from "babylonjs/scene";
  45634. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45635. import { IAnimatable } from "babylonjs/Misc/tools";
  45636. import { Nullable } from "babylonjs/types";
  45637. /**
  45638. * @hidden
  45639. */
  45640. export interface IMaterialAnisotropicDefines {
  45641. ANISOTROPIC: boolean;
  45642. ANISOTROPIC_TEXTURE: boolean;
  45643. ANISOTROPIC_TEXTUREDIRECTUV: number;
  45644. MAINUV1: boolean;
  45645. _areTexturesDirty: boolean;
  45646. _needUVs: boolean;
  45647. }
  45648. /**
  45649. * Define the code related to the anisotropic parameters of the pbr material.
  45650. */
  45651. export class PBRAnisotropicConfiguration {
  45652. private _isEnabled;
  45653. /**
  45654. * Defines if the anisotropy is enabled in the material.
  45655. */
  45656. isEnabled: boolean;
  45657. /**
  45658. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  45659. */
  45660. intensity: number;
  45661. /**
  45662. * Defines if the effect is along the tangents, bitangents or in between.
  45663. * By default, the effect is "strectching" the highlights along the tangents.
  45664. */
  45665. direction: Vector2;
  45666. private _texture;
  45667. /**
  45668. * Stores the anisotropy values in a texture.
  45669. * rg is direction (like normal from -1 to 1)
  45670. * b is a intensity
  45671. */
  45672. texture: Nullable<BaseTexture>;
  45673. /** @hidden */
  45674. private _internalMarkAllSubMeshesAsTexturesDirty;
  45675. /** @hidden */
  45676. _markAllSubMeshesAsTexturesDirty(): void;
  45677. /**
  45678. * Instantiate a new istance of anisotropy configuration.
  45679. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45680. */
  45681. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45682. /**
  45683. * Specifies that the submesh is ready to be used.
  45684. * @param defines the list of "defines" to update.
  45685. * @param scene defines the scene the material belongs to.
  45686. * @returns - boolean indicating that the submesh is ready or not.
  45687. */
  45688. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  45689. /**
  45690. * Checks to see if a texture is used in the material.
  45691. * @param defines the list of "defines" to update.
  45692. * @param mesh the mesh we are preparing the defines for.
  45693. * @param scene defines the scene the material belongs to.
  45694. */
  45695. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  45696. /**
  45697. * Binds the material data.
  45698. * @param uniformBuffer defines the Uniform buffer to fill in.
  45699. * @param scene defines the scene the material belongs to.
  45700. * @param isFrozen defines wether the material is frozen or not.
  45701. */
  45702. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45703. /**
  45704. * Checks to see if a texture is used in the material.
  45705. * @param texture - Base texture to use.
  45706. * @returns - Boolean specifying if a texture is used in the material.
  45707. */
  45708. hasTexture(texture: BaseTexture): boolean;
  45709. /**
  45710. * Returns an array of the actively used textures.
  45711. * @param activeTextures Array of BaseTextures
  45712. */
  45713. getActiveTextures(activeTextures: BaseTexture[]): void;
  45714. /**
  45715. * Returns the animatable textures.
  45716. * @param animatables Array of animatable textures.
  45717. */
  45718. getAnimatables(animatables: IAnimatable[]): void;
  45719. /**
  45720. * Disposes the resources of the material.
  45721. * @param forceDisposeTextures - Forces the disposal of all textures.
  45722. */
  45723. dispose(forceDisposeTextures?: boolean): void;
  45724. /**
  45725. * Get the current class name of the texture useful for serialization or dynamic coding.
  45726. * @returns "PBRAnisotropicConfiguration"
  45727. */
  45728. getClassName(): string;
  45729. /**
  45730. * Add fallbacks to the effect fallbacks list.
  45731. * @param defines defines the Base texture to use.
  45732. * @param fallbacks defines the current fallback list.
  45733. * @param currentRank defines the current fallback rank.
  45734. * @returns the new fallback rank.
  45735. */
  45736. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45737. /**
  45738. * Add the required uniforms to the current list.
  45739. * @param uniforms defines the current uniform list.
  45740. */
  45741. static AddUniforms(uniforms: string[]): void;
  45742. /**
  45743. * Add the required uniforms to the current buffer.
  45744. * @param uniformBuffer defines the current uniform buffer.
  45745. */
  45746. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45747. /**
  45748. * Add the required samplers to the current list.
  45749. * @param samplers defines the current sampler list.
  45750. */
  45751. static AddSamplers(samplers: string[]): void;
  45752. /**
  45753. * Makes a duplicate of the current configuration into another one.
  45754. * @param anisotropicConfiguration define the config where to copy the info
  45755. */
  45756. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  45757. /**
  45758. * Serializes this anisotropy configuration.
  45759. * @returns - An object with the serialized config.
  45760. */
  45761. serialize(): any;
  45762. /**
  45763. * Parses a anisotropy Configuration from a serialized object.
  45764. * @param source - Serialized object.
  45765. */
  45766. parse(source: any): void;
  45767. }
  45768. }
  45769. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  45770. /**
  45771. * @hidden
  45772. */
  45773. export interface IMaterialBRDFDefines {
  45774. BRDF_V_HEIGHT_CORRELATED: boolean;
  45775. MS_BRDF_ENERGY_CONSERVATION: boolean;
  45776. /** @hidden */
  45777. _areMiscDirty: boolean;
  45778. }
  45779. /**
  45780. * Define the code related to the BRDF parameters of the pbr material.
  45781. */
  45782. export class PBRBRDFConfiguration {
  45783. /**
  45784. * Default value used for the energy conservation.
  45785. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45786. */
  45787. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  45788. /**
  45789. * Default value used for the Smith Visibility Height Correlated mode.
  45790. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  45791. */
  45792. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  45793. private _useEnergyConservation;
  45794. /**
  45795. * Defines if the material uses energy conservation.
  45796. */
  45797. useEnergyConservation: boolean;
  45798. private _useSmithVisibilityHeightCorrelated;
  45799. /**
  45800. * LEGACY Mode set to false
  45801. * Defines if the material uses height smith correlated visibility term.
  45802. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  45803. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  45804. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  45805. * Not relying on height correlated will also disable energy conservation.
  45806. */
  45807. useSmithVisibilityHeightCorrelated: boolean;
  45808. /** @hidden */
  45809. private _internalMarkAllSubMeshesAsMiscDirty;
  45810. /** @hidden */
  45811. _markAllSubMeshesAsMiscDirty(): void;
  45812. /**
  45813. * Instantiate a new istance of clear coat configuration.
  45814. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  45815. */
  45816. constructor(markAllSubMeshesAsMiscDirty: () => void);
  45817. /**
  45818. * Checks to see if a texture is used in the material.
  45819. * @param defines the list of "defines" to update.
  45820. */
  45821. prepareDefines(defines: IMaterialBRDFDefines): void;
  45822. /**
  45823. * Get the current class name of the texture useful for serialization or dynamic coding.
  45824. * @returns "PBRClearCoatConfiguration"
  45825. */
  45826. getClassName(): string;
  45827. /**
  45828. * Makes a duplicate of the current configuration into another one.
  45829. * @param brdfConfiguration define the config where to copy the info
  45830. */
  45831. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  45832. /**
  45833. * Serializes this BRDF configuration.
  45834. * @returns - An object with the serialized config.
  45835. */
  45836. serialize(): any;
  45837. /**
  45838. * Parses a BRDF Configuration from a serialized object.
  45839. * @param source - Serialized object.
  45840. */
  45841. parse(source: any): void;
  45842. }
  45843. }
  45844. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  45845. import { EffectFallbacks } from "babylonjs/Materials/effect";
  45846. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45847. import { Color3 } from "babylonjs/Maths/math";
  45848. import { Scene } from "babylonjs/scene";
  45849. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45850. import { IAnimatable } from "babylonjs/Misc/tools";
  45851. import { Nullable } from "babylonjs/types";
  45852. /**
  45853. * @hidden
  45854. */
  45855. export interface IMaterialSheenDefines {
  45856. SHEEN: boolean;
  45857. SHEEN_TEXTURE: boolean;
  45858. SHEEN_TEXTUREDIRECTUV: number;
  45859. SHEEN_LINKWITHALBEDO: boolean;
  45860. /** @hidden */
  45861. _areTexturesDirty: boolean;
  45862. }
  45863. /**
  45864. * Define the code related to the Sheen parameters of the pbr material.
  45865. */
  45866. export class PBRSheenConfiguration {
  45867. private _isEnabled;
  45868. /**
  45869. * Defines if the material uses sheen.
  45870. */
  45871. isEnabled: boolean;
  45872. private _linkSheenWithAlbedo;
  45873. /**
  45874. * Defines if the sheen is linked to the sheen color.
  45875. */
  45876. linkSheenWithAlbedo: boolean;
  45877. /**
  45878. * Defines the sheen intensity.
  45879. */
  45880. intensity: number;
  45881. /**
  45882. * Defines the sheen color.
  45883. */
  45884. color: Color3;
  45885. private _texture;
  45886. /**
  45887. * Stores the sheen tint values in a texture.
  45888. * rgb is tint
  45889. * a is a intensity
  45890. */
  45891. texture: Nullable<BaseTexture>;
  45892. /** @hidden */
  45893. private _internalMarkAllSubMeshesAsTexturesDirty;
  45894. /** @hidden */
  45895. _markAllSubMeshesAsTexturesDirty(): void;
  45896. /**
  45897. * Instantiate a new istance of clear coat configuration.
  45898. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  45899. */
  45900. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  45901. /**
  45902. * Specifies that the submesh is ready to be used.
  45903. * @param defines the list of "defines" to update.
  45904. * @param scene defines the scene the material belongs to.
  45905. * @returns - boolean indicating that the submesh is ready or not.
  45906. */
  45907. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  45908. /**
  45909. * Checks to see if a texture is used in the material.
  45910. * @param defines the list of "defines" to update.
  45911. * @param scene defines the scene the material belongs to.
  45912. */
  45913. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  45914. /**
  45915. * Binds the material data.
  45916. * @param uniformBuffer defines the Uniform buffer to fill in.
  45917. * @param scene defines the scene the material belongs to.
  45918. * @param isFrozen defines wether the material is frozen or not.
  45919. */
  45920. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  45921. /**
  45922. * Checks to see if a texture is used in the material.
  45923. * @param texture - Base texture to use.
  45924. * @returns - Boolean specifying if a texture is used in the material.
  45925. */
  45926. hasTexture(texture: BaseTexture): boolean;
  45927. /**
  45928. * Returns an array of the actively used textures.
  45929. * @param activeTextures Array of BaseTextures
  45930. */
  45931. getActiveTextures(activeTextures: BaseTexture[]): void;
  45932. /**
  45933. * Returns the animatable textures.
  45934. * @param animatables Array of animatable textures.
  45935. */
  45936. getAnimatables(animatables: IAnimatable[]): void;
  45937. /**
  45938. * Disposes the resources of the material.
  45939. * @param forceDisposeTextures - Forces the disposal of all textures.
  45940. */
  45941. dispose(forceDisposeTextures?: boolean): void;
  45942. /**
  45943. * Get the current class name of the texture useful for serialization or dynamic coding.
  45944. * @returns "PBRSheenConfiguration"
  45945. */
  45946. getClassName(): string;
  45947. /**
  45948. * Add fallbacks to the effect fallbacks list.
  45949. * @param defines defines the Base texture to use.
  45950. * @param fallbacks defines the current fallback list.
  45951. * @param currentRank defines the current fallback rank.
  45952. * @returns the new fallback rank.
  45953. */
  45954. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  45955. /**
  45956. * Add the required uniforms to the current list.
  45957. * @param uniforms defines the current uniform list.
  45958. */
  45959. static AddUniforms(uniforms: string[]): void;
  45960. /**
  45961. * Add the required uniforms to the current buffer.
  45962. * @param uniformBuffer defines the current uniform buffer.
  45963. */
  45964. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  45965. /**
  45966. * Add the required samplers to the current list.
  45967. * @param samplers defines the current sampler list.
  45968. */
  45969. static AddSamplers(samplers: string[]): void;
  45970. /**
  45971. * Makes a duplicate of the current configuration into another one.
  45972. * @param sheenConfiguration define the config where to copy the info
  45973. */
  45974. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  45975. /**
  45976. * Serializes this BRDF configuration.
  45977. * @returns - An object with the serialized config.
  45978. */
  45979. serialize(): any;
  45980. /**
  45981. * Parses a Sheen Configuration from a serialized object.
  45982. * @param source - Serialized object.
  45983. */
  45984. parse(source: any): void;
  45985. }
  45986. }
  45987. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  45988. import { Nullable } from "babylonjs/types";
  45989. import { IAnimatable } from "babylonjs/Misc/tools";
  45990. import { Color3 } from "babylonjs/Maths/math";
  45991. import { SmartArray } from "babylonjs/Misc/smartArray";
  45992. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  45993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  45994. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  45995. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  45996. import { Engine } from "babylonjs/Engines/engine";
  45997. import { Scene } from "babylonjs/scene";
  45998. /**
  45999. * @hidden
  46000. */
  46001. export interface IMaterialSubSurfaceDefines {
  46002. SUBSURFACE: boolean;
  46003. SS_REFRACTION: boolean;
  46004. SS_TRANSLUCENCY: boolean;
  46005. SS_SCATERRING: boolean;
  46006. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46007. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46008. SS_REFRACTIONMAP_3D: boolean;
  46009. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46010. SS_LODINREFRACTIONALPHA: boolean;
  46011. SS_GAMMAREFRACTION: boolean;
  46012. SS_RGBDREFRACTION: boolean;
  46013. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46014. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46015. /** @hidden */
  46016. _areTexturesDirty: boolean;
  46017. }
  46018. /**
  46019. * Define the code related to the sub surface parameters of the pbr material.
  46020. */
  46021. export class PBRSubSurfaceConfiguration {
  46022. private _isRefractionEnabled;
  46023. /**
  46024. * Defines if the refraction is enabled in the material.
  46025. */
  46026. isRefractionEnabled: boolean;
  46027. private _isTranslucencyEnabled;
  46028. /**
  46029. * Defines if the translucency is enabled in the material.
  46030. */
  46031. isTranslucencyEnabled: boolean;
  46032. private _isScatteringEnabled;
  46033. /**
  46034. * Defines the refraction intensity of the material.
  46035. * The refraction when enabled replaces the Diffuse part of the material.
  46036. * The intensity helps transitionning between diffuse and refraction.
  46037. */
  46038. refractionIntensity: number;
  46039. /**
  46040. * Defines the translucency intensity of the material.
  46041. * When translucency has been enabled, this defines how much of the "translucency"
  46042. * is addded to the diffuse part of the material.
  46043. */
  46044. translucencyIntensity: number;
  46045. /**
  46046. * Defines the scattering intensity of the material.
  46047. * When scattering has been enabled, this defines how much of the "scattered light"
  46048. * is addded to the diffuse part of the material.
  46049. */
  46050. scatteringIntensity: number;
  46051. private _thicknessTexture;
  46052. /**
  46053. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  46054. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  46055. * 0 would mean minimumThickness
  46056. * 1 would mean maximumThickness
  46057. * The other channels might be use as a mask to vary the different effects intensity.
  46058. */
  46059. thicknessTexture: Nullable<BaseTexture>;
  46060. private _refractionTexture;
  46061. /**
  46062. * Defines the texture to use for refraction.
  46063. */
  46064. refractionTexture: Nullable<BaseTexture>;
  46065. private _indexOfRefraction;
  46066. /**
  46067. * Defines the indice of refraction used in the material.
  46068. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  46069. */
  46070. indexOfRefraction: number;
  46071. private _invertRefractionY;
  46072. /**
  46073. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  46074. */
  46075. invertRefractionY: boolean;
  46076. private _linkRefractionWithTransparency;
  46077. /**
  46078. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  46079. * Materials half opaque for instance using refraction could benefit from this control.
  46080. */
  46081. linkRefractionWithTransparency: boolean;
  46082. /**
  46083. * Defines the minimum thickness stored in the thickness map.
  46084. * If no thickness map is defined, this value will be used to simulate thickness.
  46085. */
  46086. minimumThickness: number;
  46087. /**
  46088. * Defines the maximum thickness stored in the thickness map.
  46089. */
  46090. maximumThickness: number;
  46091. /**
  46092. * Defines the volume tint of the material.
  46093. * This is used for both translucency and scattering.
  46094. */
  46095. tintColor: Color3;
  46096. /**
  46097. * Defines the distance at which the tint color should be found in the media.
  46098. * This is used for refraction only.
  46099. */
  46100. tintColorAtDistance: number;
  46101. /**
  46102. * Defines how far each channel transmit through the media.
  46103. * It is defined as a color to simplify it selection.
  46104. */
  46105. diffusionDistance: Color3;
  46106. private _useMaskFromThicknessTexture;
  46107. /**
  46108. * Stores the intensity of the different subsurface effects in the thickness texture.
  46109. * * the green channel is the translucency intensity.
  46110. * * the blue channel is the scattering intensity.
  46111. * * the alpha channel is the refraction intensity.
  46112. */
  46113. useMaskFromThicknessTexture: boolean;
  46114. /** @hidden */
  46115. private _internalMarkAllSubMeshesAsTexturesDirty;
  46116. /** @hidden */
  46117. _markAllSubMeshesAsTexturesDirty(): void;
  46118. /**
  46119. * Instantiate a new istance of sub surface configuration.
  46120. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  46121. */
  46122. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  46123. /**
  46124. * Gets wehter the submesh is ready to be used or not.
  46125. * @param defines the list of "defines" to update.
  46126. * @param scene defines the scene the material belongs to.
  46127. * @returns - boolean indicating that the submesh is ready or not.
  46128. */
  46129. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  46130. /**
  46131. * Checks to see if a texture is used in the material.
  46132. * @param defines the list of "defines" to update.
  46133. * @param scene defines the scene to the material belongs to.
  46134. */
  46135. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  46136. /**
  46137. * Binds the material data.
  46138. * @param uniformBuffer defines the Uniform buffer to fill in.
  46139. * @param scene defines the scene the material belongs to.
  46140. * @param engine defines the engine the material belongs to.
  46141. * @param isFrozen defines wether the material is frozen or not.
  46142. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  46143. */
  46144. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  46145. /**
  46146. * Unbinds the material from the mesh.
  46147. * @param activeEffect defines the effect that should be unbound from.
  46148. * @returns true if unbound, otherwise false
  46149. */
  46150. unbind(activeEffect: Effect): boolean;
  46151. /**
  46152. * Returns the texture used for refraction or null if none is used.
  46153. * @param scene defines the scene the material belongs to.
  46154. * @returns - Refraction texture if present. If no refraction texture and refraction
  46155. * is linked with transparency, returns environment texture. Otherwise, returns null.
  46156. */
  46157. private _getRefractionTexture;
  46158. /**
  46159. * Returns true if alpha blending should be disabled.
  46160. */
  46161. readonly disableAlphaBlending: boolean;
  46162. /**
  46163. * Fills the list of render target textures.
  46164. * @param renderTargets the list of render targets to update
  46165. */
  46166. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  46167. /**
  46168. * Checks to see if a texture is used in the material.
  46169. * @param texture - Base texture to use.
  46170. * @returns - Boolean specifying if a texture is used in the material.
  46171. */
  46172. hasTexture(texture: BaseTexture): boolean;
  46173. /**
  46174. * Gets a boolean indicating that current material needs to register RTT
  46175. * @returns true if this uses a render target otherwise false.
  46176. */
  46177. hasRenderTargetTextures(): boolean;
  46178. /**
  46179. * Returns an array of the actively used textures.
  46180. * @param activeTextures Array of BaseTextures
  46181. */
  46182. getActiveTextures(activeTextures: BaseTexture[]): void;
  46183. /**
  46184. * Returns the animatable textures.
  46185. * @param animatables Array of animatable textures.
  46186. */
  46187. getAnimatables(animatables: IAnimatable[]): void;
  46188. /**
  46189. * Disposes the resources of the material.
  46190. * @param forceDisposeTextures - Forces the disposal of all textures.
  46191. */
  46192. dispose(forceDisposeTextures?: boolean): void;
  46193. /**
  46194. * Get the current class name of the texture useful for serialization or dynamic coding.
  46195. * @returns "PBRSubSurfaceConfiguration"
  46196. */
  46197. getClassName(): string;
  46198. /**
  46199. * Add fallbacks to the effect fallbacks list.
  46200. * @param defines defines the Base texture to use.
  46201. * @param fallbacks defines the current fallback list.
  46202. * @param currentRank defines the current fallback rank.
  46203. * @returns the new fallback rank.
  46204. */
  46205. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  46206. /**
  46207. * Add the required uniforms to the current list.
  46208. * @param uniforms defines the current uniform list.
  46209. */
  46210. static AddUniforms(uniforms: string[]): void;
  46211. /**
  46212. * Add the required samplers to the current list.
  46213. * @param samplers defines the current sampler list.
  46214. */
  46215. static AddSamplers(samplers: string[]): void;
  46216. /**
  46217. * Add the required uniforms to the current buffer.
  46218. * @param uniformBuffer defines the current uniform buffer.
  46219. */
  46220. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  46221. /**
  46222. * Makes a duplicate of the current configuration into another one.
  46223. * @param configuration define the config where to copy the info
  46224. */
  46225. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  46226. /**
  46227. * Serializes this Sub Surface configuration.
  46228. * @returns - An object with the serialized config.
  46229. */
  46230. serialize(): any;
  46231. /**
  46232. * Parses a Sub Surface Configuration from a serialized object.
  46233. * @param source - Serialized object.
  46234. */
  46235. parse(source: any): void;
  46236. }
  46237. }
  46238. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  46239. /** @hidden */
  46240. export var pbrFragmentDeclaration: {
  46241. name: string;
  46242. shader: string;
  46243. };
  46244. }
  46245. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  46246. /** @hidden */
  46247. export var pbrUboDeclaration: {
  46248. name: string;
  46249. shader: string;
  46250. };
  46251. }
  46252. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  46253. /** @hidden */
  46254. export var pbrFragmentExtraDeclaration: {
  46255. name: string;
  46256. shader: string;
  46257. };
  46258. }
  46259. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  46260. /** @hidden */
  46261. export var pbrFragmentSamplersDeclaration: {
  46262. name: string;
  46263. shader: string;
  46264. };
  46265. }
  46266. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  46267. /** @hidden */
  46268. export var pbrHelperFunctions: {
  46269. name: string;
  46270. shader: string;
  46271. };
  46272. }
  46273. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  46274. /** @hidden */
  46275. export var harmonicsFunctions: {
  46276. name: string;
  46277. shader: string;
  46278. };
  46279. }
  46280. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  46281. /** @hidden */
  46282. export var pbrDirectLightingSetupFunctions: {
  46283. name: string;
  46284. shader: string;
  46285. };
  46286. }
  46287. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  46288. /** @hidden */
  46289. export var pbrDirectLightingFalloffFunctions: {
  46290. name: string;
  46291. shader: string;
  46292. };
  46293. }
  46294. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  46295. /** @hidden */
  46296. export var pbrBRDFFunctions: {
  46297. name: string;
  46298. shader: string;
  46299. };
  46300. }
  46301. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  46302. /** @hidden */
  46303. export var pbrDirectLightingFunctions: {
  46304. name: string;
  46305. shader: string;
  46306. };
  46307. }
  46308. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  46309. /** @hidden */
  46310. export var pbrIBLFunctions: {
  46311. name: string;
  46312. shader: string;
  46313. };
  46314. }
  46315. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  46316. /** @hidden */
  46317. export var pbrDebug: {
  46318. name: string;
  46319. shader: string;
  46320. };
  46321. }
  46322. declare module "babylonjs/Shaders/pbr.fragment" {
  46323. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  46324. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46325. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  46326. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46327. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46328. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  46329. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  46330. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  46331. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46332. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  46333. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46334. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  46335. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  46336. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  46337. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46338. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  46339. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  46340. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  46341. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  46342. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  46343. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  46344. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  46345. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  46346. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  46347. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  46348. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  46349. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  46350. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  46351. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  46352. /** @hidden */
  46353. export var pbrPixelShader: {
  46354. name: string;
  46355. shader: string;
  46356. };
  46357. }
  46358. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  46359. /** @hidden */
  46360. export var pbrVertexDeclaration: {
  46361. name: string;
  46362. shader: string;
  46363. };
  46364. }
  46365. declare module "babylonjs/Shaders/pbr.vertex" {
  46366. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  46367. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  46368. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  46369. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  46370. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  46371. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  46372. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  46373. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  46374. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  46375. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  46376. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  46377. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  46378. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  46379. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  46380. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  46381. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  46382. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  46383. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  46384. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  46385. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  46386. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  46387. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  46388. /** @hidden */
  46389. export var pbrVertexShader: {
  46390. name: string;
  46391. shader: string;
  46392. };
  46393. }
  46394. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  46395. import { IAnimatable } from "babylonjs/Misc/tools";
  46396. import { Nullable } from "babylonjs/types";
  46397. import { Scene } from "babylonjs/scene";
  46398. import { Matrix, Color3 } from "babylonjs/Maths/math";
  46399. import { SubMesh } from "babylonjs/Meshes/subMesh";
  46400. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46401. import { Mesh } from "babylonjs/Meshes/mesh";
  46402. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  46403. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  46404. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  46405. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  46406. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  46407. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  46408. import { Material } from "babylonjs/Materials/material";
  46409. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  46410. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  46411. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  46412. import "babylonjs/Shaders/pbr.fragment";
  46413. import "babylonjs/Shaders/pbr.vertex";
  46414. /**
  46415. * Manages the defines for the PBR Material.
  46416. * @hidden
  46417. */
  46418. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  46419. PBR: boolean;
  46420. MAINUV1: boolean;
  46421. MAINUV2: boolean;
  46422. UV1: boolean;
  46423. UV2: boolean;
  46424. ALBEDO: boolean;
  46425. ALBEDODIRECTUV: number;
  46426. VERTEXCOLOR: boolean;
  46427. AMBIENT: boolean;
  46428. AMBIENTDIRECTUV: number;
  46429. AMBIENTINGRAYSCALE: boolean;
  46430. OPACITY: boolean;
  46431. VERTEXALPHA: boolean;
  46432. OPACITYDIRECTUV: number;
  46433. OPACITYRGB: boolean;
  46434. ALPHATEST: boolean;
  46435. DEPTHPREPASS: boolean;
  46436. ALPHABLEND: boolean;
  46437. ALPHAFROMALBEDO: boolean;
  46438. ALPHATESTVALUE: string;
  46439. SPECULAROVERALPHA: boolean;
  46440. RADIANCEOVERALPHA: boolean;
  46441. ALPHAFRESNEL: boolean;
  46442. LINEARALPHAFRESNEL: boolean;
  46443. PREMULTIPLYALPHA: boolean;
  46444. EMISSIVE: boolean;
  46445. EMISSIVEDIRECTUV: number;
  46446. REFLECTIVITY: boolean;
  46447. REFLECTIVITYDIRECTUV: number;
  46448. SPECULARTERM: boolean;
  46449. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  46450. MICROSURFACEAUTOMATIC: boolean;
  46451. LODBASEDMICROSFURACE: boolean;
  46452. MICROSURFACEMAP: boolean;
  46453. MICROSURFACEMAPDIRECTUV: number;
  46454. METALLICWORKFLOW: boolean;
  46455. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  46456. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  46457. METALLNESSSTOREINMETALMAPBLUE: boolean;
  46458. AOSTOREINMETALMAPRED: boolean;
  46459. ENVIRONMENTBRDF: boolean;
  46460. ENVIRONMENTBRDF_RGBD: boolean;
  46461. NORMAL: boolean;
  46462. TANGENT: boolean;
  46463. BUMP: boolean;
  46464. BUMPDIRECTUV: number;
  46465. OBJECTSPACE_NORMALMAP: boolean;
  46466. PARALLAX: boolean;
  46467. PARALLAXOCCLUSION: boolean;
  46468. NORMALXYSCALE: boolean;
  46469. LIGHTMAP: boolean;
  46470. LIGHTMAPDIRECTUV: number;
  46471. USELIGHTMAPASSHADOWMAP: boolean;
  46472. GAMMALIGHTMAP: boolean;
  46473. REFLECTION: boolean;
  46474. REFLECTIONMAP_3D: boolean;
  46475. REFLECTIONMAP_SPHERICAL: boolean;
  46476. REFLECTIONMAP_PLANAR: boolean;
  46477. REFLECTIONMAP_CUBIC: boolean;
  46478. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  46479. REFLECTIONMAP_PROJECTION: boolean;
  46480. REFLECTIONMAP_SKYBOX: boolean;
  46481. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  46482. REFLECTIONMAP_EXPLICIT: boolean;
  46483. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  46484. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  46485. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  46486. INVERTCUBICMAP: boolean;
  46487. USESPHERICALFROMREFLECTIONMAP: boolean;
  46488. USESPHERICALINVERTEX: boolean;
  46489. REFLECTIONMAP_OPPOSITEZ: boolean;
  46490. LODINREFLECTIONALPHA: boolean;
  46491. GAMMAREFLECTION: boolean;
  46492. RGBDREFLECTION: boolean;
  46493. RADIANCEOCCLUSION: boolean;
  46494. HORIZONOCCLUSION: boolean;
  46495. INSTANCES: boolean;
  46496. NUM_BONE_INFLUENCERS: number;
  46497. BonesPerMesh: number;
  46498. BONETEXTURE: boolean;
  46499. NONUNIFORMSCALING: boolean;
  46500. MORPHTARGETS: boolean;
  46501. MORPHTARGETS_NORMAL: boolean;
  46502. MORPHTARGETS_TANGENT: boolean;
  46503. NUM_MORPH_INFLUENCERS: number;
  46504. IMAGEPROCESSING: boolean;
  46505. VIGNETTE: boolean;
  46506. VIGNETTEBLENDMODEMULTIPLY: boolean;
  46507. VIGNETTEBLENDMODEOPAQUE: boolean;
  46508. TONEMAPPING: boolean;
  46509. TONEMAPPING_ACES: boolean;
  46510. CONTRAST: boolean;
  46511. COLORCURVES: boolean;
  46512. COLORGRADING: boolean;
  46513. COLORGRADING3D: boolean;
  46514. SAMPLER3DGREENDEPTH: boolean;
  46515. SAMPLER3DBGRMAP: boolean;
  46516. IMAGEPROCESSINGPOSTPROCESS: boolean;
  46517. EXPOSURE: boolean;
  46518. MULTIVIEW: boolean;
  46519. USEPHYSICALLIGHTFALLOFF: boolean;
  46520. USEGLTFLIGHTFALLOFF: boolean;
  46521. TWOSIDEDLIGHTING: boolean;
  46522. SHADOWFLOAT: boolean;
  46523. CLIPPLANE: boolean;
  46524. CLIPPLANE2: boolean;
  46525. CLIPPLANE3: boolean;
  46526. CLIPPLANE4: boolean;
  46527. POINTSIZE: boolean;
  46528. FOG: boolean;
  46529. LOGARITHMICDEPTH: boolean;
  46530. FORCENORMALFORWARD: boolean;
  46531. SPECULARAA: boolean;
  46532. CLEARCOAT: boolean;
  46533. CLEARCOAT_DEFAULTIOR: boolean;
  46534. CLEARCOAT_TEXTURE: boolean;
  46535. CLEARCOAT_TEXTUREDIRECTUV: number;
  46536. CLEARCOAT_BUMP: boolean;
  46537. CLEARCOAT_BUMPDIRECTUV: number;
  46538. CLEARCOAT_TINT: boolean;
  46539. CLEARCOAT_TINT_TEXTURE: boolean;
  46540. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  46541. ANISOTROPIC: boolean;
  46542. ANISOTROPIC_TEXTURE: boolean;
  46543. ANISOTROPIC_TEXTUREDIRECTUV: number;
  46544. BRDF_V_HEIGHT_CORRELATED: boolean;
  46545. MS_BRDF_ENERGY_CONSERVATION: boolean;
  46546. SHEEN: boolean;
  46547. SHEEN_TEXTURE: boolean;
  46548. SHEEN_TEXTUREDIRECTUV: number;
  46549. SHEEN_LINKWITHALBEDO: boolean;
  46550. SUBSURFACE: boolean;
  46551. SS_REFRACTION: boolean;
  46552. SS_TRANSLUCENCY: boolean;
  46553. SS_SCATERRING: boolean;
  46554. SS_THICKNESSANDMASK_TEXTURE: boolean;
  46555. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  46556. SS_REFRACTIONMAP_3D: boolean;
  46557. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  46558. SS_LODINREFRACTIONALPHA: boolean;
  46559. SS_GAMMAREFRACTION: boolean;
  46560. SS_RGBDREFRACTION: boolean;
  46561. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  46562. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  46563. UNLIT: boolean;
  46564. DEBUGMODE: number;
  46565. /**
  46566. * Initializes the PBR Material defines.
  46567. */
  46568. constructor();
  46569. /**
  46570. * Resets the PBR Material defines.
  46571. */
  46572. reset(): void;
  46573. }
  46574. /**
  46575. * The Physically based material base class of BJS.
  46576. *
  46577. * This offers the main features of a standard PBR material.
  46578. * For more information, please refer to the documentation :
  46579. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  46580. */
  46581. export abstract class PBRBaseMaterial extends PushMaterial {
  46582. /**
  46583. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  46584. */
  46585. static readonly PBRMATERIAL_OPAQUE: number;
  46586. /**
  46587. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  46588. */
  46589. static readonly PBRMATERIAL_ALPHATEST: number;
  46590. /**
  46591. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46592. */
  46593. static readonly PBRMATERIAL_ALPHABLEND: number;
  46594. /**
  46595. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  46596. * They are also discarded below the alpha cutoff threshold to improve performances.
  46597. */
  46598. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  46599. /**
  46600. * Defines the default value of how much AO map is occluding the analytical lights
  46601. * (point spot...).
  46602. */
  46603. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  46604. /**
  46605. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  46606. */
  46607. static readonly LIGHTFALLOFF_PHYSICAL: number;
  46608. /**
  46609. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  46610. * to enhance interoperability with other engines.
  46611. */
  46612. static readonly LIGHTFALLOFF_GLTF: number;
  46613. /**
  46614. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  46615. * to enhance interoperability with other materials.
  46616. */
  46617. static readonly LIGHTFALLOFF_STANDARD: number;
  46618. /**
  46619. * Intensity of the direct lights e.g. the four lights available in your scene.
  46620. * This impacts both the direct diffuse and specular highlights.
  46621. */
  46622. protected _directIntensity: number;
  46623. /**
  46624. * Intensity of the emissive part of the material.
  46625. * This helps controlling the emissive effect without modifying the emissive color.
  46626. */
  46627. protected _emissiveIntensity: number;
  46628. /**
  46629. * Intensity of the environment e.g. how much the environment will light the object
  46630. * either through harmonics for rough material or through the refelction for shiny ones.
  46631. */
  46632. protected _environmentIntensity: number;
  46633. /**
  46634. * This is a special control allowing the reduction of the specular highlights coming from the
  46635. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  46636. */
  46637. protected _specularIntensity: number;
  46638. /**
  46639. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  46640. */
  46641. private _lightingInfos;
  46642. /**
  46643. * Debug Control allowing disabling the bump map on this material.
  46644. */
  46645. protected _disableBumpMap: boolean;
  46646. /**
  46647. * AKA Diffuse Texture in standard nomenclature.
  46648. */
  46649. protected _albedoTexture: Nullable<BaseTexture>;
  46650. /**
  46651. * AKA Occlusion Texture in other nomenclature.
  46652. */
  46653. protected _ambientTexture: Nullable<BaseTexture>;
  46654. /**
  46655. * AKA Occlusion Texture Intensity in other nomenclature.
  46656. */
  46657. protected _ambientTextureStrength: number;
  46658. /**
  46659. * Defines how much the AO map is occluding the analytical lights (point spot...).
  46660. * 1 means it completely occludes it
  46661. * 0 mean it has no impact
  46662. */
  46663. protected _ambientTextureImpactOnAnalyticalLights: number;
  46664. /**
  46665. * Stores the alpha values in a texture.
  46666. */
  46667. protected _opacityTexture: Nullable<BaseTexture>;
  46668. /**
  46669. * Stores the reflection values in a texture.
  46670. */
  46671. protected _reflectionTexture: Nullable<BaseTexture>;
  46672. /**
  46673. * Stores the emissive values in a texture.
  46674. */
  46675. protected _emissiveTexture: Nullable<BaseTexture>;
  46676. /**
  46677. * AKA Specular texture in other nomenclature.
  46678. */
  46679. protected _reflectivityTexture: Nullable<BaseTexture>;
  46680. /**
  46681. * Used to switch from specular/glossiness to metallic/roughness workflow.
  46682. */
  46683. protected _metallicTexture: Nullable<BaseTexture>;
  46684. /**
  46685. * Specifies the metallic scalar of the metallic/roughness workflow.
  46686. * Can also be used to scale the metalness values of the metallic texture.
  46687. */
  46688. protected _metallic: Nullable<number>;
  46689. /**
  46690. * Specifies the roughness scalar of the metallic/roughness workflow.
  46691. * Can also be used to scale the roughness values of the metallic texture.
  46692. */
  46693. protected _roughness: Nullable<number>;
  46694. /**
  46695. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  46696. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  46697. */
  46698. protected _microSurfaceTexture: Nullable<BaseTexture>;
  46699. /**
  46700. * Stores surface normal data used to displace a mesh in a texture.
  46701. */
  46702. protected _bumpTexture: Nullable<BaseTexture>;
  46703. /**
  46704. * Stores the pre-calculated light information of a mesh in a texture.
  46705. */
  46706. protected _lightmapTexture: Nullable<BaseTexture>;
  46707. /**
  46708. * The color of a material in ambient lighting.
  46709. */
  46710. protected _ambientColor: Color3;
  46711. /**
  46712. * AKA Diffuse Color in other nomenclature.
  46713. */
  46714. protected _albedoColor: Color3;
  46715. /**
  46716. * AKA Specular Color in other nomenclature.
  46717. */
  46718. protected _reflectivityColor: Color3;
  46719. /**
  46720. * The color applied when light is reflected from a material.
  46721. */
  46722. protected _reflectionColor: Color3;
  46723. /**
  46724. * The color applied when light is emitted from a material.
  46725. */
  46726. protected _emissiveColor: Color3;
  46727. /**
  46728. * AKA Glossiness in other nomenclature.
  46729. */
  46730. protected _microSurface: number;
  46731. /**
  46732. * Specifies that the material will use the light map as a show map.
  46733. */
  46734. protected _useLightmapAsShadowmap: boolean;
  46735. /**
  46736. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  46737. * makes the reflect vector face the model (under horizon).
  46738. */
  46739. protected _useHorizonOcclusion: boolean;
  46740. /**
  46741. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  46742. * too much the area relying on ambient texture to define their ambient occlusion.
  46743. */
  46744. protected _useRadianceOcclusion: boolean;
  46745. /**
  46746. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  46747. */
  46748. protected _useAlphaFromAlbedoTexture: boolean;
  46749. /**
  46750. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  46751. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  46752. */
  46753. protected _useSpecularOverAlpha: boolean;
  46754. /**
  46755. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  46756. */
  46757. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  46758. /**
  46759. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  46760. */
  46761. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  46762. /**
  46763. * Specifies if the metallic texture contains the roughness information in its green channel.
  46764. */
  46765. protected _useRoughnessFromMetallicTextureGreen: boolean;
  46766. /**
  46767. * Specifies if the metallic texture contains the metallness information in its blue channel.
  46768. */
  46769. protected _useMetallnessFromMetallicTextureBlue: boolean;
  46770. /**
  46771. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  46772. */
  46773. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  46774. /**
  46775. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  46776. */
  46777. protected _useAmbientInGrayScale: boolean;
  46778. /**
  46779. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  46780. * The material will try to infer what glossiness each pixel should be.
  46781. */
  46782. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  46783. /**
  46784. * Defines the falloff type used in this material.
  46785. * It by default is Physical.
  46786. */
  46787. protected _lightFalloff: number;
  46788. /**
  46789. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  46790. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  46791. */
  46792. protected _useRadianceOverAlpha: boolean;
  46793. /**
  46794. * Allows using an object space normal map (instead of tangent space).
  46795. */
  46796. protected _useObjectSpaceNormalMap: boolean;
  46797. /**
  46798. * Allows using the bump map in parallax mode.
  46799. */
  46800. protected _useParallax: boolean;
  46801. /**
  46802. * Allows using the bump map in parallax occlusion mode.
  46803. */
  46804. protected _useParallaxOcclusion: boolean;
  46805. /**
  46806. * Controls the scale bias of the parallax mode.
  46807. */
  46808. protected _parallaxScaleBias: number;
  46809. /**
  46810. * If sets to true, disables all the lights affecting the material.
  46811. */
  46812. protected _disableLighting: boolean;
  46813. /**
  46814. * Number of Simultaneous lights allowed on the material.
  46815. */
  46816. protected _maxSimultaneousLights: number;
  46817. /**
  46818. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  46819. */
  46820. protected _invertNormalMapX: boolean;
  46821. /**
  46822. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  46823. */
  46824. protected _invertNormalMapY: boolean;
  46825. /**
  46826. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  46827. */
  46828. protected _twoSidedLighting: boolean;
  46829. /**
  46830. * Defines the alpha limits in alpha test mode.
  46831. */
  46832. protected _alphaCutOff: number;
  46833. /**
  46834. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  46835. */
  46836. protected _forceAlphaTest: boolean;
  46837. /**
  46838. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46839. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  46840. */
  46841. protected _useAlphaFresnel: boolean;
  46842. /**
  46843. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  46844. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  46845. */
  46846. protected _useLinearAlphaFresnel: boolean;
  46847. /**
  46848. * The transparency mode of the material.
  46849. */
  46850. protected _transparencyMode: Nullable<number>;
  46851. /**
  46852. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  46853. * from cos thetav and roughness:
  46854. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  46855. */
  46856. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  46857. /**
  46858. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  46859. */
  46860. protected _forceIrradianceInFragment: boolean;
  46861. /**
  46862. * Force normal to face away from face.
  46863. */
  46864. protected _forceNormalForward: boolean;
  46865. /**
  46866. * Enables specular anti aliasing in the PBR shader.
  46867. * It will both interacts on the Geometry for analytical and IBL lighting.
  46868. * It also prefilter the roughness map based on the bump values.
  46869. */
  46870. protected _enableSpecularAntiAliasing: boolean;
  46871. /**
  46872. * Default configuration related to image processing available in the PBR Material.
  46873. */
  46874. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  46875. /**
  46876. * Keep track of the image processing observer to allow dispose and replace.
  46877. */
  46878. private _imageProcessingObserver;
  46879. /**
  46880. * Attaches a new image processing configuration to the PBR Material.
  46881. * @param configuration
  46882. */
  46883. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  46884. /**
  46885. * Stores the available render targets.
  46886. */
  46887. private _renderTargets;
  46888. /**
  46889. * Sets the global ambient color for the material used in lighting calculations.
  46890. */
  46891. private _globalAmbientColor;
  46892. /**
  46893. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  46894. */
  46895. private _useLogarithmicDepth;
  46896. /**
  46897. * If set to true, no lighting calculations will be applied.
  46898. */
  46899. private _unlit;
  46900. private _debugMode;
  46901. /**
  46902. * @hidden
  46903. * This is reserved for the inspector.
  46904. * Defines the material debug mode.
  46905. * It helps seeing only some components of the material while troubleshooting.
  46906. */
  46907. debugMode: number;
  46908. /**
  46909. * @hidden
  46910. * This is reserved for the inspector.
  46911. * Specify from where on screen the debug mode should start.
  46912. * The value goes from -1 (full screen) to 1 (not visible)
  46913. * It helps with side by side comparison against the final render
  46914. * This defaults to -1
  46915. */
  46916. private debugLimit;
  46917. /**
  46918. * @hidden
  46919. * This is reserved for the inspector.
  46920. * As the default viewing range might not be enough (if the ambient is really small for instance)
  46921. * You can use the factor to better multiply the final value.
  46922. */
  46923. private debugFactor;
  46924. /**
  46925. * Defines the clear coat layer parameters for the material.
  46926. */
  46927. readonly clearCoat: PBRClearCoatConfiguration;
  46928. /**
  46929. * Defines the anisotropic parameters for the material.
  46930. */
  46931. readonly anisotropy: PBRAnisotropicConfiguration;
  46932. /**
  46933. * Defines the BRDF parameters for the material.
  46934. */
  46935. readonly brdf: PBRBRDFConfiguration;
  46936. /**
  46937. * Defines the Sheen parameters for the material.
  46938. */
  46939. readonly sheen: PBRSheenConfiguration;
  46940. /**
  46941. * Defines the SubSurface parameters for the material.
  46942. */
  46943. readonly subSurface: PBRSubSurfaceConfiguration;
  46944. /**
  46945. * Custom callback helping to override the default shader used in the material.
  46946. */
  46947. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  46948. /**
  46949. * Instantiates a new PBRMaterial instance.
  46950. *
  46951. * @param name The material name
  46952. * @param scene The scene the material will be use in.
  46953. */
  46954. constructor(name: string, scene: Scene);
  46955. /**
  46956. * Gets a boolean indicating that current material needs to register RTT
  46957. */
  46958. readonly hasRenderTargetTextures: boolean;
  46959. /**
  46960. * Gets the name of the material class.
  46961. */
  46962. getClassName(): string;
  46963. /**
  46964. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46965. */
  46966. /**
  46967. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  46968. */
  46969. useLogarithmicDepth: boolean;
  46970. /**
  46971. * Gets the current transparency mode.
  46972. */
  46973. /**
  46974. * Sets the transparency mode of the material.
  46975. *
  46976. * | Value | Type | Description |
  46977. * | ----- | ----------------------------------- | ----------- |
  46978. * | 0 | OPAQUE | |
  46979. * | 1 | ALPHATEST | |
  46980. * | 2 | ALPHABLEND | |
  46981. * | 3 | ALPHATESTANDBLEND | |
  46982. *
  46983. */
  46984. transparencyMode: Nullable<number>;
  46985. /**
  46986. * Returns true if alpha blending should be disabled.
  46987. */
  46988. private readonly _disableAlphaBlending;
  46989. /**
  46990. * Specifies whether or not this material should be rendered in alpha blend mode.
  46991. */
  46992. needAlphaBlending(): boolean;
  46993. /**
  46994. * Specifies if the mesh will require alpha blending.
  46995. * @param mesh - BJS mesh.
  46996. */
  46997. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  46998. /**
  46999. * Specifies whether or not this material should be rendered in alpha test mode.
  47000. */
  47001. needAlphaTesting(): boolean;
  47002. /**
  47003. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  47004. */
  47005. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  47006. /**
  47007. * Gets the texture used for the alpha test.
  47008. */
  47009. getAlphaTestTexture(): Nullable<BaseTexture>;
  47010. /**
  47011. * Specifies that the submesh is ready to be used.
  47012. * @param mesh - BJS mesh.
  47013. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  47014. * @param useInstances - Specifies that instances should be used.
  47015. * @returns - boolean indicating that the submesh is ready or not.
  47016. */
  47017. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  47018. /**
  47019. * Specifies if the material uses metallic roughness workflow.
  47020. * @returns boolean specifiying if the material uses metallic roughness workflow.
  47021. */
  47022. isMetallicWorkflow(): boolean;
  47023. private _prepareEffect;
  47024. private _prepareDefines;
  47025. /**
  47026. * Force shader compilation
  47027. */
  47028. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  47029. clipPlane: boolean;
  47030. }>): void;
  47031. /**
  47032. * Initializes the uniform buffer layout for the shader.
  47033. */
  47034. buildUniformLayout(): void;
  47035. /**
  47036. * Unbinds the material from the mesh
  47037. */
  47038. unbind(): void;
  47039. /**
  47040. * Binds the submesh data.
  47041. * @param world - The world matrix.
  47042. * @param mesh - The BJS mesh.
  47043. * @param subMesh - A submesh of the BJS mesh.
  47044. */
  47045. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  47046. /**
  47047. * Returns the animatable textures.
  47048. * @returns - Array of animatable textures.
  47049. */
  47050. getAnimatables(): IAnimatable[];
  47051. /**
  47052. * Returns the texture used for reflections.
  47053. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  47054. */
  47055. private _getReflectionTexture;
  47056. /**
  47057. * Returns an array of the actively used textures.
  47058. * @returns - Array of BaseTextures
  47059. */
  47060. getActiveTextures(): BaseTexture[];
  47061. /**
  47062. * Checks to see if a texture is used in the material.
  47063. * @param texture - Base texture to use.
  47064. * @returns - Boolean specifying if a texture is used in the material.
  47065. */
  47066. hasTexture(texture: BaseTexture): boolean;
  47067. /**
  47068. * Disposes the resources of the material.
  47069. * @param forceDisposeEffect - Forces the disposal of effects.
  47070. * @param forceDisposeTextures - Forces the disposal of all textures.
  47071. */
  47072. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  47073. }
  47074. }
  47075. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  47076. import { Nullable } from "babylonjs/types";
  47077. import { Scene } from "babylonjs/scene";
  47078. import { Color3 } from "babylonjs/Maths/math";
  47079. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  47080. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  47081. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47082. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  47083. /**
  47084. * The Physically based material of BJS.
  47085. *
  47086. * This offers the main features of a standard PBR material.
  47087. * For more information, please refer to the documentation :
  47088. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  47089. */
  47090. export class PBRMaterial extends PBRBaseMaterial {
  47091. /**
  47092. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  47093. */
  47094. static readonly PBRMATERIAL_OPAQUE: number;
  47095. /**
  47096. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  47097. */
  47098. static readonly PBRMATERIAL_ALPHATEST: number;
  47099. /**
  47100. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47101. */
  47102. static readonly PBRMATERIAL_ALPHABLEND: number;
  47103. /**
  47104. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  47105. * They are also discarded below the alpha cutoff threshold to improve performances.
  47106. */
  47107. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  47108. /**
  47109. * Defines the default value of how much AO map is occluding the analytical lights
  47110. * (point spot...).
  47111. */
  47112. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  47113. /**
  47114. * Intensity of the direct lights e.g. the four lights available in your scene.
  47115. * This impacts both the direct diffuse and specular highlights.
  47116. */
  47117. directIntensity: number;
  47118. /**
  47119. * Intensity of the emissive part of the material.
  47120. * This helps controlling the emissive effect without modifying the emissive color.
  47121. */
  47122. emissiveIntensity: number;
  47123. /**
  47124. * Intensity of the environment e.g. how much the environment will light the object
  47125. * either through harmonics for rough material or through the refelction for shiny ones.
  47126. */
  47127. environmentIntensity: number;
  47128. /**
  47129. * This is a special control allowing the reduction of the specular highlights coming from the
  47130. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  47131. */
  47132. specularIntensity: number;
  47133. /**
  47134. * Debug Control allowing disabling the bump map on this material.
  47135. */
  47136. disableBumpMap: boolean;
  47137. /**
  47138. * AKA Diffuse Texture in standard nomenclature.
  47139. */
  47140. albedoTexture: BaseTexture;
  47141. /**
  47142. * AKA Occlusion Texture in other nomenclature.
  47143. */
  47144. ambientTexture: BaseTexture;
  47145. /**
  47146. * AKA Occlusion Texture Intensity in other nomenclature.
  47147. */
  47148. ambientTextureStrength: number;
  47149. /**
  47150. * Defines how much the AO map is occluding the analytical lights (point spot...).
  47151. * 1 means it completely occludes it
  47152. * 0 mean it has no impact
  47153. */
  47154. ambientTextureImpactOnAnalyticalLights: number;
  47155. /**
  47156. * Stores the alpha values in a texture.
  47157. */
  47158. opacityTexture: BaseTexture;
  47159. /**
  47160. * Stores the reflection values in a texture.
  47161. */
  47162. reflectionTexture: Nullable<BaseTexture>;
  47163. /**
  47164. * Stores the emissive values in a texture.
  47165. */
  47166. emissiveTexture: BaseTexture;
  47167. /**
  47168. * AKA Specular texture in other nomenclature.
  47169. */
  47170. reflectivityTexture: BaseTexture;
  47171. /**
  47172. * Used to switch from specular/glossiness to metallic/roughness workflow.
  47173. */
  47174. metallicTexture: BaseTexture;
  47175. /**
  47176. * Specifies the metallic scalar of the metallic/roughness workflow.
  47177. * Can also be used to scale the metalness values of the metallic texture.
  47178. */
  47179. metallic: Nullable<number>;
  47180. /**
  47181. * Specifies the roughness scalar of the metallic/roughness workflow.
  47182. * Can also be used to scale the roughness values of the metallic texture.
  47183. */
  47184. roughness: Nullable<number>;
  47185. /**
  47186. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  47187. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  47188. */
  47189. microSurfaceTexture: BaseTexture;
  47190. /**
  47191. * Stores surface normal data used to displace a mesh in a texture.
  47192. */
  47193. bumpTexture: BaseTexture;
  47194. /**
  47195. * Stores the pre-calculated light information of a mesh in a texture.
  47196. */
  47197. lightmapTexture: BaseTexture;
  47198. /**
  47199. * Stores the refracted light information in a texture.
  47200. */
  47201. refractionTexture: Nullable<BaseTexture>;
  47202. /**
  47203. * The color of a material in ambient lighting.
  47204. */
  47205. ambientColor: Color3;
  47206. /**
  47207. * AKA Diffuse Color in other nomenclature.
  47208. */
  47209. albedoColor: Color3;
  47210. /**
  47211. * AKA Specular Color in other nomenclature.
  47212. */
  47213. reflectivityColor: Color3;
  47214. /**
  47215. * The color reflected from the material.
  47216. */
  47217. reflectionColor: Color3;
  47218. /**
  47219. * The color emitted from the material.
  47220. */
  47221. emissiveColor: Color3;
  47222. /**
  47223. * AKA Glossiness in other nomenclature.
  47224. */
  47225. microSurface: number;
  47226. /**
  47227. * source material index of refraction (IOR)' / 'destination material IOR.
  47228. */
  47229. indexOfRefraction: number;
  47230. /**
  47231. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  47232. */
  47233. invertRefractionY: boolean;
  47234. /**
  47235. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  47236. * Materials half opaque for instance using refraction could benefit from this control.
  47237. */
  47238. linkRefractionWithTransparency: boolean;
  47239. /**
  47240. * If true, the light map contains occlusion information instead of lighting info.
  47241. */
  47242. useLightmapAsShadowmap: boolean;
  47243. /**
  47244. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  47245. */
  47246. useAlphaFromAlbedoTexture: boolean;
  47247. /**
  47248. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  47249. */
  47250. forceAlphaTest: boolean;
  47251. /**
  47252. * Defines the alpha limits in alpha test mode.
  47253. */
  47254. alphaCutOff: number;
  47255. /**
  47256. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  47257. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  47258. */
  47259. useSpecularOverAlpha: boolean;
  47260. /**
  47261. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  47262. */
  47263. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  47264. /**
  47265. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  47266. */
  47267. useRoughnessFromMetallicTextureAlpha: boolean;
  47268. /**
  47269. * Specifies if the metallic texture contains the roughness information in its green channel.
  47270. */
  47271. useRoughnessFromMetallicTextureGreen: boolean;
  47272. /**
  47273. * Specifies if the metallic texture contains the metallness information in its blue channel.
  47274. */
  47275. useMetallnessFromMetallicTextureBlue: boolean;
  47276. /**
  47277. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  47278. */
  47279. useAmbientOcclusionFromMetallicTextureRed: boolean;
  47280. /**
  47281. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  47282. */
  47283. useAmbientInGrayScale: boolean;
  47284. /**
  47285. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  47286. * The material will try to infer what glossiness each pixel should be.
  47287. */
  47288. useAutoMicroSurfaceFromReflectivityMap: boolean;
  47289. /**
  47290. * BJS is using an harcoded light falloff based on a manually sets up range.
  47291. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47292. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47293. */
  47294. /**
  47295. * BJS is using an harcoded light falloff based on a manually sets up range.
  47296. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  47297. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  47298. */
  47299. usePhysicalLightFalloff: boolean;
  47300. /**
  47301. * In order to support the falloff compatibility with gltf, a special mode has been added
  47302. * to reproduce the gltf light falloff.
  47303. */
  47304. /**
  47305. * In order to support the falloff compatibility with gltf, a special mode has been added
  47306. * to reproduce the gltf light falloff.
  47307. */
  47308. useGLTFLightFalloff: boolean;
  47309. /**
  47310. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  47311. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  47312. */
  47313. useRadianceOverAlpha: boolean;
  47314. /**
  47315. * Allows using an object space normal map (instead of tangent space).
  47316. */
  47317. useObjectSpaceNormalMap: boolean;
  47318. /**
  47319. * Allows using the bump map in parallax mode.
  47320. */
  47321. useParallax: boolean;
  47322. /**
  47323. * Allows using the bump map in parallax occlusion mode.
  47324. */
  47325. useParallaxOcclusion: boolean;
  47326. /**
  47327. * Controls the scale bias of the parallax mode.
  47328. */
  47329. parallaxScaleBias: number;
  47330. /**
  47331. * If sets to true, disables all the lights affecting the material.
  47332. */
  47333. disableLighting: boolean;
  47334. /**
  47335. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  47336. */
  47337. forceIrradianceInFragment: boolean;
  47338. /**
  47339. * Number of Simultaneous lights allowed on the material.
  47340. */
  47341. maxSimultaneousLights: number;
  47342. /**
  47343. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  47344. */
  47345. invertNormalMapX: boolean;
  47346. /**
  47347. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  47348. */
  47349. invertNormalMapY: boolean;
  47350. /**
  47351. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  47352. */
  47353. twoSidedLighting: boolean;
  47354. /**
  47355. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47356. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  47357. */
  47358. useAlphaFresnel: boolean;
  47359. /**
  47360. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  47361. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  47362. */
  47363. useLinearAlphaFresnel: boolean;
  47364. /**
  47365. * Let user defines the brdf lookup texture used for IBL.
  47366. * A default 8bit version is embedded but you could point at :
  47367. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  47368. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  47369. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  47370. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  47371. */
  47372. environmentBRDFTexture: Nullable<BaseTexture>;
  47373. /**
  47374. * Force normal to face away from face.
  47375. */
  47376. forceNormalForward: boolean;
  47377. /**
  47378. * Enables specular anti aliasing in the PBR shader.
  47379. * It will both interacts on the Geometry for analytical and IBL lighting.
  47380. * It also prefilter the roughness map based on the bump values.
  47381. */
  47382. enableSpecularAntiAliasing: boolean;
  47383. /**
  47384. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  47385. * makes the reflect vector face the model (under horizon).
  47386. */
  47387. useHorizonOcclusion: boolean;
  47388. /**
  47389. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  47390. * too much the area relying on ambient texture to define their ambient occlusion.
  47391. */
  47392. useRadianceOcclusion: boolean;
  47393. /**
  47394. * If set to true, no lighting calculations will be applied.
  47395. */
  47396. unlit: boolean;
  47397. /**
  47398. * Gets the image processing configuration used either in this material.
  47399. */
  47400. /**
  47401. * Sets the Default image processing configuration used either in the this material.
  47402. *
  47403. * If sets to null, the scene one is in use.
  47404. */
  47405. imageProcessingConfiguration: ImageProcessingConfiguration;
  47406. /**
  47407. * Gets wether the color curves effect is enabled.
  47408. */
  47409. /**
  47410. * Sets wether the color curves effect is enabled.
  47411. */
  47412. cameraColorCurvesEnabled: boolean;
  47413. /**
  47414. * Gets wether the color grading effect is enabled.
  47415. */
  47416. /**
  47417. * Gets wether the color grading effect is enabled.
  47418. */
  47419. cameraColorGradingEnabled: boolean;
  47420. /**
  47421. * Gets wether tonemapping is enabled or not.
  47422. */
  47423. /**
  47424. * Sets wether tonemapping is enabled or not
  47425. */
  47426. cameraToneMappingEnabled: boolean;
  47427. /**
  47428. * The camera exposure used on this material.
  47429. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47430. * This corresponds to a photographic exposure.
  47431. */
  47432. /**
  47433. * The camera exposure used on this material.
  47434. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  47435. * This corresponds to a photographic exposure.
  47436. */
  47437. cameraExposure: number;
  47438. /**
  47439. * Gets The camera contrast used on this material.
  47440. */
  47441. /**
  47442. * Sets The camera contrast used on this material.
  47443. */
  47444. cameraContrast: number;
  47445. /**
  47446. * Gets the Color Grading 2D Lookup Texture.
  47447. */
  47448. /**
  47449. * Sets the Color Grading 2D Lookup Texture.
  47450. */
  47451. cameraColorGradingTexture: Nullable<BaseTexture>;
  47452. /**
  47453. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47454. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47455. * 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;
  47456. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47457. */
  47458. /**
  47459. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  47460. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  47461. * 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;
  47462. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  47463. */
  47464. cameraColorCurves: Nullable<ColorCurves>;
  47465. /**
  47466. * Instantiates a new PBRMaterial instance.
  47467. *
  47468. * @param name The material name
  47469. * @param scene The scene the material will be use in.
  47470. */
  47471. constructor(name: string, scene: Scene);
  47472. /**
  47473. * Returns the name of this material class.
  47474. */
  47475. getClassName(): string;
  47476. /**
  47477. * Makes a duplicate of the current material.
  47478. * @param name - name to use for the new material.
  47479. */
  47480. clone(name: string): PBRMaterial;
  47481. /**
  47482. * Serializes this PBR Material.
  47483. * @returns - An object with the serialized material.
  47484. */
  47485. serialize(): any;
  47486. /**
  47487. * Parses a PBR Material from a serialized object.
  47488. * @param source - Serialized object.
  47489. * @param scene - BJS scene instance.
  47490. * @param rootUrl - url for the scene object
  47491. * @returns - PBRMaterial
  47492. */
  47493. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  47494. }
  47495. }
  47496. declare module "babylonjs/Misc/dds" {
  47497. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47498. import { Engine } from "babylonjs/Engines/engine";
  47499. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47500. import { Nullable } from "babylonjs/types";
  47501. import { Scene } from "babylonjs/scene";
  47502. /**
  47503. * Direct draw surface info
  47504. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  47505. */
  47506. export interface DDSInfo {
  47507. /**
  47508. * Width of the texture
  47509. */
  47510. width: number;
  47511. /**
  47512. * Width of the texture
  47513. */
  47514. height: number;
  47515. /**
  47516. * Number of Mipmaps for the texture
  47517. * @see https://en.wikipedia.org/wiki/Mipmap
  47518. */
  47519. mipmapCount: number;
  47520. /**
  47521. * If the textures format is a known fourCC format
  47522. * @see https://www.fourcc.org/
  47523. */
  47524. isFourCC: boolean;
  47525. /**
  47526. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  47527. */
  47528. isRGB: boolean;
  47529. /**
  47530. * If the texture is a lumincance format
  47531. */
  47532. isLuminance: boolean;
  47533. /**
  47534. * If this is a cube texture
  47535. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  47536. */
  47537. isCube: boolean;
  47538. /**
  47539. * If the texture is a compressed format eg. FOURCC_DXT1
  47540. */
  47541. isCompressed: boolean;
  47542. /**
  47543. * The dxgiFormat of the texture
  47544. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  47545. */
  47546. dxgiFormat: number;
  47547. /**
  47548. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  47549. */
  47550. textureType: number;
  47551. /**
  47552. * Sphericle polynomial created for the dds texture
  47553. */
  47554. sphericalPolynomial?: SphericalPolynomial;
  47555. }
  47556. /**
  47557. * Class used to provide DDS decompression tools
  47558. */
  47559. export class DDSTools {
  47560. /**
  47561. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  47562. */
  47563. static StoreLODInAlphaChannel: boolean;
  47564. /**
  47565. * Gets DDS information from an array buffer
  47566. * @param arrayBuffer defines the array buffer to read data from
  47567. * @returns the DDS information
  47568. */
  47569. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  47570. private static _FloatView;
  47571. private static _Int32View;
  47572. private static _ToHalfFloat;
  47573. private static _FromHalfFloat;
  47574. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  47575. private static _GetHalfFloatRGBAArrayBuffer;
  47576. private static _GetFloatRGBAArrayBuffer;
  47577. private static _GetFloatAsUIntRGBAArrayBuffer;
  47578. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  47579. private static _GetRGBAArrayBuffer;
  47580. private static _ExtractLongWordOrder;
  47581. private static _GetRGBArrayBuffer;
  47582. private static _GetLuminanceArrayBuffer;
  47583. /**
  47584. * Uploads DDS Levels to a Babylon Texture
  47585. * @hidden
  47586. */
  47587. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  47588. }
  47589. module "babylonjs/Engines/engine" {
  47590. interface Engine {
  47591. /**
  47592. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  47593. * @param rootUrl defines the url where the file to load is located
  47594. * @param scene defines the current scene
  47595. * @param lodScale defines scale to apply to the mip map selection
  47596. * @param lodOffset defines offset to apply to the mip map selection
  47597. * @param onLoad defines an optional callback raised when the texture is loaded
  47598. * @param onError defines an optional callback raised if there is an issue to load the texture
  47599. * @param format defines the format of the data
  47600. * @param forcedExtension defines the extension to use to pick the right loader
  47601. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  47602. * @returns the cube texture as an InternalTexture
  47603. */
  47604. 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;
  47605. }
  47606. }
  47607. }
  47608. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  47609. import { Nullable } from "babylonjs/types";
  47610. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47611. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47612. /**
  47613. * Implementation of the DDS Texture Loader.
  47614. * @hidden
  47615. */
  47616. export class _DDSTextureLoader implements IInternalTextureLoader {
  47617. /**
  47618. * Defines wether the loader supports cascade loading the different faces.
  47619. */
  47620. readonly supportCascades: boolean;
  47621. /**
  47622. * This returns if the loader support the current file information.
  47623. * @param extension defines the file extension of the file being loaded
  47624. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47625. * @param fallback defines the fallback internal texture if any
  47626. * @param isBase64 defines whether the texture is encoded as a base64
  47627. * @param isBuffer defines whether the texture data are stored as a buffer
  47628. * @returns true if the loader can load the specified file
  47629. */
  47630. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47631. /**
  47632. * Transform the url before loading if required.
  47633. * @param rootUrl the url of the texture
  47634. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47635. * @returns the transformed texture
  47636. */
  47637. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47638. /**
  47639. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47640. * @param rootUrl the url of the texture
  47641. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47642. * @returns the fallback texture
  47643. */
  47644. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47645. /**
  47646. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47647. * @param data contains the texture data
  47648. * @param texture defines the BabylonJS internal texture
  47649. * @param createPolynomials will be true if polynomials have been requested
  47650. * @param onLoad defines the callback to trigger once the texture is ready
  47651. * @param onError defines the callback to trigger in case of error
  47652. */
  47653. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47654. /**
  47655. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47656. * @param data contains the texture data
  47657. * @param texture defines the BabylonJS internal texture
  47658. * @param callback defines the method to call once ready to upload
  47659. */
  47660. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47661. }
  47662. }
  47663. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  47664. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  47665. /** @hidden */
  47666. export var rgbdEncodePixelShader: {
  47667. name: string;
  47668. shader: string;
  47669. };
  47670. }
  47671. declare module "babylonjs/Misc/environmentTextureTools" {
  47672. import { Nullable } from "babylonjs/types";
  47673. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  47674. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47675. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  47676. import "babylonjs/Shaders/rgbdEncode.fragment";
  47677. import "babylonjs/Shaders/rgbdDecode.fragment";
  47678. /**
  47679. * Raw texture data and descriptor sufficient for WebGL texture upload
  47680. */
  47681. export interface EnvironmentTextureInfo {
  47682. /**
  47683. * Version of the environment map
  47684. */
  47685. version: number;
  47686. /**
  47687. * Width of image
  47688. */
  47689. width: number;
  47690. /**
  47691. * Irradiance information stored in the file.
  47692. */
  47693. irradiance: any;
  47694. /**
  47695. * Specular information stored in the file.
  47696. */
  47697. specular: any;
  47698. }
  47699. /**
  47700. * Sets of helpers addressing the serialization and deserialization of environment texture
  47701. * stored in a BabylonJS env file.
  47702. * Those files are usually stored as .env files.
  47703. */
  47704. export class EnvironmentTextureTools {
  47705. /**
  47706. * Magic number identifying the env file.
  47707. */
  47708. private static _MagicBytes;
  47709. /**
  47710. * Gets the environment info from an env file.
  47711. * @param data The array buffer containing the .env bytes.
  47712. * @returns the environment file info (the json header) if successfully parsed.
  47713. */
  47714. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  47715. /**
  47716. * Creates an environment texture from a loaded cube texture.
  47717. * @param texture defines the cube texture to convert in env file
  47718. * @return a promise containing the environment data if succesfull.
  47719. */
  47720. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  47721. /**
  47722. * Creates a JSON representation of the spherical data.
  47723. * @param texture defines the texture containing the polynomials
  47724. * @return the JSON representation of the spherical info
  47725. */
  47726. private static _CreateEnvTextureIrradiance;
  47727. /**
  47728. * Uploads the texture info contained in the env file to the GPU.
  47729. * @param texture defines the internal texture to upload to
  47730. * @param arrayBuffer defines the buffer cotaining the data to load
  47731. * @param info defines the texture info retrieved through the GetEnvInfo method
  47732. * @returns a promise
  47733. */
  47734. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  47735. /**
  47736. * Uploads the levels of image data to the GPU.
  47737. * @param texture defines the internal texture to upload to
  47738. * @param imageData defines the array buffer views of image data [mipmap][face]
  47739. * @returns a promise
  47740. */
  47741. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  47742. /**
  47743. * Uploads spherical polynomials information to the texture.
  47744. * @param texture defines the texture we are trying to upload the information to
  47745. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  47746. */
  47747. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  47748. /** @hidden */
  47749. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  47750. }
  47751. }
  47752. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  47753. import { Nullable } from "babylonjs/types";
  47754. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47755. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47756. /**
  47757. * Implementation of the ENV Texture Loader.
  47758. * @hidden
  47759. */
  47760. export class _ENVTextureLoader implements IInternalTextureLoader {
  47761. /**
  47762. * Defines wether the loader supports cascade loading the different faces.
  47763. */
  47764. readonly supportCascades: boolean;
  47765. /**
  47766. * This returns if the loader support the current file information.
  47767. * @param extension defines the file extension of the file being loaded
  47768. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47769. * @param fallback defines the fallback internal texture if any
  47770. * @param isBase64 defines whether the texture is encoded as a base64
  47771. * @param isBuffer defines whether the texture data are stored as a buffer
  47772. * @returns true if the loader can load the specified file
  47773. */
  47774. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47775. /**
  47776. * Transform the url before loading if required.
  47777. * @param rootUrl the url of the texture
  47778. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47779. * @returns the transformed texture
  47780. */
  47781. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47782. /**
  47783. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47784. * @param rootUrl the url of the texture
  47785. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47786. * @returns the fallback texture
  47787. */
  47788. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47789. /**
  47790. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47791. * @param data contains the texture data
  47792. * @param texture defines the BabylonJS internal texture
  47793. * @param createPolynomials will be true if polynomials have been requested
  47794. * @param onLoad defines the callback to trigger once the texture is ready
  47795. * @param onError defines the callback to trigger in case of error
  47796. */
  47797. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47798. /**
  47799. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47800. * @param data contains the texture data
  47801. * @param texture defines the BabylonJS internal texture
  47802. * @param callback defines the method to call once ready to upload
  47803. */
  47804. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  47805. }
  47806. }
  47807. declare module "babylonjs/Misc/khronosTextureContainer" {
  47808. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47809. /**
  47810. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  47811. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  47812. */
  47813. export class KhronosTextureContainer {
  47814. /** contents of the KTX container file */
  47815. arrayBuffer: any;
  47816. private static HEADER_LEN;
  47817. private static COMPRESSED_2D;
  47818. private static COMPRESSED_3D;
  47819. private static TEX_2D;
  47820. private static TEX_3D;
  47821. /**
  47822. * Gets the openGL type
  47823. */
  47824. glType: number;
  47825. /**
  47826. * Gets the openGL type size
  47827. */
  47828. glTypeSize: number;
  47829. /**
  47830. * Gets the openGL format
  47831. */
  47832. glFormat: number;
  47833. /**
  47834. * Gets the openGL internal format
  47835. */
  47836. glInternalFormat: number;
  47837. /**
  47838. * Gets the base internal format
  47839. */
  47840. glBaseInternalFormat: number;
  47841. /**
  47842. * Gets image width in pixel
  47843. */
  47844. pixelWidth: number;
  47845. /**
  47846. * Gets image height in pixel
  47847. */
  47848. pixelHeight: number;
  47849. /**
  47850. * Gets image depth in pixels
  47851. */
  47852. pixelDepth: number;
  47853. /**
  47854. * Gets the number of array elements
  47855. */
  47856. numberOfArrayElements: number;
  47857. /**
  47858. * Gets the number of faces
  47859. */
  47860. numberOfFaces: number;
  47861. /**
  47862. * Gets the number of mipmap levels
  47863. */
  47864. numberOfMipmapLevels: number;
  47865. /**
  47866. * Gets the bytes of key value data
  47867. */
  47868. bytesOfKeyValueData: number;
  47869. /**
  47870. * Gets the load type
  47871. */
  47872. loadType: number;
  47873. /**
  47874. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  47875. */
  47876. isInvalid: boolean;
  47877. /**
  47878. * Creates a new KhronosTextureContainer
  47879. * @param arrayBuffer contents of the KTX container file
  47880. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  47881. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  47882. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  47883. */
  47884. constructor(
  47885. /** contents of the KTX container file */
  47886. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  47887. /**
  47888. * Uploads KTX content to a Babylon Texture.
  47889. * It is assumed that the texture has already been created & is currently bound
  47890. * @hidden
  47891. */
  47892. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  47893. private _upload2DCompressedLevels;
  47894. }
  47895. }
  47896. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  47897. import { Nullable } from "babylonjs/types";
  47898. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  47899. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  47900. /**
  47901. * Implementation of the KTX Texture Loader.
  47902. * @hidden
  47903. */
  47904. export class _KTXTextureLoader implements IInternalTextureLoader {
  47905. /**
  47906. * Defines wether the loader supports cascade loading the different faces.
  47907. */
  47908. readonly supportCascades: boolean;
  47909. /**
  47910. * This returns if the loader support the current file information.
  47911. * @param extension defines the file extension of the file being loaded
  47912. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47913. * @param fallback defines the fallback internal texture if any
  47914. * @param isBase64 defines whether the texture is encoded as a base64
  47915. * @param isBuffer defines whether the texture data are stored as a buffer
  47916. * @returns true if the loader can load the specified file
  47917. */
  47918. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  47919. /**
  47920. * Transform the url before loading if required.
  47921. * @param rootUrl the url of the texture
  47922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47923. * @returns the transformed texture
  47924. */
  47925. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  47926. /**
  47927. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  47928. * @param rootUrl the url of the texture
  47929. * @param textureFormatInUse defines the current compressed format in use iun the engine
  47930. * @returns the fallback texture
  47931. */
  47932. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  47933. /**
  47934. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  47935. * @param data contains the texture data
  47936. * @param texture defines the BabylonJS internal texture
  47937. * @param createPolynomials will be true if polynomials have been requested
  47938. * @param onLoad defines the callback to trigger once the texture is ready
  47939. * @param onError defines the callback to trigger in case of error
  47940. */
  47941. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  47942. /**
  47943. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  47944. * @param data contains the texture data
  47945. * @param texture defines the BabylonJS internal texture
  47946. * @param callback defines the method to call once ready to upload
  47947. */
  47948. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  47949. }
  47950. }
  47951. declare module "babylonjs/Helpers/sceneHelpers" {
  47952. import { Nullable } from "babylonjs/types";
  47953. import { Mesh } from "babylonjs/Meshes/mesh";
  47954. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  47955. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  47956. import { WebXRExperienceHelper } from "babylonjs/Cameras/XR/webXRExperienceHelper";
  47957. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  47958. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  47959. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  47960. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  47961. import "babylonjs/Meshes/Builders/boxBuilder";
  47962. /** @hidden */
  47963. export var _forceSceneHelpersToBundle: boolean;
  47964. module "babylonjs/scene" {
  47965. interface Scene {
  47966. /**
  47967. * Creates a default light for the scene.
  47968. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  47969. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  47970. */
  47971. createDefaultLight(replace?: boolean): void;
  47972. /**
  47973. * Creates a default camera for the scene.
  47974. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  47975. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47976. * @param replace has default false, when true replaces the active camera in the scene
  47977. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  47978. */
  47979. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47980. /**
  47981. * Creates a default camera and a default light.
  47982. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  47983. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  47984. * @param replace has the default false, when true replaces the active camera/light in the scene
  47985. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  47986. */
  47987. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  47988. /**
  47989. * Creates a new sky box
  47990. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  47991. * @param environmentTexture defines the texture to use as environment texture
  47992. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  47993. * @param scale defines the overall scale of the skybox
  47994. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  47995. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  47996. * @returns a new mesh holding the sky box
  47997. */
  47998. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  47999. /**
  48000. * Creates a new environment
  48001. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  48002. * @param options defines the options you can use to configure the environment
  48003. * @returns the new EnvironmentHelper
  48004. */
  48005. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  48006. /**
  48007. * Creates a new VREXperienceHelper
  48008. * @see http://doc.babylonjs.com/how_to/webvr_helper
  48009. * @param webVROptions defines the options used to create the new VREXperienceHelper
  48010. * @returns a new VREXperienceHelper
  48011. */
  48012. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  48013. /**
  48014. * Creates a new XREXperienceHelper
  48015. * @see http://doc.babylonjs.com/how_to/webxr
  48016. * @returns a promise for a new XREXperienceHelper
  48017. */
  48018. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  48019. }
  48020. }
  48021. }
  48022. declare module "babylonjs/Helpers/videoDome" {
  48023. import { Scene } from "babylonjs/scene";
  48024. import { TransformNode } from "babylonjs/Meshes/transformNode";
  48025. import { Mesh } from "babylonjs/Meshes/mesh";
  48026. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  48027. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  48028. import "babylonjs/Meshes/Builders/sphereBuilder";
  48029. /**
  48030. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  48031. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  48032. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  48033. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  48034. */
  48035. export class VideoDome extends TransformNode {
  48036. /**
  48037. * Define the video source as a Monoscopic panoramic 360 video.
  48038. */
  48039. static readonly MODE_MONOSCOPIC: number;
  48040. /**
  48041. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48042. */
  48043. static readonly MODE_TOPBOTTOM: number;
  48044. /**
  48045. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48046. */
  48047. static readonly MODE_SIDEBYSIDE: number;
  48048. private _useDirectMapping;
  48049. /**
  48050. * The video texture being displayed on the sphere
  48051. */
  48052. protected _videoTexture: VideoTexture;
  48053. /**
  48054. * Gets the video texture being displayed on the sphere
  48055. */
  48056. readonly videoTexture: VideoTexture;
  48057. /**
  48058. * The skybox material
  48059. */
  48060. protected _material: BackgroundMaterial;
  48061. /**
  48062. * The surface used for the skybox
  48063. */
  48064. protected _mesh: Mesh;
  48065. /**
  48066. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  48067. * Also see the options.resolution property.
  48068. */
  48069. fovMultiplier: number;
  48070. private _videoMode;
  48071. /**
  48072. * Gets or set the current video mode for the video. It can be:
  48073. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  48074. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  48075. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  48076. */
  48077. videoMode: number;
  48078. /**
  48079. * Oberserver used in Stereoscopic VR Mode.
  48080. */
  48081. private _onBeforeCameraRenderObserver;
  48082. /**
  48083. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  48084. * @param name Element's name, child elements will append suffixes for their own names.
  48085. * @param urlsOrVideo defines the url(s) or the video element to use
  48086. * @param options An object containing optional or exposed sub element properties
  48087. */
  48088. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  48089. resolution?: number;
  48090. clickToPlay?: boolean;
  48091. autoPlay?: boolean;
  48092. loop?: boolean;
  48093. size?: number;
  48094. poster?: string;
  48095. faceForward?: boolean;
  48096. useDirectMapping?: boolean;
  48097. }, scene: Scene);
  48098. private _changeVideoMode;
  48099. /**
  48100. * Releases resources associated with this node.
  48101. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  48102. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  48103. */
  48104. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  48105. }
  48106. }
  48107. declare module "babylonjs/Helpers/index" {
  48108. export * from "babylonjs/Helpers/environmentHelper";
  48109. export * from "babylonjs/Helpers/photoDome";
  48110. export * from "babylonjs/Helpers/sceneHelpers";
  48111. export * from "babylonjs/Helpers/videoDome";
  48112. }
  48113. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  48114. import { PerfCounter } from "babylonjs/Misc/tools";
  48115. import { IDisposable } from "babylonjs/scene";
  48116. import { Engine } from "babylonjs/Engines/engine";
  48117. /**
  48118. * This class can be used to get instrumentation data from a Babylon engine
  48119. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48120. */
  48121. export class EngineInstrumentation implements IDisposable {
  48122. /**
  48123. * Define the instrumented engine.
  48124. */
  48125. engine: Engine;
  48126. private _captureGPUFrameTime;
  48127. private _gpuFrameTimeToken;
  48128. private _gpuFrameTime;
  48129. private _captureShaderCompilationTime;
  48130. private _shaderCompilationTime;
  48131. private _onBeginFrameObserver;
  48132. private _onEndFrameObserver;
  48133. private _onBeforeShaderCompilationObserver;
  48134. private _onAfterShaderCompilationObserver;
  48135. /**
  48136. * Gets the perf counter used for GPU frame time
  48137. */
  48138. readonly gpuFrameTimeCounter: PerfCounter;
  48139. /**
  48140. * Gets the GPU frame time capture status
  48141. */
  48142. /**
  48143. * Enable or disable the GPU frame time capture
  48144. */
  48145. captureGPUFrameTime: boolean;
  48146. /**
  48147. * Gets the perf counter used for shader compilation time
  48148. */
  48149. readonly shaderCompilationTimeCounter: PerfCounter;
  48150. /**
  48151. * Gets the shader compilation time capture status
  48152. */
  48153. /**
  48154. * Enable or disable the shader compilation time capture
  48155. */
  48156. captureShaderCompilationTime: boolean;
  48157. /**
  48158. * Instantiates a new engine instrumentation.
  48159. * This class can be used to get instrumentation data from a Babylon engine
  48160. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  48161. * @param engine Defines the engine to instrument
  48162. */
  48163. constructor(
  48164. /**
  48165. * Define the instrumented engine.
  48166. */
  48167. engine: Engine);
  48168. /**
  48169. * Dispose and release associated resources.
  48170. */
  48171. dispose(): void;
  48172. }
  48173. }
  48174. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  48175. import { PerfCounter } from "babylonjs/Misc/tools";
  48176. import { Scene, IDisposable } from "babylonjs/scene";
  48177. /**
  48178. * This class can be used to get instrumentation data from a Babylon engine
  48179. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48180. */
  48181. export class SceneInstrumentation implements IDisposable {
  48182. /**
  48183. * Defines the scene to instrument
  48184. */
  48185. scene: Scene;
  48186. private _captureActiveMeshesEvaluationTime;
  48187. private _activeMeshesEvaluationTime;
  48188. private _captureRenderTargetsRenderTime;
  48189. private _renderTargetsRenderTime;
  48190. private _captureFrameTime;
  48191. private _frameTime;
  48192. private _captureRenderTime;
  48193. private _renderTime;
  48194. private _captureInterFrameTime;
  48195. private _interFrameTime;
  48196. private _captureParticlesRenderTime;
  48197. private _particlesRenderTime;
  48198. private _captureSpritesRenderTime;
  48199. private _spritesRenderTime;
  48200. private _capturePhysicsTime;
  48201. private _physicsTime;
  48202. private _captureAnimationsTime;
  48203. private _animationsTime;
  48204. private _captureCameraRenderTime;
  48205. private _cameraRenderTime;
  48206. private _onBeforeActiveMeshesEvaluationObserver;
  48207. private _onAfterActiveMeshesEvaluationObserver;
  48208. private _onBeforeRenderTargetsRenderObserver;
  48209. private _onAfterRenderTargetsRenderObserver;
  48210. private _onAfterRenderObserver;
  48211. private _onBeforeDrawPhaseObserver;
  48212. private _onAfterDrawPhaseObserver;
  48213. private _onBeforeAnimationsObserver;
  48214. private _onBeforeParticlesRenderingObserver;
  48215. private _onAfterParticlesRenderingObserver;
  48216. private _onBeforeSpritesRenderingObserver;
  48217. private _onAfterSpritesRenderingObserver;
  48218. private _onBeforePhysicsObserver;
  48219. private _onAfterPhysicsObserver;
  48220. private _onAfterAnimationsObserver;
  48221. private _onBeforeCameraRenderObserver;
  48222. private _onAfterCameraRenderObserver;
  48223. /**
  48224. * Gets the perf counter used for active meshes evaluation time
  48225. */
  48226. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  48227. /**
  48228. * Gets the active meshes evaluation time capture status
  48229. */
  48230. /**
  48231. * Enable or disable the active meshes evaluation time capture
  48232. */
  48233. captureActiveMeshesEvaluationTime: boolean;
  48234. /**
  48235. * Gets the perf counter used for render targets render time
  48236. */
  48237. readonly renderTargetsRenderTimeCounter: PerfCounter;
  48238. /**
  48239. * Gets the render targets render time capture status
  48240. */
  48241. /**
  48242. * Enable or disable the render targets render time capture
  48243. */
  48244. captureRenderTargetsRenderTime: boolean;
  48245. /**
  48246. * Gets the perf counter used for particles render time
  48247. */
  48248. readonly particlesRenderTimeCounter: PerfCounter;
  48249. /**
  48250. * Gets the particles render time capture status
  48251. */
  48252. /**
  48253. * Enable or disable the particles render time capture
  48254. */
  48255. captureParticlesRenderTime: boolean;
  48256. /**
  48257. * Gets the perf counter used for sprites render time
  48258. */
  48259. readonly spritesRenderTimeCounter: PerfCounter;
  48260. /**
  48261. * Gets the sprites render time capture status
  48262. */
  48263. /**
  48264. * Enable or disable the sprites render time capture
  48265. */
  48266. captureSpritesRenderTime: boolean;
  48267. /**
  48268. * Gets the perf counter used for physics time
  48269. */
  48270. readonly physicsTimeCounter: PerfCounter;
  48271. /**
  48272. * Gets the physics time capture status
  48273. */
  48274. /**
  48275. * Enable or disable the physics time capture
  48276. */
  48277. capturePhysicsTime: boolean;
  48278. /**
  48279. * Gets the perf counter used for animations time
  48280. */
  48281. readonly animationsTimeCounter: PerfCounter;
  48282. /**
  48283. * Gets the animations time capture status
  48284. */
  48285. /**
  48286. * Enable or disable the animations time capture
  48287. */
  48288. captureAnimationsTime: boolean;
  48289. /**
  48290. * Gets the perf counter used for frame time capture
  48291. */
  48292. readonly frameTimeCounter: PerfCounter;
  48293. /**
  48294. * Gets the frame time capture status
  48295. */
  48296. /**
  48297. * Enable or disable the frame time capture
  48298. */
  48299. captureFrameTime: boolean;
  48300. /**
  48301. * Gets the perf counter used for inter-frames time capture
  48302. */
  48303. readonly interFrameTimeCounter: PerfCounter;
  48304. /**
  48305. * Gets the inter-frames time capture status
  48306. */
  48307. /**
  48308. * Enable or disable the inter-frames time capture
  48309. */
  48310. captureInterFrameTime: boolean;
  48311. /**
  48312. * Gets the perf counter used for render time capture
  48313. */
  48314. readonly renderTimeCounter: PerfCounter;
  48315. /**
  48316. * Gets the render time capture status
  48317. */
  48318. /**
  48319. * Enable or disable the render time capture
  48320. */
  48321. captureRenderTime: boolean;
  48322. /**
  48323. * Gets the perf counter used for camera render time capture
  48324. */
  48325. readonly cameraRenderTimeCounter: PerfCounter;
  48326. /**
  48327. * Gets the camera render time capture status
  48328. */
  48329. /**
  48330. * Enable or disable the camera render time capture
  48331. */
  48332. captureCameraRenderTime: boolean;
  48333. /**
  48334. * Gets the perf counter used for draw calls
  48335. */
  48336. readonly drawCallsCounter: PerfCounter;
  48337. /**
  48338. * Instantiates a new scene instrumentation.
  48339. * This class can be used to get instrumentation data from a Babylon engine
  48340. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  48341. * @param scene Defines the scene to instrument
  48342. */
  48343. constructor(
  48344. /**
  48345. * Defines the scene to instrument
  48346. */
  48347. scene: Scene);
  48348. /**
  48349. * Dispose and release associated resources.
  48350. */
  48351. dispose(): void;
  48352. }
  48353. }
  48354. declare module "babylonjs/Instrumentation/index" {
  48355. export * from "babylonjs/Instrumentation/engineInstrumentation";
  48356. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  48357. export * from "babylonjs/Instrumentation/timeToken";
  48358. }
  48359. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  48360. /** @hidden */
  48361. export var glowMapGenerationPixelShader: {
  48362. name: string;
  48363. shader: string;
  48364. };
  48365. }
  48366. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  48367. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  48368. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  48369. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  48370. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  48371. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  48372. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  48373. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  48374. /** @hidden */
  48375. export var glowMapGenerationVertexShader: {
  48376. name: string;
  48377. shader: string;
  48378. };
  48379. }
  48380. declare module "babylonjs/Layers/effectLayer" {
  48381. import { Observable } from "babylonjs/Misc/observable";
  48382. import { Nullable } from "babylonjs/types";
  48383. import { Camera } from "babylonjs/Cameras/camera";
  48384. import { Scene } from "babylonjs/scene";
  48385. import { Color4, ISize } from "babylonjs/Maths/math";
  48386. import { Engine } from "babylonjs/Engines/engine";
  48387. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48388. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48389. import { Mesh } from "babylonjs/Meshes/mesh";
  48390. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48391. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  48392. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48393. import { Effect } from "babylonjs/Materials/effect";
  48394. import { Material } from "babylonjs/Materials/material";
  48395. import "babylonjs/Shaders/glowMapGeneration.fragment";
  48396. import "babylonjs/Shaders/glowMapGeneration.vertex";
  48397. /**
  48398. * Effect layer options. This helps customizing the behaviour
  48399. * of the effect layer.
  48400. */
  48401. export interface IEffectLayerOptions {
  48402. /**
  48403. * Multiplication factor apply to the canvas size to compute the render target size
  48404. * used to generated the objects (the smaller the faster).
  48405. */
  48406. mainTextureRatio: number;
  48407. /**
  48408. * Enforces a fixed size texture to ensure effect stability across devices.
  48409. */
  48410. mainTextureFixedSize?: number;
  48411. /**
  48412. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  48413. */
  48414. alphaBlendingMode: number;
  48415. /**
  48416. * The camera attached to the layer.
  48417. */
  48418. camera: Nullable<Camera>;
  48419. /**
  48420. * The rendering group to draw the layer in.
  48421. */
  48422. renderingGroupId: number;
  48423. }
  48424. /**
  48425. * The effect layer Helps adding post process effect blended with the main pass.
  48426. *
  48427. * This can be for instance use to generate glow or higlight effects on the scene.
  48428. *
  48429. * The effect layer class can not be used directly and is intented to inherited from to be
  48430. * customized per effects.
  48431. */
  48432. export abstract class EffectLayer {
  48433. private _vertexBuffers;
  48434. private _indexBuffer;
  48435. private _cachedDefines;
  48436. private _effectLayerMapGenerationEffect;
  48437. private _effectLayerOptions;
  48438. private _mergeEffect;
  48439. protected _scene: Scene;
  48440. protected _engine: Engine;
  48441. protected _maxSize: number;
  48442. protected _mainTextureDesiredSize: ISize;
  48443. protected _mainTexture: RenderTargetTexture;
  48444. protected _shouldRender: boolean;
  48445. protected _postProcesses: PostProcess[];
  48446. protected _textures: BaseTexture[];
  48447. protected _emissiveTextureAndColor: {
  48448. texture: Nullable<BaseTexture>;
  48449. color: Color4;
  48450. };
  48451. /**
  48452. * The name of the layer
  48453. */
  48454. name: string;
  48455. /**
  48456. * The clear color of the texture used to generate the glow map.
  48457. */
  48458. neutralColor: Color4;
  48459. /**
  48460. * Specifies wether the highlight layer is enabled or not.
  48461. */
  48462. isEnabled: boolean;
  48463. /**
  48464. * Gets the camera attached to the layer.
  48465. */
  48466. readonly camera: Nullable<Camera>;
  48467. /**
  48468. * Gets the rendering group id the layer should render in.
  48469. */
  48470. readonly renderingGroupId: number;
  48471. /**
  48472. * An event triggered when the effect layer has been disposed.
  48473. */
  48474. onDisposeObservable: Observable<EffectLayer>;
  48475. /**
  48476. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  48477. */
  48478. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  48479. /**
  48480. * An event triggered when the generated texture is being merged in the scene.
  48481. */
  48482. onBeforeComposeObservable: Observable<EffectLayer>;
  48483. /**
  48484. * An event triggered when the generated texture has been merged in the scene.
  48485. */
  48486. onAfterComposeObservable: Observable<EffectLayer>;
  48487. /**
  48488. * An event triggered when the efffect layer changes its size.
  48489. */
  48490. onSizeChangedObservable: Observable<EffectLayer>;
  48491. /** @hidden */
  48492. static _SceneComponentInitialization: (scene: Scene) => void;
  48493. /**
  48494. * Instantiates a new effect Layer and references it in the scene.
  48495. * @param name The name of the layer
  48496. * @param scene The scene to use the layer in
  48497. */
  48498. constructor(
  48499. /** The Friendly of the effect in the scene */
  48500. name: string, scene: Scene);
  48501. /**
  48502. * Get the effect name of the layer.
  48503. * @return The effect name
  48504. */
  48505. abstract getEffectName(): string;
  48506. /**
  48507. * Checks for the readiness of the element composing the layer.
  48508. * @param subMesh the mesh to check for
  48509. * @param useInstances specify wether or not to use instances to render the mesh
  48510. * @return true if ready otherwise, false
  48511. */
  48512. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48513. /**
  48514. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48515. * @returns true if the effect requires stencil during the main canvas render pass.
  48516. */
  48517. abstract needStencil(): boolean;
  48518. /**
  48519. * Create the merge effect. This is the shader use to blit the information back
  48520. * to the main canvas at the end of the scene rendering.
  48521. * @returns The effect containing the shader used to merge the effect on the main canvas
  48522. */
  48523. protected abstract _createMergeEffect(): Effect;
  48524. /**
  48525. * Creates the render target textures and post processes used in the effect layer.
  48526. */
  48527. protected abstract _createTextureAndPostProcesses(): void;
  48528. /**
  48529. * Implementation specific of rendering the generating effect on the main canvas.
  48530. * @param effect The effect used to render through
  48531. */
  48532. protected abstract _internalRender(effect: Effect): void;
  48533. /**
  48534. * Sets the required values for both the emissive texture and and the main color.
  48535. */
  48536. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48537. /**
  48538. * Free any resources and references associated to a mesh.
  48539. * Internal use
  48540. * @param mesh The mesh to free.
  48541. */
  48542. abstract _disposeMesh(mesh: Mesh): void;
  48543. /**
  48544. * Serializes this layer (Glow or Highlight for example)
  48545. * @returns a serialized layer object
  48546. */
  48547. abstract serialize?(): any;
  48548. /**
  48549. * Initializes the effect layer with the required options.
  48550. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  48551. */
  48552. protected _init(options: Partial<IEffectLayerOptions>): void;
  48553. /**
  48554. * Generates the index buffer of the full screen quad blending to the main canvas.
  48555. */
  48556. private _generateIndexBuffer;
  48557. /**
  48558. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  48559. */
  48560. private _genrateVertexBuffer;
  48561. /**
  48562. * Sets the main texture desired size which is the closest power of two
  48563. * of the engine canvas size.
  48564. */
  48565. private _setMainTextureSize;
  48566. /**
  48567. * Creates the main texture for the effect layer.
  48568. */
  48569. protected _createMainTexture(): void;
  48570. /**
  48571. * Adds specific effects defines.
  48572. * @param defines The defines to add specifics to.
  48573. */
  48574. protected _addCustomEffectDefines(defines: string[]): void;
  48575. /**
  48576. * Checks for the readiness of the element composing the layer.
  48577. * @param subMesh the mesh to check for
  48578. * @param useInstances specify wether or not to use instances to render the mesh
  48579. * @param emissiveTexture the associated emissive texture used to generate the glow
  48580. * @return true if ready otherwise, false
  48581. */
  48582. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  48583. /**
  48584. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  48585. */
  48586. render(): void;
  48587. /**
  48588. * Determine if a given mesh will be used in the current effect.
  48589. * @param mesh mesh to test
  48590. * @returns true if the mesh will be used
  48591. */
  48592. hasMesh(mesh: AbstractMesh): boolean;
  48593. /**
  48594. * Returns true if the layer contains information to display, otherwise false.
  48595. * @returns true if the glow layer should be rendered
  48596. */
  48597. shouldRender(): boolean;
  48598. /**
  48599. * Returns true if the mesh should render, otherwise false.
  48600. * @param mesh The mesh to render
  48601. * @returns true if it should render otherwise false
  48602. */
  48603. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  48604. /**
  48605. * Returns true if the mesh can be rendered, otherwise false.
  48606. * @param mesh The mesh to render
  48607. * @param material The material used on the mesh
  48608. * @returns true if it can be rendered otherwise false
  48609. */
  48610. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48611. /**
  48612. * Returns true if the mesh should render, otherwise false.
  48613. * @param mesh The mesh to render
  48614. * @returns true if it should render otherwise false
  48615. */
  48616. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  48617. /**
  48618. * Renders the submesh passed in parameter to the generation map.
  48619. */
  48620. protected _renderSubMesh(subMesh: SubMesh): void;
  48621. /**
  48622. * Rebuild the required buffers.
  48623. * @hidden Internal use only.
  48624. */
  48625. _rebuild(): void;
  48626. /**
  48627. * Dispose only the render target textures and post process.
  48628. */
  48629. private _disposeTextureAndPostProcesses;
  48630. /**
  48631. * Dispose the highlight layer and free resources.
  48632. */
  48633. dispose(): void;
  48634. /**
  48635. * Gets the class name of the effect layer
  48636. * @returns the string with the class name of the effect layer
  48637. */
  48638. getClassName(): string;
  48639. /**
  48640. * Creates an effect layer from parsed effect layer data
  48641. * @param parsedEffectLayer defines effect layer data
  48642. * @param scene defines the current scene
  48643. * @param rootUrl defines the root URL containing the effect layer information
  48644. * @returns a parsed effect Layer
  48645. */
  48646. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  48647. }
  48648. }
  48649. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  48650. import { Scene } from "babylonjs/scene";
  48651. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  48652. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48653. import { AbstractScene } from "babylonjs/abstractScene";
  48654. module "babylonjs/abstractScene" {
  48655. interface AbstractScene {
  48656. /**
  48657. * The list of effect layers (highlights/glow) added to the scene
  48658. * @see http://doc.babylonjs.com/how_to/highlight_layer
  48659. * @see http://doc.babylonjs.com/how_to/glow_layer
  48660. */
  48661. effectLayers: Array<EffectLayer>;
  48662. /**
  48663. * Removes the given effect layer from this scene.
  48664. * @param toRemove defines the effect layer to remove
  48665. * @returns the index of the removed effect layer
  48666. */
  48667. removeEffectLayer(toRemove: EffectLayer): number;
  48668. /**
  48669. * Adds the given effect layer to this scene
  48670. * @param newEffectLayer defines the effect layer to add
  48671. */
  48672. addEffectLayer(newEffectLayer: EffectLayer): void;
  48673. }
  48674. }
  48675. /**
  48676. * Defines the layer scene component responsible to manage any effect layers
  48677. * in a given scene.
  48678. */
  48679. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  48680. /**
  48681. * The component name helpfull to identify the component in the list of scene components.
  48682. */
  48683. readonly name: string;
  48684. /**
  48685. * The scene the component belongs to.
  48686. */
  48687. scene: Scene;
  48688. private _engine;
  48689. private _renderEffects;
  48690. private _needStencil;
  48691. private _previousStencilState;
  48692. /**
  48693. * Creates a new instance of the component for the given scene
  48694. * @param scene Defines the scene to register the component in
  48695. */
  48696. constructor(scene: Scene);
  48697. /**
  48698. * Registers the component in a given scene
  48699. */
  48700. register(): void;
  48701. /**
  48702. * Rebuilds the elements related to this component in case of
  48703. * context lost for instance.
  48704. */
  48705. rebuild(): void;
  48706. /**
  48707. * Serializes the component data to the specified json object
  48708. * @param serializationObject The object to serialize to
  48709. */
  48710. serialize(serializationObject: any): void;
  48711. /**
  48712. * Adds all the element from the container to the scene
  48713. * @param container the container holding the elements
  48714. */
  48715. addFromContainer(container: AbstractScene): void;
  48716. /**
  48717. * Removes all the elements in the container from the scene
  48718. * @param container contains the elements to remove
  48719. * @param dispose if the removed element should be disposed (default: false)
  48720. */
  48721. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  48722. /**
  48723. * Disposes the component and the associated ressources.
  48724. */
  48725. dispose(): void;
  48726. private _isReadyForMesh;
  48727. private _renderMainTexture;
  48728. private _setStencil;
  48729. private _setStencilBack;
  48730. private _draw;
  48731. private _drawCamera;
  48732. private _drawRenderingGroup;
  48733. }
  48734. }
  48735. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  48736. /** @hidden */
  48737. export var glowMapMergePixelShader: {
  48738. name: string;
  48739. shader: string;
  48740. };
  48741. }
  48742. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  48743. /** @hidden */
  48744. export var glowMapMergeVertexShader: {
  48745. name: string;
  48746. shader: string;
  48747. };
  48748. }
  48749. declare module "babylonjs/Layers/glowLayer" {
  48750. import { Nullable } from "babylonjs/types";
  48751. import { Camera } from "babylonjs/Cameras/camera";
  48752. import { Scene } from "babylonjs/scene";
  48753. import { Color4 } from "babylonjs/Maths/math";
  48754. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48755. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48756. import { Mesh } from "babylonjs/Meshes/mesh";
  48757. import { Texture } from "babylonjs/Materials/Textures/texture";
  48758. import { Effect } from "babylonjs/Materials/effect";
  48759. import { Material } from "babylonjs/Materials/material";
  48760. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48761. import "babylonjs/Shaders/glowMapMerge.fragment";
  48762. import "babylonjs/Shaders/glowMapMerge.vertex";
  48763. import "babylonjs/Layers/effectLayerSceneComponent";
  48764. module "babylonjs/abstractScene" {
  48765. interface AbstractScene {
  48766. /**
  48767. * Return a the first highlight layer of the scene with a given name.
  48768. * @param name The name of the highlight layer to look for.
  48769. * @return The highlight layer if found otherwise null.
  48770. */
  48771. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  48772. }
  48773. }
  48774. /**
  48775. * Glow layer options. This helps customizing the behaviour
  48776. * of the glow layer.
  48777. */
  48778. export interface IGlowLayerOptions {
  48779. /**
  48780. * Multiplication factor apply to the canvas size to compute the render target size
  48781. * used to generated the glowing objects (the smaller the faster).
  48782. */
  48783. mainTextureRatio: number;
  48784. /**
  48785. * Enforces a fixed size texture to ensure resize independant blur.
  48786. */
  48787. mainTextureFixedSize?: number;
  48788. /**
  48789. * How big is the kernel of the blur texture.
  48790. */
  48791. blurKernelSize: number;
  48792. /**
  48793. * The camera attached to the layer.
  48794. */
  48795. camera: Nullable<Camera>;
  48796. /**
  48797. * Enable MSAA by chosing the number of samples.
  48798. */
  48799. mainTextureSamples?: number;
  48800. /**
  48801. * The rendering group to draw the layer in.
  48802. */
  48803. renderingGroupId: number;
  48804. }
  48805. /**
  48806. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  48807. *
  48808. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  48809. * glowy meshes to your scene.
  48810. *
  48811. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  48812. */
  48813. export class GlowLayer extends EffectLayer {
  48814. /**
  48815. * Effect Name of the layer.
  48816. */
  48817. static readonly EffectName: string;
  48818. /**
  48819. * The default blur kernel size used for the glow.
  48820. */
  48821. static DefaultBlurKernelSize: number;
  48822. /**
  48823. * The default texture size ratio used for the glow.
  48824. */
  48825. static DefaultTextureRatio: number;
  48826. /**
  48827. * Sets the kernel size of the blur.
  48828. */
  48829. /**
  48830. * Gets the kernel size of the blur.
  48831. */
  48832. blurKernelSize: number;
  48833. /**
  48834. * Sets the glow intensity.
  48835. */
  48836. /**
  48837. * Gets the glow intensity.
  48838. */
  48839. intensity: number;
  48840. private _options;
  48841. private _intensity;
  48842. private _horizontalBlurPostprocess1;
  48843. private _verticalBlurPostprocess1;
  48844. private _horizontalBlurPostprocess2;
  48845. private _verticalBlurPostprocess2;
  48846. private _blurTexture1;
  48847. private _blurTexture2;
  48848. private _postProcesses1;
  48849. private _postProcesses2;
  48850. private _includedOnlyMeshes;
  48851. private _excludedMeshes;
  48852. /**
  48853. * Callback used to let the user override the color selection on a per mesh basis
  48854. */
  48855. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  48856. /**
  48857. * Callback used to let the user override the texture selection on a per mesh basis
  48858. */
  48859. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  48860. /**
  48861. * Instantiates a new glow Layer and references it to the scene.
  48862. * @param name The name of the layer
  48863. * @param scene The scene to use the layer in
  48864. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  48865. */
  48866. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  48867. /**
  48868. * Get the effect name of the layer.
  48869. * @return The effect name
  48870. */
  48871. getEffectName(): string;
  48872. /**
  48873. * Create the merge effect. This is the shader use to blit the information back
  48874. * to the main canvas at the end of the scene rendering.
  48875. */
  48876. protected _createMergeEffect(): Effect;
  48877. /**
  48878. * Creates the render target textures and post processes used in the glow layer.
  48879. */
  48880. protected _createTextureAndPostProcesses(): void;
  48881. /**
  48882. * Checks for the readiness of the element composing the layer.
  48883. * @param subMesh the mesh to check for
  48884. * @param useInstances specify wether or not to use instances to render the mesh
  48885. * @param emissiveTexture the associated emissive texture used to generate the glow
  48886. * @return true if ready otherwise, false
  48887. */
  48888. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  48889. /**
  48890. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  48891. */
  48892. needStencil(): boolean;
  48893. /**
  48894. * Returns true if the mesh can be rendered, otherwise false.
  48895. * @param mesh The mesh to render
  48896. * @param material The material used on the mesh
  48897. * @returns true if it can be rendered otherwise false
  48898. */
  48899. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  48900. /**
  48901. * Implementation specific of rendering the generating effect on the main canvas.
  48902. * @param effect The effect used to render through
  48903. */
  48904. protected _internalRender(effect: Effect): void;
  48905. /**
  48906. * Sets the required values for both the emissive texture and and the main color.
  48907. */
  48908. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  48909. /**
  48910. * Returns true if the mesh should render, otherwise false.
  48911. * @param mesh The mesh to render
  48912. * @returns true if it should render otherwise false
  48913. */
  48914. protected _shouldRenderMesh(mesh: Mesh): boolean;
  48915. /**
  48916. * Adds specific effects defines.
  48917. * @param defines The defines to add specifics to.
  48918. */
  48919. protected _addCustomEffectDefines(defines: string[]): void;
  48920. /**
  48921. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  48922. * @param mesh The mesh to exclude from the glow layer
  48923. */
  48924. addExcludedMesh(mesh: Mesh): void;
  48925. /**
  48926. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  48927. * @param mesh The mesh to remove
  48928. */
  48929. removeExcludedMesh(mesh: Mesh): void;
  48930. /**
  48931. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  48932. * @param mesh The mesh to include in the glow layer
  48933. */
  48934. addIncludedOnlyMesh(mesh: Mesh): void;
  48935. /**
  48936. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  48937. * @param mesh The mesh to remove
  48938. */
  48939. removeIncludedOnlyMesh(mesh: Mesh): void;
  48940. /**
  48941. * Determine if a given mesh will be used in the glow layer
  48942. * @param mesh The mesh to test
  48943. * @returns true if the mesh will be highlighted by the current glow layer
  48944. */
  48945. hasMesh(mesh: AbstractMesh): boolean;
  48946. /**
  48947. * Free any resources and references associated to a mesh.
  48948. * Internal use
  48949. * @param mesh The mesh to free.
  48950. * @hidden
  48951. */
  48952. _disposeMesh(mesh: Mesh): void;
  48953. /**
  48954. * Gets the class name of the effect layer
  48955. * @returns the string with the class name of the effect layer
  48956. */
  48957. getClassName(): string;
  48958. /**
  48959. * Serializes this glow layer
  48960. * @returns a serialized glow layer object
  48961. */
  48962. serialize(): any;
  48963. /**
  48964. * Creates a Glow Layer from parsed glow layer data
  48965. * @param parsedGlowLayer defines glow layer data
  48966. * @param scene defines the current scene
  48967. * @param rootUrl defines the root URL containing the glow layer information
  48968. * @returns a parsed Glow Layer
  48969. */
  48970. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  48971. }
  48972. }
  48973. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  48974. /** @hidden */
  48975. export var glowBlurPostProcessPixelShader: {
  48976. name: string;
  48977. shader: string;
  48978. };
  48979. }
  48980. declare module "babylonjs/Layers/highlightLayer" {
  48981. import { Observable } from "babylonjs/Misc/observable";
  48982. import { Nullable } from "babylonjs/types";
  48983. import { Camera } from "babylonjs/Cameras/camera";
  48984. import { Scene } from "babylonjs/scene";
  48985. import { Color3, Color4 } from "babylonjs/Maths/math";
  48986. import { SubMesh } from "babylonjs/Meshes/subMesh";
  48987. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  48988. import { Mesh } from "babylonjs/Meshes/mesh";
  48989. import { Effect } from "babylonjs/Materials/effect";
  48990. import { Material } from "babylonjs/Materials/material";
  48991. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  48992. import "babylonjs/Shaders/glowMapMerge.fragment";
  48993. import "babylonjs/Shaders/glowMapMerge.vertex";
  48994. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  48995. module "babylonjs/abstractScene" {
  48996. interface AbstractScene {
  48997. /**
  48998. * Return a the first highlight layer of the scene with a given name.
  48999. * @param name The name of the highlight layer to look for.
  49000. * @return The highlight layer if found otherwise null.
  49001. */
  49002. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  49003. }
  49004. }
  49005. /**
  49006. * Highlight layer options. This helps customizing the behaviour
  49007. * of the highlight layer.
  49008. */
  49009. export interface IHighlightLayerOptions {
  49010. /**
  49011. * Multiplication factor apply to the canvas size to compute the render target size
  49012. * used to generated the glowing objects (the smaller the faster).
  49013. */
  49014. mainTextureRatio: number;
  49015. /**
  49016. * Enforces a fixed size texture to ensure resize independant blur.
  49017. */
  49018. mainTextureFixedSize?: number;
  49019. /**
  49020. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  49021. * of the picture to blur (the smaller the faster).
  49022. */
  49023. blurTextureSizeRatio: number;
  49024. /**
  49025. * How big in texel of the blur texture is the vertical blur.
  49026. */
  49027. blurVerticalSize: number;
  49028. /**
  49029. * How big in texel of the blur texture is the horizontal blur.
  49030. */
  49031. blurHorizontalSize: number;
  49032. /**
  49033. * Alpha blending mode used to apply the blur. Default is combine.
  49034. */
  49035. alphaBlendingMode: number;
  49036. /**
  49037. * The camera attached to the layer.
  49038. */
  49039. camera: Nullable<Camera>;
  49040. /**
  49041. * Should we display highlight as a solid stroke?
  49042. */
  49043. isStroke?: boolean;
  49044. /**
  49045. * The rendering group to draw the layer in.
  49046. */
  49047. renderingGroupId: number;
  49048. }
  49049. /**
  49050. * The highlight layer Helps adding a glow effect around a mesh.
  49051. *
  49052. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  49053. * glowy meshes to your scene.
  49054. *
  49055. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  49056. */
  49057. export class HighlightLayer extends EffectLayer {
  49058. name: string;
  49059. /**
  49060. * Effect Name of the highlight layer.
  49061. */
  49062. static readonly EffectName: string;
  49063. /**
  49064. * The neutral color used during the preparation of the glow effect.
  49065. * This is black by default as the blend operation is a blend operation.
  49066. */
  49067. static NeutralColor: Color4;
  49068. /**
  49069. * Stencil value used for glowing meshes.
  49070. */
  49071. static GlowingMeshStencilReference: number;
  49072. /**
  49073. * Stencil value used for the other meshes in the scene.
  49074. */
  49075. static NormalMeshStencilReference: number;
  49076. /**
  49077. * Specifies whether or not the inner glow is ACTIVE in the layer.
  49078. */
  49079. innerGlow: boolean;
  49080. /**
  49081. * Specifies whether or not the outer glow is ACTIVE in the layer.
  49082. */
  49083. outerGlow: boolean;
  49084. /**
  49085. * Specifies the horizontal size of the blur.
  49086. */
  49087. /**
  49088. * Gets the horizontal size of the blur.
  49089. */
  49090. blurHorizontalSize: number;
  49091. /**
  49092. * Specifies the vertical size of the blur.
  49093. */
  49094. /**
  49095. * Gets the vertical size of the blur.
  49096. */
  49097. blurVerticalSize: number;
  49098. /**
  49099. * An event triggered when the highlight layer is being blurred.
  49100. */
  49101. onBeforeBlurObservable: Observable<HighlightLayer>;
  49102. /**
  49103. * An event triggered when the highlight layer has been blurred.
  49104. */
  49105. onAfterBlurObservable: Observable<HighlightLayer>;
  49106. private _instanceGlowingMeshStencilReference;
  49107. private _options;
  49108. private _downSamplePostprocess;
  49109. private _horizontalBlurPostprocess;
  49110. private _verticalBlurPostprocess;
  49111. private _blurTexture;
  49112. private _meshes;
  49113. private _excludedMeshes;
  49114. /**
  49115. * Instantiates a new highlight Layer and references it to the scene..
  49116. * @param name The name of the layer
  49117. * @param scene The scene to use the layer in
  49118. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  49119. */
  49120. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  49121. /**
  49122. * Get the effect name of the layer.
  49123. * @return The effect name
  49124. */
  49125. getEffectName(): string;
  49126. /**
  49127. * Create the merge effect. This is the shader use to blit the information back
  49128. * to the main canvas at the end of the scene rendering.
  49129. */
  49130. protected _createMergeEffect(): Effect;
  49131. /**
  49132. * Creates the render target textures and post processes used in the highlight layer.
  49133. */
  49134. protected _createTextureAndPostProcesses(): void;
  49135. /**
  49136. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  49137. */
  49138. needStencil(): boolean;
  49139. /**
  49140. * Checks for the readiness of the element composing the layer.
  49141. * @param subMesh the mesh to check for
  49142. * @param useInstances specify wether or not to use instances to render the mesh
  49143. * @param emissiveTexture the associated emissive texture used to generate the glow
  49144. * @return true if ready otherwise, false
  49145. */
  49146. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  49147. /**
  49148. * Implementation specific of rendering the generating effect on the main canvas.
  49149. * @param effect The effect used to render through
  49150. */
  49151. protected _internalRender(effect: Effect): void;
  49152. /**
  49153. * Returns true if the layer contains information to display, otherwise false.
  49154. */
  49155. shouldRender(): boolean;
  49156. /**
  49157. * Returns true if the mesh should render, otherwise false.
  49158. * @param mesh The mesh to render
  49159. * @returns true if it should render otherwise false
  49160. */
  49161. protected _shouldRenderMesh(mesh: Mesh): boolean;
  49162. /**
  49163. * Sets the required values for both the emissive texture and and the main color.
  49164. */
  49165. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  49166. /**
  49167. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  49168. * @param mesh The mesh to exclude from the highlight layer
  49169. */
  49170. addExcludedMesh(mesh: Mesh): void;
  49171. /**
  49172. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  49173. * @param mesh The mesh to highlight
  49174. */
  49175. removeExcludedMesh(mesh: Mesh): void;
  49176. /**
  49177. * Determine if a given mesh will be highlighted by the current HighlightLayer
  49178. * @param mesh mesh to test
  49179. * @returns true if the mesh will be highlighted by the current HighlightLayer
  49180. */
  49181. hasMesh(mesh: AbstractMesh): boolean;
  49182. /**
  49183. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  49184. * @param mesh The mesh to highlight
  49185. * @param color The color of the highlight
  49186. * @param glowEmissiveOnly Extract the glow from the emissive texture
  49187. */
  49188. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  49189. /**
  49190. * Remove a mesh from the highlight layer in order to make it stop glowing.
  49191. * @param mesh The mesh to highlight
  49192. */
  49193. removeMesh(mesh: Mesh): void;
  49194. /**
  49195. * Force the stencil to the normal expected value for none glowing parts
  49196. */
  49197. private _defaultStencilReference;
  49198. /**
  49199. * Free any resources and references associated to a mesh.
  49200. * Internal use
  49201. * @param mesh The mesh to free.
  49202. * @hidden
  49203. */
  49204. _disposeMesh(mesh: Mesh): void;
  49205. /**
  49206. * Dispose the highlight layer and free resources.
  49207. */
  49208. dispose(): void;
  49209. /**
  49210. * Gets the class name of the effect layer
  49211. * @returns the string with the class name of the effect layer
  49212. */
  49213. getClassName(): string;
  49214. /**
  49215. * Serializes this Highlight layer
  49216. * @returns a serialized Highlight layer object
  49217. */
  49218. serialize(): any;
  49219. /**
  49220. * Creates a Highlight layer from parsed Highlight layer data
  49221. * @param parsedHightlightLayer defines the Highlight layer data
  49222. * @param scene defines the current scene
  49223. * @param rootUrl defines the root URL containing the Highlight layer information
  49224. * @returns a parsed Highlight layer
  49225. */
  49226. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  49227. }
  49228. }
  49229. declare module "babylonjs/Layers/index" {
  49230. export * from "babylonjs/Layers/effectLayer";
  49231. export * from "babylonjs/Layers/effectLayerSceneComponent";
  49232. export * from "babylonjs/Layers/glowLayer";
  49233. export * from "babylonjs/Layers/highlightLayer";
  49234. export * from "babylonjs/Layers/layer";
  49235. export * from "babylonjs/Layers/layerSceneComponent";
  49236. }
  49237. declare module "babylonjs/Shaders/lensFlare.fragment" {
  49238. /** @hidden */
  49239. export var lensFlarePixelShader: {
  49240. name: string;
  49241. shader: string;
  49242. };
  49243. }
  49244. declare module "babylonjs/Shaders/lensFlare.vertex" {
  49245. /** @hidden */
  49246. export var lensFlareVertexShader: {
  49247. name: string;
  49248. shader: string;
  49249. };
  49250. }
  49251. declare module "babylonjs/LensFlares/lensFlareSystem" {
  49252. import { Scene } from "babylonjs/scene";
  49253. import { Vector3, Viewport } from "babylonjs/Maths/math";
  49254. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49255. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  49256. import "babylonjs/Shaders/lensFlare.fragment";
  49257. import "babylonjs/Shaders/lensFlare.vertex";
  49258. /**
  49259. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49260. * It is usually composed of several `lensFlare`.
  49261. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49262. */
  49263. export class LensFlareSystem {
  49264. /**
  49265. * Define the name of the lens flare system
  49266. */
  49267. name: string;
  49268. /**
  49269. * List of lens flares used in this system.
  49270. */
  49271. lensFlares: LensFlare[];
  49272. /**
  49273. * Define a limit from the border the lens flare can be visible.
  49274. */
  49275. borderLimit: number;
  49276. /**
  49277. * Define a viewport border we do not want to see the lens flare in.
  49278. */
  49279. viewportBorder: number;
  49280. /**
  49281. * Define a predicate which could limit the list of meshes able to occlude the effect.
  49282. */
  49283. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  49284. /**
  49285. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  49286. */
  49287. layerMask: number;
  49288. /**
  49289. * Define the id of the lens flare system in the scene.
  49290. * (equal to name by default)
  49291. */
  49292. id: string;
  49293. private _scene;
  49294. private _emitter;
  49295. private _vertexBuffers;
  49296. private _indexBuffer;
  49297. private _effect;
  49298. private _positionX;
  49299. private _positionY;
  49300. private _isEnabled;
  49301. /** @hidden */
  49302. static _SceneComponentInitialization: (scene: Scene) => void;
  49303. /**
  49304. * Instantiates a lens flare system.
  49305. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  49306. * It is usually composed of several `lensFlare`.
  49307. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49308. * @param name Define the name of the lens flare system in the scene
  49309. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  49310. * @param scene Define the scene the lens flare system belongs to
  49311. */
  49312. constructor(
  49313. /**
  49314. * Define the name of the lens flare system
  49315. */
  49316. name: string, emitter: any, scene: Scene);
  49317. /**
  49318. * Define if the lens flare system is enabled.
  49319. */
  49320. isEnabled: boolean;
  49321. /**
  49322. * Get the scene the effects belongs to.
  49323. * @returns the scene holding the lens flare system
  49324. */
  49325. getScene(): Scene;
  49326. /**
  49327. * Get the emitter of the lens flare system.
  49328. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49329. * @returns the emitter of the lens flare system
  49330. */
  49331. getEmitter(): any;
  49332. /**
  49333. * Set the emitter of the lens flare system.
  49334. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  49335. * @param newEmitter Define the new emitter of the system
  49336. */
  49337. setEmitter(newEmitter: any): void;
  49338. /**
  49339. * Get the lens flare system emitter position.
  49340. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  49341. * @returns the position
  49342. */
  49343. getEmitterPosition(): Vector3;
  49344. /**
  49345. * @hidden
  49346. */
  49347. computeEffectivePosition(globalViewport: Viewport): boolean;
  49348. /** @hidden */
  49349. _isVisible(): boolean;
  49350. /**
  49351. * @hidden
  49352. */
  49353. render(): boolean;
  49354. /**
  49355. * Dispose and release the lens flare with its associated resources.
  49356. */
  49357. dispose(): void;
  49358. /**
  49359. * Parse a lens flare system from a JSON repressentation
  49360. * @param parsedLensFlareSystem Define the JSON to parse
  49361. * @param scene Define the scene the parsed system should be instantiated in
  49362. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  49363. * @returns the parsed system
  49364. */
  49365. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  49366. /**
  49367. * Serialize the current Lens Flare System into a JSON representation.
  49368. * @returns the serialized JSON
  49369. */
  49370. serialize(): any;
  49371. }
  49372. }
  49373. declare module "babylonjs/LensFlares/lensFlare" {
  49374. import { Nullable } from "babylonjs/types";
  49375. import { Color3 } from "babylonjs/Maths/math";
  49376. import { Texture } from "babylonjs/Materials/Textures/texture";
  49377. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49378. /**
  49379. * This represents one of the lens effect in a `lensFlareSystem`.
  49380. * It controls one of the indiviual texture used in the effect.
  49381. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49382. */
  49383. export class LensFlare {
  49384. /**
  49385. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49386. */
  49387. size: number;
  49388. /**
  49389. * 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.
  49390. */
  49391. position: number;
  49392. /**
  49393. * Define the lens color.
  49394. */
  49395. color: Color3;
  49396. /**
  49397. * Define the lens texture.
  49398. */
  49399. texture: Nullable<Texture>;
  49400. /**
  49401. * Define the alpha mode to render this particular lens.
  49402. */
  49403. alphaMode: number;
  49404. private _system;
  49405. /**
  49406. * Creates a new Lens Flare.
  49407. * This represents one of the lens effect in a `lensFlareSystem`.
  49408. * It controls one of the indiviual texture used in the effect.
  49409. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49410. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  49411. * @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.
  49412. * @param color Define the lens color
  49413. * @param imgUrl Define the lens texture url
  49414. * @param system Define the `lensFlareSystem` this flare is part of
  49415. * @returns The newly created Lens Flare
  49416. */
  49417. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  49418. /**
  49419. * Instantiates a new Lens Flare.
  49420. * This represents one of the lens effect in a `lensFlareSystem`.
  49421. * It controls one of the indiviual texture used in the effect.
  49422. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49423. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  49424. * @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.
  49425. * @param color Define the lens color
  49426. * @param imgUrl Define the lens texture url
  49427. * @param system Define the `lensFlareSystem` this flare is part of
  49428. */
  49429. constructor(
  49430. /**
  49431. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  49432. */
  49433. size: number,
  49434. /**
  49435. * 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.
  49436. */
  49437. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  49438. /**
  49439. * Dispose and release the lens flare with its associated resources.
  49440. */
  49441. dispose(): void;
  49442. }
  49443. }
  49444. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  49445. import { Nullable } from "babylonjs/types";
  49446. import { Scene } from "babylonjs/scene";
  49447. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49448. import { AbstractScene } from "babylonjs/abstractScene";
  49449. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  49450. module "babylonjs/abstractScene" {
  49451. interface AbstractScene {
  49452. /**
  49453. * The list of lens flare system added to the scene
  49454. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  49455. */
  49456. lensFlareSystems: Array<LensFlareSystem>;
  49457. /**
  49458. * Removes the given lens flare system from this scene.
  49459. * @param toRemove The lens flare system to remove
  49460. * @returns The index of the removed lens flare system
  49461. */
  49462. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  49463. /**
  49464. * Adds the given lens flare system to this scene
  49465. * @param newLensFlareSystem The lens flare system to add
  49466. */
  49467. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  49468. /**
  49469. * Gets a lens flare system using its name
  49470. * @param name defines the name to look for
  49471. * @returns the lens flare system or null if not found
  49472. */
  49473. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  49474. /**
  49475. * Gets a lens flare system using its id
  49476. * @param id defines the id to look for
  49477. * @returns the lens flare system or null if not found
  49478. */
  49479. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  49480. }
  49481. }
  49482. /**
  49483. * Defines the lens flare scene component responsible to manage any lens flares
  49484. * in a given scene.
  49485. */
  49486. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  49487. /**
  49488. * The component name helpfull to identify the component in the list of scene components.
  49489. */
  49490. readonly name: string;
  49491. /**
  49492. * The scene the component belongs to.
  49493. */
  49494. scene: Scene;
  49495. /**
  49496. * Creates a new instance of the component for the given scene
  49497. * @param scene Defines the scene to register the component in
  49498. */
  49499. constructor(scene: Scene);
  49500. /**
  49501. * Registers the component in a given scene
  49502. */
  49503. register(): void;
  49504. /**
  49505. * Rebuilds the elements related to this component in case of
  49506. * context lost for instance.
  49507. */
  49508. rebuild(): void;
  49509. /**
  49510. * Adds all the element from the container to the scene
  49511. * @param container the container holding the elements
  49512. */
  49513. addFromContainer(container: AbstractScene): void;
  49514. /**
  49515. * Removes all the elements in the container from the scene
  49516. * @param container contains the elements to remove
  49517. * @param dispose if the removed element should be disposed (default: false)
  49518. */
  49519. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49520. /**
  49521. * Serializes the component data to the specified json object
  49522. * @param serializationObject The object to serialize to
  49523. */
  49524. serialize(serializationObject: any): void;
  49525. /**
  49526. * Disposes the component and the associated ressources.
  49527. */
  49528. dispose(): void;
  49529. private _draw;
  49530. }
  49531. }
  49532. declare module "babylonjs/LensFlares/index" {
  49533. export * from "babylonjs/LensFlares/lensFlare";
  49534. export * from "babylonjs/LensFlares/lensFlareSystem";
  49535. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  49536. }
  49537. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  49538. import { Scene } from "babylonjs/scene";
  49539. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  49540. import { AbstractScene } from "babylonjs/abstractScene";
  49541. /**
  49542. * Defines the shadow generator component responsible to manage any shadow generators
  49543. * in a given scene.
  49544. */
  49545. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  49546. /**
  49547. * The component name helpfull to identify the component in the list of scene components.
  49548. */
  49549. readonly name: string;
  49550. /**
  49551. * The scene the component belongs to.
  49552. */
  49553. scene: Scene;
  49554. /**
  49555. * Creates a new instance of the component for the given scene
  49556. * @param scene Defines the scene to register the component in
  49557. */
  49558. constructor(scene: Scene);
  49559. /**
  49560. * Registers the component in a given scene
  49561. */
  49562. register(): void;
  49563. /**
  49564. * Rebuilds the elements related to this component in case of
  49565. * context lost for instance.
  49566. */
  49567. rebuild(): void;
  49568. /**
  49569. * Serializes the component data to the specified json object
  49570. * @param serializationObject The object to serialize to
  49571. */
  49572. serialize(serializationObject: any): void;
  49573. /**
  49574. * Adds all the element from the container to the scene
  49575. * @param container the container holding the elements
  49576. */
  49577. addFromContainer(container: AbstractScene): void;
  49578. /**
  49579. * Removes all the elements in the container from the scene
  49580. * @param container contains the elements to remove
  49581. * @param dispose if the removed element should be disposed (default: false)
  49582. */
  49583. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  49584. /**
  49585. * Rebuilds the elements related to this component in case of
  49586. * context lost for instance.
  49587. */
  49588. dispose(): void;
  49589. private _gatherRenderTargets;
  49590. }
  49591. }
  49592. declare module "babylonjs/Lights/Shadows/index" {
  49593. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  49594. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  49595. }
  49596. declare module "babylonjs/Lights/pointLight" {
  49597. import { Scene } from "babylonjs/scene";
  49598. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49600. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  49601. import { Effect } from "babylonjs/Materials/effect";
  49602. /**
  49603. * A point light is a light defined by an unique point in world space.
  49604. * The light is emitted in every direction from this point.
  49605. * A good example of a point light is a standard light bulb.
  49606. * Documentation: https://doc.babylonjs.com/babylon101/lights
  49607. */
  49608. export class PointLight extends ShadowLight {
  49609. private _shadowAngle;
  49610. /**
  49611. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49612. * This specifies what angle the shadow will use to be created.
  49613. *
  49614. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49615. */
  49616. /**
  49617. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49618. * This specifies what angle the shadow will use to be created.
  49619. *
  49620. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  49621. */
  49622. shadowAngle: number;
  49623. /**
  49624. * Gets the direction if it has been set.
  49625. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49626. */
  49627. /**
  49628. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  49629. */
  49630. direction: Vector3;
  49631. /**
  49632. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  49633. * A PointLight emits the light in every direction.
  49634. * It can cast shadows.
  49635. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  49636. * ```javascript
  49637. * var pointLight = new PointLight("pl", camera.position, scene);
  49638. * ```
  49639. * Documentation : https://doc.babylonjs.com/babylon101/lights
  49640. * @param name The light friendly name
  49641. * @param position The position of the point light in the scene
  49642. * @param scene The scene the lights belongs to
  49643. */
  49644. constructor(name: string, position: Vector3, scene: Scene);
  49645. /**
  49646. * Returns the string "PointLight"
  49647. * @returns the class name
  49648. */
  49649. getClassName(): string;
  49650. /**
  49651. * Returns the integer 0.
  49652. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  49653. */
  49654. getTypeID(): number;
  49655. /**
  49656. * Specifies wether or not the shadowmap should be a cube texture.
  49657. * @returns true if the shadowmap needs to be a cube texture.
  49658. */
  49659. needCube(): boolean;
  49660. /**
  49661. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  49662. * @param faceIndex The index of the face we are computed the direction to generate shadow
  49663. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  49664. */
  49665. getShadowDirection(faceIndex?: number): Vector3;
  49666. /**
  49667. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  49668. * - fov = PI / 2
  49669. * - aspect ratio : 1.0
  49670. * - z-near and far equal to the active camera minZ and maxZ.
  49671. * Returns the PointLight.
  49672. */
  49673. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  49674. protected _buildUniformLayout(): void;
  49675. /**
  49676. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  49677. * @param effect The effect to update
  49678. * @param lightIndex The index of the light in the effect to update
  49679. * @returns The point light
  49680. */
  49681. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  49682. /**
  49683. * Prepares the list of defines specific to the light type.
  49684. * @param defines the list of defines
  49685. * @param lightIndex defines the index of the light for the effect
  49686. */
  49687. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  49688. }
  49689. }
  49690. declare module "babylonjs/Lights/index" {
  49691. export * from "babylonjs/Lights/light";
  49692. export * from "babylonjs/Lights/shadowLight";
  49693. export * from "babylonjs/Lights/Shadows/index";
  49694. export * from "babylonjs/Lights/directionalLight";
  49695. export * from "babylonjs/Lights/hemisphericLight";
  49696. export * from "babylonjs/Lights/pointLight";
  49697. export * from "babylonjs/Lights/spotLight";
  49698. }
  49699. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  49700. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  49701. /**
  49702. * Header information of HDR texture files.
  49703. */
  49704. export interface HDRInfo {
  49705. /**
  49706. * The height of the texture in pixels.
  49707. */
  49708. height: number;
  49709. /**
  49710. * The width of the texture in pixels.
  49711. */
  49712. width: number;
  49713. /**
  49714. * The index of the beginning of the data in the binary file.
  49715. */
  49716. dataPosition: number;
  49717. }
  49718. /**
  49719. * This groups tools to convert HDR texture to native colors array.
  49720. */
  49721. export class HDRTools {
  49722. private static Ldexp;
  49723. private static Rgbe2float;
  49724. private static readStringLine;
  49725. /**
  49726. * Reads header information from an RGBE texture stored in a native array.
  49727. * More information on this format are available here:
  49728. * https://en.wikipedia.org/wiki/RGBE_image_format
  49729. *
  49730. * @param uint8array The binary file stored in native array.
  49731. * @return The header information.
  49732. */
  49733. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  49734. /**
  49735. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  49736. * This RGBE texture needs to store the information as a panorama.
  49737. *
  49738. * More information on this format are available here:
  49739. * https://en.wikipedia.org/wiki/RGBE_image_format
  49740. *
  49741. * @param buffer The binary file stored in an array buffer.
  49742. * @param size The expected size of the extracted cubemap.
  49743. * @return The Cube Map information.
  49744. */
  49745. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  49746. /**
  49747. * Returns the pixels data extracted from an RGBE texture.
  49748. * This pixels will be stored left to right up to down in the R G B order in one array.
  49749. *
  49750. * More information on this format are available here:
  49751. * https://en.wikipedia.org/wiki/RGBE_image_format
  49752. *
  49753. * @param uint8array The binary file stored in an array buffer.
  49754. * @param hdrInfo The header information of the file.
  49755. * @return The pixels data in RGB right to left up to down order.
  49756. */
  49757. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  49758. private static RGBE_ReadPixels_RLE;
  49759. }
  49760. }
  49761. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  49762. import { Nullable } from "babylonjs/types";
  49763. import { Scene } from "babylonjs/scene";
  49764. import { Matrix, Vector3 } from "babylonjs/Maths/math";
  49765. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  49766. import "babylonjs/Engines/Extensions/engine.rawTexture";
  49767. /**
  49768. * This represents a texture coming from an HDR input.
  49769. *
  49770. * The only supported format is currently panorama picture stored in RGBE format.
  49771. * Example of such files can be found on HDRLib: http://hdrlib.com/
  49772. */
  49773. export class HDRCubeTexture extends BaseTexture {
  49774. private static _facesMapping;
  49775. private _generateHarmonics;
  49776. private _noMipmap;
  49777. private _textureMatrix;
  49778. private _size;
  49779. private _onLoad;
  49780. private _onError;
  49781. /**
  49782. * The texture URL.
  49783. */
  49784. url: string;
  49785. /**
  49786. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  49787. */
  49788. coordinatesMode: number;
  49789. protected _isBlocking: boolean;
  49790. /**
  49791. * Sets wether or not the texture is blocking during loading.
  49792. */
  49793. /**
  49794. * Gets wether or not the texture is blocking during loading.
  49795. */
  49796. isBlocking: boolean;
  49797. protected _rotationY: number;
  49798. /**
  49799. * Sets texture matrix rotation angle around Y axis in radians.
  49800. */
  49801. /**
  49802. * Gets texture matrix rotation angle around Y axis radians.
  49803. */
  49804. rotationY: number;
  49805. /**
  49806. * Gets or sets the center of the bounding box associated with the cube texture
  49807. * It must define where the camera used to render the texture was set
  49808. */
  49809. boundingBoxPosition: Vector3;
  49810. private _boundingBoxSize;
  49811. /**
  49812. * Gets or sets the size of the bounding box associated with the cube texture
  49813. * When defined, the cubemap will switch to local mode
  49814. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  49815. * @example https://www.babylonjs-playground.com/#RNASML
  49816. */
  49817. boundingBoxSize: Vector3;
  49818. /**
  49819. * Instantiates an HDRTexture from the following parameters.
  49820. *
  49821. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  49822. * @param scene The scene the texture will be used in
  49823. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  49824. * @param noMipmap Forces to not generate the mipmap if true
  49825. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  49826. * @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)
  49827. * @param reserved Reserved flag for internal use.
  49828. */
  49829. 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>);
  49830. /**
  49831. * Get the current class name of the texture useful for serialization or dynamic coding.
  49832. * @returns "HDRCubeTexture"
  49833. */
  49834. getClassName(): string;
  49835. /**
  49836. * Occurs when the file is raw .hdr file.
  49837. */
  49838. private loadTexture;
  49839. clone(): HDRCubeTexture;
  49840. delayLoad(): void;
  49841. /**
  49842. * Get the texture reflection matrix used to rotate/transform the reflection.
  49843. * @returns the reflection matrix
  49844. */
  49845. getReflectionTextureMatrix(): Matrix;
  49846. /**
  49847. * Set the texture reflection matrix used to rotate/transform the reflection.
  49848. * @param value Define the reflection matrix to set
  49849. */
  49850. setReflectionTextureMatrix(value: Matrix): void;
  49851. /**
  49852. * Parses a JSON representation of an HDR Texture in order to create the texture
  49853. * @param parsedTexture Define the JSON representation
  49854. * @param scene Define the scene the texture should be created in
  49855. * @param rootUrl Define the root url in case we need to load relative dependencies
  49856. * @returns the newly created texture after parsing
  49857. */
  49858. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  49859. serialize(): any;
  49860. }
  49861. }
  49862. declare module "babylonjs/Physics/physicsEngine" {
  49863. import { Nullable } from "babylonjs/types";
  49864. import { Vector3 } from "babylonjs/Maths/math";
  49865. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  49866. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  49867. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  49868. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49869. /**
  49870. * Class used to control physics engine
  49871. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  49872. */
  49873. export class PhysicsEngine implements IPhysicsEngine {
  49874. private _physicsPlugin;
  49875. /**
  49876. * Global value used to control the smallest number supported by the simulation
  49877. */
  49878. static Epsilon: number;
  49879. private _impostors;
  49880. private _joints;
  49881. /**
  49882. * Gets the gravity vector used by the simulation
  49883. */
  49884. gravity: Vector3;
  49885. /**
  49886. * Factory used to create the default physics plugin.
  49887. * @returns The default physics plugin
  49888. */
  49889. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  49890. /**
  49891. * Creates a new Physics Engine
  49892. * @param gravity defines the gravity vector used by the simulation
  49893. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  49894. */
  49895. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  49896. /**
  49897. * Sets the gravity vector used by the simulation
  49898. * @param gravity defines the gravity vector to use
  49899. */
  49900. setGravity(gravity: Vector3): void;
  49901. /**
  49902. * Set the time step of the physics engine.
  49903. * Default is 1/60.
  49904. * To slow it down, enter 1/600 for example.
  49905. * To speed it up, 1/30
  49906. * @param newTimeStep defines the new timestep to apply to this world.
  49907. */
  49908. setTimeStep(newTimeStep?: number): void;
  49909. /**
  49910. * Get the time step of the physics engine.
  49911. * @returns the current time step
  49912. */
  49913. getTimeStep(): number;
  49914. /**
  49915. * Release all resources
  49916. */
  49917. dispose(): void;
  49918. /**
  49919. * Gets the name of the current physics plugin
  49920. * @returns the name of the plugin
  49921. */
  49922. getPhysicsPluginName(): string;
  49923. /**
  49924. * Adding a new impostor for the impostor tracking.
  49925. * This will be done by the impostor itself.
  49926. * @param impostor the impostor to add
  49927. */
  49928. addImpostor(impostor: PhysicsImpostor): void;
  49929. /**
  49930. * Remove an impostor from the engine.
  49931. * This impostor and its mesh will not longer be updated by the physics engine.
  49932. * @param impostor the impostor to remove
  49933. */
  49934. removeImpostor(impostor: PhysicsImpostor): void;
  49935. /**
  49936. * Add a joint to the physics engine
  49937. * @param mainImpostor defines the main impostor to which the joint is added.
  49938. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  49939. * @param joint defines the joint that will connect both impostors.
  49940. */
  49941. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49942. /**
  49943. * Removes a joint from the simulation
  49944. * @param mainImpostor defines the impostor used with the joint
  49945. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  49946. * @param joint defines the joint to remove
  49947. */
  49948. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  49949. /**
  49950. * Called by the scene. No need to call it.
  49951. * @param delta defines the timespam between frames
  49952. */
  49953. _step(delta: number): void;
  49954. /**
  49955. * Gets the current plugin used to run the simulation
  49956. * @returns current plugin
  49957. */
  49958. getPhysicsPlugin(): IPhysicsEnginePlugin;
  49959. /**
  49960. * Gets the list of physic impostors
  49961. * @returns an array of PhysicsImpostor
  49962. */
  49963. getImpostors(): Array<PhysicsImpostor>;
  49964. /**
  49965. * Gets the impostor for a physics enabled object
  49966. * @param object defines the object impersonated by the impostor
  49967. * @returns the PhysicsImpostor or null if not found
  49968. */
  49969. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  49970. /**
  49971. * Gets the impostor for a physics body object
  49972. * @param body defines physics body used by the impostor
  49973. * @returns the PhysicsImpostor or null if not found
  49974. */
  49975. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  49976. /**
  49977. * Does a raycast in the physics world
  49978. * @param from when should the ray start?
  49979. * @param to when should the ray end?
  49980. * @returns PhysicsRaycastResult
  49981. */
  49982. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  49983. }
  49984. }
  49985. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  49986. import { Nullable } from "babylonjs/types";
  49987. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  49988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49989. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  49990. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  49991. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  49992. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  49993. /** @hidden */
  49994. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  49995. private _useDeltaForWorldStep;
  49996. world: any;
  49997. name: string;
  49998. private _physicsMaterials;
  49999. private _fixedTimeStep;
  50000. private _cannonRaycastResult;
  50001. private _raycastResult;
  50002. private _removeAfterStep;
  50003. BJSCANNON: any;
  50004. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  50005. setGravity(gravity: Vector3): void;
  50006. setTimeStep(timeStep: number): void;
  50007. getTimeStep(): number;
  50008. executeStep(delta: number): void;
  50009. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50010. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50011. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50012. private _processChildMeshes;
  50013. removePhysicsBody(impostor: PhysicsImpostor): void;
  50014. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50015. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50016. private _addMaterial;
  50017. private _checkWithEpsilon;
  50018. private _createShape;
  50019. private _createHeightmap;
  50020. private _minus90X;
  50021. private _plus90X;
  50022. private _tmpPosition;
  50023. private _tmpDeltaPosition;
  50024. private _tmpUnityRotation;
  50025. private _updatePhysicsBodyTransformation;
  50026. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50027. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50028. isSupported(): boolean;
  50029. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50030. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50031. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50032. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50033. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50034. getBodyMass(impostor: PhysicsImpostor): number;
  50035. getBodyFriction(impostor: PhysicsImpostor): number;
  50036. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50037. getBodyRestitution(impostor: PhysicsImpostor): number;
  50038. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50039. sleepBody(impostor: PhysicsImpostor): void;
  50040. wakeUpBody(impostor: PhysicsImpostor): void;
  50041. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  50042. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50043. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50044. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50045. getRadius(impostor: PhysicsImpostor): number;
  50046. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50047. dispose(): void;
  50048. private _extendNamespace;
  50049. /**
  50050. * Does a raycast in the physics world
  50051. * @param from when should the ray start?
  50052. * @param to when should the ray end?
  50053. * @returns PhysicsRaycastResult
  50054. */
  50055. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50056. }
  50057. }
  50058. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  50059. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50060. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50061. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50062. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50063. import { Vector3, Quaternion } from "babylonjs/Maths/math";
  50064. import { Nullable } from "babylonjs/types";
  50065. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50066. /** @hidden */
  50067. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  50068. world: any;
  50069. name: string;
  50070. BJSOIMO: any;
  50071. private _raycastResult;
  50072. constructor(iterations?: number, oimoInjection?: any);
  50073. setGravity(gravity: Vector3): void;
  50074. setTimeStep(timeStep: number): void;
  50075. getTimeStep(): number;
  50076. private _tmpImpostorsArray;
  50077. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50078. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50079. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50080. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50081. private _tmpPositionVector;
  50082. removePhysicsBody(impostor: PhysicsImpostor): void;
  50083. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50084. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50085. isSupported(): boolean;
  50086. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50087. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50088. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50089. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50090. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50091. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50092. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50093. getBodyMass(impostor: PhysicsImpostor): number;
  50094. getBodyFriction(impostor: PhysicsImpostor): number;
  50095. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50096. getBodyRestitution(impostor: PhysicsImpostor): number;
  50097. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50098. sleepBody(impostor: PhysicsImpostor): void;
  50099. wakeUpBody(impostor: PhysicsImpostor): void;
  50100. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50101. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  50102. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  50103. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50104. getRadius(impostor: PhysicsImpostor): number;
  50105. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50106. dispose(): void;
  50107. /**
  50108. * Does a raycast in the physics world
  50109. * @param from when should the ray start?
  50110. * @param to when should the ray end?
  50111. * @returns PhysicsRaycastResult
  50112. */
  50113. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50114. }
  50115. }
  50116. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  50117. import { Nullable } from "babylonjs/types";
  50118. import { Scene } from "babylonjs/scene";
  50119. import { Vector3, Vector2, Color4, Vector4 } from "babylonjs/Maths/math";
  50120. import { Mesh } from "babylonjs/Meshes/mesh";
  50121. /**
  50122. * Class containing static functions to help procedurally build meshes
  50123. */
  50124. export class RibbonBuilder {
  50125. /**
  50126. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  50127. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  50128. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  50129. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  50130. * * 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
  50131. * * 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
  50132. * * 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
  50133. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50134. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50135. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50136. * * 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
  50137. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  50138. * * 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
  50139. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  50140. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50141. * @param name defines the name of the mesh
  50142. * @param options defines the options used to create the mesh
  50143. * @param scene defines the hosting scene
  50144. * @returns the ribbon mesh
  50145. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  50146. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50147. */
  50148. static CreateRibbon(name: string, options: {
  50149. pathArray: Vector3[][];
  50150. closeArray?: boolean;
  50151. closePath?: boolean;
  50152. offset?: number;
  50153. updatable?: boolean;
  50154. sideOrientation?: number;
  50155. frontUVs?: Vector4;
  50156. backUVs?: Vector4;
  50157. instance?: Mesh;
  50158. invertUV?: boolean;
  50159. uvs?: Vector2[];
  50160. colors?: Color4[];
  50161. }, scene?: Nullable<Scene>): Mesh;
  50162. }
  50163. }
  50164. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  50165. import { Nullable } from "babylonjs/types";
  50166. import { Scene } from "babylonjs/scene";
  50167. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  50168. import { Mesh } from "babylonjs/Meshes/mesh";
  50169. /**
  50170. * Class containing static functions to help procedurally build meshes
  50171. */
  50172. export class ShapeBuilder {
  50173. /**
  50174. * 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.
  50175. * * 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.
  50176. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50177. * * 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.
  50178. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  50179. * * 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
  50180. * * 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
  50181. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  50182. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50183. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50184. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  50185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  50186. * @param name defines the name of the mesh
  50187. * @param options defines the options used to create the mesh
  50188. * @param scene defines the hosting scene
  50189. * @returns the extruded shape mesh
  50190. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50191. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50192. */
  50193. static ExtrudeShape(name: string, options: {
  50194. shape: Vector3[];
  50195. path: Vector3[];
  50196. scale?: number;
  50197. rotation?: number;
  50198. cap?: number;
  50199. updatable?: boolean;
  50200. sideOrientation?: number;
  50201. frontUVs?: Vector4;
  50202. backUVs?: Vector4;
  50203. instance?: Mesh;
  50204. invertUV?: boolean;
  50205. }, scene?: Nullable<Scene>): Mesh;
  50206. /**
  50207. * Creates an custom extruded shape mesh.
  50208. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  50209. * * 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.
  50210. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  50211. * * 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
  50212. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  50213. * * 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
  50214. * * It must returns a float value that will be the scale value applied to the shape on each path point
  50215. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  50216. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  50217. * * 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
  50218. * * 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
  50219. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  50220. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50221. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50222. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  50223. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50224. * @param name defines the name of the mesh
  50225. * @param options defines the options used to create the mesh
  50226. * @param scene defines the hosting scene
  50227. * @returns the custom extruded shape mesh
  50228. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  50229. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  50230. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  50231. */
  50232. static ExtrudeShapeCustom(name: string, options: {
  50233. shape: Vector3[];
  50234. path: Vector3[];
  50235. scaleFunction?: any;
  50236. rotationFunction?: any;
  50237. ribbonCloseArray?: boolean;
  50238. ribbonClosePath?: boolean;
  50239. cap?: number;
  50240. updatable?: boolean;
  50241. sideOrientation?: number;
  50242. frontUVs?: Vector4;
  50243. backUVs?: Vector4;
  50244. instance?: Mesh;
  50245. invertUV?: boolean;
  50246. }, scene?: Nullable<Scene>): Mesh;
  50247. private static _ExtrudeShapeGeneric;
  50248. }
  50249. }
  50250. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  50251. import { Quaternion, Vector3 } from "babylonjs/Maths/math";
  50252. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  50253. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  50254. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  50255. import { Nullable } from "babylonjs/types";
  50256. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50257. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  50258. /**
  50259. * AmmoJS Physics plugin
  50260. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  50261. * @see https://github.com/kripken/ammo.js/
  50262. */
  50263. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  50264. private _useDeltaForWorldStep;
  50265. /**
  50266. * Reference to the Ammo library
  50267. */
  50268. bjsAMMO: any;
  50269. /**
  50270. * Created ammoJS world which physics bodies are added to
  50271. */
  50272. world: any;
  50273. /**
  50274. * Name of the plugin
  50275. */
  50276. name: string;
  50277. private _timeStep;
  50278. private _fixedTimeStep;
  50279. private _maxSteps;
  50280. private _tmpQuaternion;
  50281. private _tmpAmmoTransform;
  50282. private _tmpAmmoQuaternion;
  50283. private _tmpAmmoConcreteContactResultCallback;
  50284. private _collisionConfiguration;
  50285. private _dispatcher;
  50286. private _overlappingPairCache;
  50287. private _solver;
  50288. private _softBodySolver;
  50289. private _tmpAmmoVectorA;
  50290. private _tmpAmmoVectorB;
  50291. private _tmpAmmoVectorC;
  50292. private _tmpAmmoVectorD;
  50293. private _tmpContactCallbackResult;
  50294. private _tmpAmmoVectorRCA;
  50295. private _tmpAmmoVectorRCB;
  50296. private _raycastResult;
  50297. private static readonly DISABLE_COLLISION_FLAG;
  50298. private static readonly KINEMATIC_FLAG;
  50299. private static readonly DISABLE_DEACTIVATION_FLAG;
  50300. /**
  50301. * Initializes the ammoJS plugin
  50302. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  50303. * @param ammoInjection can be used to inject your own ammo reference
  50304. */
  50305. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  50306. /**
  50307. * Sets the gravity of the physics world (m/(s^2))
  50308. * @param gravity Gravity to set
  50309. */
  50310. setGravity(gravity: Vector3): void;
  50311. /**
  50312. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  50313. * @param timeStep timestep to use in seconds
  50314. */
  50315. setTimeStep(timeStep: number): void;
  50316. /**
  50317. * 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)
  50318. * @param fixedTimeStep fixedTimeStep to use in seconds
  50319. */
  50320. setFixedTimeStep(fixedTimeStep: number): void;
  50321. /**
  50322. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  50323. * @param maxSteps the maximum number of steps by the physics engine per frame
  50324. */
  50325. setMaxSteps(maxSteps: number): void;
  50326. /**
  50327. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  50328. * @returns the current timestep in seconds
  50329. */
  50330. getTimeStep(): number;
  50331. private _isImpostorInContact;
  50332. private _isImpostorPairInContact;
  50333. private _stepSimulation;
  50334. /**
  50335. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  50336. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  50337. * After the step the babylon meshes are set to the position of the physics imposters
  50338. * @param delta amount of time to step forward
  50339. * @param impostors array of imposters to update before/after the step
  50340. */
  50341. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  50342. /**
  50343. * Update babylon mesh to match physics world object
  50344. * @param impostor imposter to match
  50345. */
  50346. private _afterSoftStep;
  50347. /**
  50348. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50349. * @param impostor imposter to match
  50350. */
  50351. private _ropeStep;
  50352. /**
  50353. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  50354. * @param impostor imposter to match
  50355. */
  50356. private _softbodyOrClothStep;
  50357. private _tmpVector;
  50358. private _tmpMatrix;
  50359. /**
  50360. * Applies an impulse on the imposter
  50361. * @param impostor imposter to apply impulse to
  50362. * @param force amount of force to be applied to the imposter
  50363. * @param contactPoint the location to apply the impulse on the imposter
  50364. */
  50365. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50366. /**
  50367. * Applies a force on the imposter
  50368. * @param impostor imposter to apply force
  50369. * @param force amount of force to be applied to the imposter
  50370. * @param contactPoint the location to apply the force on the imposter
  50371. */
  50372. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  50373. /**
  50374. * Creates a physics body using the plugin
  50375. * @param impostor the imposter to create the physics body on
  50376. */
  50377. generatePhysicsBody(impostor: PhysicsImpostor): void;
  50378. /**
  50379. * Removes the physics body from the imposter and disposes of the body's memory
  50380. * @param impostor imposter to remove the physics body from
  50381. */
  50382. removePhysicsBody(impostor: PhysicsImpostor): void;
  50383. /**
  50384. * Generates a joint
  50385. * @param impostorJoint the imposter joint to create the joint with
  50386. */
  50387. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  50388. /**
  50389. * Removes a joint
  50390. * @param impostorJoint the imposter joint to remove the joint from
  50391. */
  50392. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  50393. private _addMeshVerts;
  50394. /**
  50395. * Initialise the soft body vertices to match its object's (mesh) vertices
  50396. * Softbody vertices (nodes) are in world space and to match this
  50397. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  50398. * @param impostor to create the softbody for
  50399. */
  50400. private _softVertexData;
  50401. /**
  50402. * Create an impostor's soft body
  50403. * @param impostor to create the softbody for
  50404. */
  50405. private _createSoftbody;
  50406. /**
  50407. * Create cloth for an impostor
  50408. * @param impostor to create the softbody for
  50409. */
  50410. private _createCloth;
  50411. /**
  50412. * Create rope for an impostor
  50413. * @param impostor to create the softbody for
  50414. */
  50415. private _createRope;
  50416. private _addHullVerts;
  50417. private _createShape;
  50418. /**
  50419. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  50420. * @param impostor imposter containing the physics body and babylon object
  50421. */
  50422. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  50423. /**
  50424. * Sets the babylon object's position/rotation from the physics body's position/rotation
  50425. * @param impostor imposter containing the physics body and babylon object
  50426. * @param newPosition new position
  50427. * @param newRotation new rotation
  50428. */
  50429. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  50430. /**
  50431. * If this plugin is supported
  50432. * @returns true if its supported
  50433. */
  50434. isSupported(): boolean;
  50435. /**
  50436. * Sets the linear velocity of the physics body
  50437. * @param impostor imposter to set the velocity on
  50438. * @param velocity velocity to set
  50439. */
  50440. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50441. /**
  50442. * Sets the angular velocity of the physics body
  50443. * @param impostor imposter to set the velocity on
  50444. * @param velocity velocity to set
  50445. */
  50446. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  50447. /**
  50448. * gets the linear velocity
  50449. * @param impostor imposter to get linear velocity from
  50450. * @returns linear velocity
  50451. */
  50452. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50453. /**
  50454. * gets the angular velocity
  50455. * @param impostor imposter to get angular velocity from
  50456. * @returns angular velocity
  50457. */
  50458. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  50459. /**
  50460. * Sets the mass of physics body
  50461. * @param impostor imposter to set the mass on
  50462. * @param mass mass to set
  50463. */
  50464. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  50465. /**
  50466. * Gets the mass of the physics body
  50467. * @param impostor imposter to get the mass from
  50468. * @returns mass
  50469. */
  50470. getBodyMass(impostor: PhysicsImpostor): number;
  50471. /**
  50472. * Gets friction of the impostor
  50473. * @param impostor impostor to get friction from
  50474. * @returns friction value
  50475. */
  50476. getBodyFriction(impostor: PhysicsImpostor): number;
  50477. /**
  50478. * Sets friction of the impostor
  50479. * @param impostor impostor to set friction on
  50480. * @param friction friction value
  50481. */
  50482. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  50483. /**
  50484. * Gets restitution of the impostor
  50485. * @param impostor impostor to get restitution from
  50486. * @returns restitution value
  50487. */
  50488. getBodyRestitution(impostor: PhysicsImpostor): number;
  50489. /**
  50490. * Sets resitution of the impostor
  50491. * @param impostor impostor to set resitution on
  50492. * @param restitution resitution value
  50493. */
  50494. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  50495. /**
  50496. * Gets pressure inside the impostor
  50497. * @param impostor impostor to get pressure from
  50498. * @returns pressure value
  50499. */
  50500. getBodyPressure(impostor: PhysicsImpostor): number;
  50501. /**
  50502. * Sets pressure inside a soft body impostor
  50503. * Cloth and rope must remain 0 pressure
  50504. * @param impostor impostor to set pressure on
  50505. * @param pressure pressure value
  50506. */
  50507. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  50508. /**
  50509. * Gets stiffness of the impostor
  50510. * @param impostor impostor to get stiffness from
  50511. * @returns pressure value
  50512. */
  50513. getBodyStiffness(impostor: PhysicsImpostor): number;
  50514. /**
  50515. * Sets stiffness of the impostor
  50516. * @param impostor impostor to set stiffness on
  50517. * @param stiffness stiffness value from 0 to 1
  50518. */
  50519. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  50520. /**
  50521. * Gets velocityIterations of the impostor
  50522. * @param impostor impostor to get velocity iterations from
  50523. * @returns velocityIterations value
  50524. */
  50525. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  50526. /**
  50527. * Sets velocityIterations of the impostor
  50528. * @param impostor impostor to set velocity iterations on
  50529. * @param velocityIterations velocityIterations value
  50530. */
  50531. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  50532. /**
  50533. * Gets positionIterations of the impostor
  50534. * @param impostor impostor to get position iterations from
  50535. * @returns positionIterations value
  50536. */
  50537. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  50538. /**
  50539. * Sets positionIterations of the impostor
  50540. * @param impostor impostor to set position on
  50541. * @param positionIterations positionIterations value
  50542. */
  50543. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  50544. /**
  50545. * Append an anchor to a cloth object
  50546. * @param impostor is the cloth impostor to add anchor to
  50547. * @param otherImpostor is the rigid impostor to anchor to
  50548. * @param width ratio across width from 0 to 1
  50549. * @param height ratio up height from 0 to 1
  50550. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  50551. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50552. */
  50553. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50554. /**
  50555. * Append an hook to a rope object
  50556. * @param impostor is the rope impostor to add hook to
  50557. * @param otherImpostor is the rigid impostor to hook to
  50558. * @param length ratio along the rope from 0 to 1
  50559. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  50560. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  50561. */
  50562. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  50563. /**
  50564. * Sleeps the physics body and stops it from being active
  50565. * @param impostor impostor to sleep
  50566. */
  50567. sleepBody(impostor: PhysicsImpostor): void;
  50568. /**
  50569. * Activates the physics body
  50570. * @param impostor impostor to activate
  50571. */
  50572. wakeUpBody(impostor: PhysicsImpostor): void;
  50573. /**
  50574. * Updates the distance parameters of the joint
  50575. * @param joint joint to update
  50576. * @param maxDistance maximum distance of the joint
  50577. * @param minDistance minimum distance of the joint
  50578. */
  50579. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  50580. /**
  50581. * Sets a motor on the joint
  50582. * @param joint joint to set motor on
  50583. * @param speed speed of the motor
  50584. * @param maxForce maximum force of the motor
  50585. * @param motorIndex index of the motor
  50586. */
  50587. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  50588. /**
  50589. * Sets the motors limit
  50590. * @param joint joint to set limit on
  50591. * @param upperLimit upper limit
  50592. * @param lowerLimit lower limit
  50593. */
  50594. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  50595. /**
  50596. * Syncs the position and rotation of a mesh with the impostor
  50597. * @param mesh mesh to sync
  50598. * @param impostor impostor to update the mesh with
  50599. */
  50600. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  50601. /**
  50602. * Gets the radius of the impostor
  50603. * @param impostor impostor to get radius from
  50604. * @returns the radius
  50605. */
  50606. getRadius(impostor: PhysicsImpostor): number;
  50607. /**
  50608. * Gets the box size of the impostor
  50609. * @param impostor impostor to get box size from
  50610. * @param result the resulting box size
  50611. */
  50612. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  50613. /**
  50614. * Disposes of the impostor
  50615. */
  50616. dispose(): void;
  50617. /**
  50618. * Does a raycast in the physics world
  50619. * @param from when should the ray start?
  50620. * @param to when should the ray end?
  50621. * @returns PhysicsRaycastResult
  50622. */
  50623. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  50624. }
  50625. }
  50626. declare module "babylonjs/Probes/reflectionProbe" {
  50627. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  50628. import { Vector3 } from "babylonjs/Maths/math";
  50629. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50630. import { Nullable } from "babylonjs/types";
  50631. import { Scene } from "babylonjs/scene";
  50632. module "babylonjs/abstractScene" {
  50633. interface AbstractScene {
  50634. /**
  50635. * The list of reflection probes added to the scene
  50636. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50637. */
  50638. reflectionProbes: Array<ReflectionProbe>;
  50639. /**
  50640. * Removes the given reflection probe from this scene.
  50641. * @param toRemove The reflection probe to remove
  50642. * @returns The index of the removed reflection probe
  50643. */
  50644. removeReflectionProbe(toRemove: ReflectionProbe): number;
  50645. /**
  50646. * Adds the given reflection probe to this scene.
  50647. * @param newReflectionProbe The reflection probe to add
  50648. */
  50649. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  50650. }
  50651. }
  50652. /**
  50653. * Class used to generate realtime reflection / refraction cube textures
  50654. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  50655. */
  50656. export class ReflectionProbe {
  50657. /** defines the name of the probe */
  50658. name: string;
  50659. private _scene;
  50660. private _renderTargetTexture;
  50661. private _projectionMatrix;
  50662. private _viewMatrix;
  50663. private _target;
  50664. private _add;
  50665. private _attachedMesh;
  50666. private _invertYAxis;
  50667. /** Gets or sets probe position (center of the cube map) */
  50668. position: Vector3;
  50669. /**
  50670. * Creates a new reflection probe
  50671. * @param name defines the name of the probe
  50672. * @param size defines the texture resolution (for each face)
  50673. * @param scene defines the hosting scene
  50674. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  50675. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  50676. */
  50677. constructor(
  50678. /** defines the name of the probe */
  50679. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  50680. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  50681. samples: number;
  50682. /** Gets or sets the refresh rate to use (on every frame by default) */
  50683. refreshRate: number;
  50684. /**
  50685. * Gets the hosting scene
  50686. * @returns a Scene
  50687. */
  50688. getScene(): Scene;
  50689. /** Gets the internal CubeTexture used to render to */
  50690. readonly cubeTexture: RenderTargetTexture;
  50691. /** Gets the list of meshes to render */
  50692. readonly renderList: Nullable<AbstractMesh[]>;
  50693. /**
  50694. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  50695. * @param mesh defines the mesh to attach to
  50696. */
  50697. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  50698. /**
  50699. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  50700. * @param renderingGroupId The rendering group id corresponding to its index
  50701. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  50702. */
  50703. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  50704. /**
  50705. * Clean all associated resources
  50706. */
  50707. dispose(): void;
  50708. /**
  50709. * Converts the reflection probe information to a readable string for debug purpose.
  50710. * @param fullDetails Supports for multiple levels of logging within scene loading
  50711. * @returns the human readable reflection probe info
  50712. */
  50713. toString(fullDetails?: boolean): string;
  50714. /**
  50715. * Get the class name of the relfection probe.
  50716. * @returns "ReflectionProbe"
  50717. */
  50718. getClassName(): string;
  50719. /**
  50720. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  50721. * @returns The JSON representation of the texture
  50722. */
  50723. serialize(): any;
  50724. /**
  50725. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  50726. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  50727. * @param scene Define the scene the parsed reflection probe should be instantiated in
  50728. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  50729. * @returns The parsed reflection probe if successful
  50730. */
  50731. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  50732. }
  50733. }
  50734. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  50735. /** @hidden */
  50736. export var _BabylonLoaderRegistered: boolean;
  50737. }
  50738. declare module "babylonjs/Loading/Plugins/index" {
  50739. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  50740. }
  50741. declare module "babylonjs/Loading/index" {
  50742. export * from "babylonjs/Loading/loadingScreen";
  50743. export * from "babylonjs/Loading/Plugins/index";
  50744. export * from "babylonjs/Loading/sceneLoader";
  50745. export * from "babylonjs/Loading/sceneLoaderFlags";
  50746. }
  50747. declare module "babylonjs/Materials/Background/index" {
  50748. export * from "babylonjs/Materials/Background/backgroundMaterial";
  50749. }
  50750. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  50751. import { Scene } from "babylonjs/scene";
  50752. import { Color3 } from "babylonjs/Maths/math";
  50753. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50754. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50755. /**
  50756. * The Physically based simple base material of BJS.
  50757. *
  50758. * This enables better naming and convention enforcements on top of the pbrMaterial.
  50759. * It is used as the base class for both the specGloss and metalRough conventions.
  50760. */
  50761. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  50762. /**
  50763. * Number of Simultaneous lights allowed on the material.
  50764. */
  50765. maxSimultaneousLights: number;
  50766. /**
  50767. * If sets to true, disables all the lights affecting the material.
  50768. */
  50769. disableLighting: boolean;
  50770. /**
  50771. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  50772. */
  50773. environmentTexture: BaseTexture;
  50774. /**
  50775. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  50776. */
  50777. invertNormalMapX: boolean;
  50778. /**
  50779. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  50780. */
  50781. invertNormalMapY: boolean;
  50782. /**
  50783. * Normal map used in the model.
  50784. */
  50785. normalTexture: BaseTexture;
  50786. /**
  50787. * Emissivie color used to self-illuminate the model.
  50788. */
  50789. emissiveColor: Color3;
  50790. /**
  50791. * Emissivie texture used to self-illuminate the model.
  50792. */
  50793. emissiveTexture: BaseTexture;
  50794. /**
  50795. * Occlusion Channel Strenght.
  50796. */
  50797. occlusionStrength: number;
  50798. /**
  50799. * Occlusion Texture of the material (adding extra occlusion effects).
  50800. */
  50801. occlusionTexture: BaseTexture;
  50802. /**
  50803. * Defines the alpha limits in alpha test mode.
  50804. */
  50805. alphaCutOff: number;
  50806. /**
  50807. * Gets the current double sided mode.
  50808. */
  50809. /**
  50810. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50811. */
  50812. doubleSided: boolean;
  50813. /**
  50814. * Stores the pre-calculated light information of a mesh in a texture.
  50815. */
  50816. lightmapTexture: BaseTexture;
  50817. /**
  50818. * If true, the light map contains occlusion information instead of lighting info.
  50819. */
  50820. useLightmapAsShadowmap: boolean;
  50821. /**
  50822. * Instantiates a new PBRMaterial instance.
  50823. *
  50824. * @param name The material name
  50825. * @param scene The scene the material will be use in.
  50826. */
  50827. constructor(name: string, scene: Scene);
  50828. getClassName(): string;
  50829. }
  50830. }
  50831. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  50832. import { Scene } from "babylonjs/scene";
  50833. import { Color3 } from "babylonjs/Maths/math";
  50834. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50835. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50836. /**
  50837. * The PBR material of BJS following the metal roughness convention.
  50838. *
  50839. * This fits to the PBR convention in the GLTF definition:
  50840. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  50841. */
  50842. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  50843. /**
  50844. * The base color has two different interpretations depending on the value of metalness.
  50845. * When the material is a metal, the base color is the specific measured reflectance value
  50846. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  50847. * of the material.
  50848. */
  50849. baseColor: Color3;
  50850. /**
  50851. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  50852. * well as opacity information in the alpha channel.
  50853. */
  50854. baseTexture: BaseTexture;
  50855. /**
  50856. * Specifies the metallic scalar value of the material.
  50857. * Can also be used to scale the metalness values of the metallic texture.
  50858. */
  50859. metallic: number;
  50860. /**
  50861. * Specifies the roughness scalar value of the material.
  50862. * Can also be used to scale the roughness values of the metallic texture.
  50863. */
  50864. roughness: number;
  50865. /**
  50866. * Texture containing both the metallic value in the B channel and the
  50867. * roughness value in the G channel to keep better precision.
  50868. */
  50869. metallicRoughnessTexture: BaseTexture;
  50870. /**
  50871. * Instantiates a new PBRMetalRoughnessMaterial instance.
  50872. *
  50873. * @param name The material name
  50874. * @param scene The scene the material will be use in.
  50875. */
  50876. constructor(name: string, scene: Scene);
  50877. /**
  50878. * Return the currrent class name of the material.
  50879. */
  50880. getClassName(): string;
  50881. /**
  50882. * Makes a duplicate of the current material.
  50883. * @param name - name to use for the new material.
  50884. */
  50885. clone(name: string): PBRMetallicRoughnessMaterial;
  50886. /**
  50887. * Serialize the material to a parsable JSON object.
  50888. */
  50889. serialize(): any;
  50890. /**
  50891. * Parses a JSON object correponding to the serialize function.
  50892. */
  50893. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  50894. }
  50895. }
  50896. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  50897. import { Scene } from "babylonjs/scene";
  50898. import { Color3 } from "babylonjs/Maths/math";
  50899. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50900. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50901. /**
  50902. * The PBR material of BJS following the specular glossiness convention.
  50903. *
  50904. * This fits to the PBR convention in the GLTF definition:
  50905. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  50906. */
  50907. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  50908. /**
  50909. * Specifies the diffuse color of the material.
  50910. */
  50911. diffuseColor: Color3;
  50912. /**
  50913. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  50914. * channel.
  50915. */
  50916. diffuseTexture: BaseTexture;
  50917. /**
  50918. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  50919. */
  50920. specularColor: Color3;
  50921. /**
  50922. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  50923. */
  50924. glossiness: number;
  50925. /**
  50926. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  50927. */
  50928. specularGlossinessTexture: BaseTexture;
  50929. /**
  50930. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  50931. *
  50932. * @param name The material name
  50933. * @param scene The scene the material will be use in.
  50934. */
  50935. constructor(name: string, scene: Scene);
  50936. /**
  50937. * Return the currrent class name of the material.
  50938. */
  50939. getClassName(): string;
  50940. /**
  50941. * Makes a duplicate of the current material.
  50942. * @param name - name to use for the new material.
  50943. */
  50944. clone(name: string): PBRSpecularGlossinessMaterial;
  50945. /**
  50946. * Serialize the material to a parsable JSON object.
  50947. */
  50948. serialize(): any;
  50949. /**
  50950. * Parses a JSON object correponding to the serialize function.
  50951. */
  50952. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  50953. }
  50954. }
  50955. declare module "babylonjs/Materials/PBR/index" {
  50956. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  50957. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  50958. export * from "babylonjs/Materials/PBR/pbrMaterial";
  50959. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  50960. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  50961. }
  50962. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  50963. import { Nullable } from "babylonjs/types";
  50964. import { Scene } from "babylonjs/scene";
  50965. import { Matrix } from "babylonjs/Maths/math";
  50966. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  50967. /**
  50968. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  50969. * It can help converting any input color in a desired output one. This can then be used to create effects
  50970. * from sepia, black and white to sixties or futuristic rendering...
  50971. *
  50972. * The only supported format is currently 3dl.
  50973. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  50974. */
  50975. export class ColorGradingTexture extends BaseTexture {
  50976. /**
  50977. * The current texture matrix. (will always be identity in color grading texture)
  50978. */
  50979. private _textureMatrix;
  50980. /**
  50981. * The texture URL.
  50982. */
  50983. url: string;
  50984. /**
  50985. * Empty line regex stored for GC.
  50986. */
  50987. private static _noneEmptyLineRegex;
  50988. private _engine;
  50989. /**
  50990. * Instantiates a ColorGradingTexture from the following parameters.
  50991. *
  50992. * @param url The location of the color gradind data (currently only supporting 3dl)
  50993. * @param scene The scene the texture will be used in
  50994. */
  50995. constructor(url: string, scene: Scene);
  50996. /**
  50997. * Returns the texture matrix used in most of the material.
  50998. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  50999. */
  51000. getTextureMatrix(): Matrix;
  51001. /**
  51002. * Occurs when the file being loaded is a .3dl LUT file.
  51003. */
  51004. private load3dlTexture;
  51005. /**
  51006. * Starts the loading process of the texture.
  51007. */
  51008. private loadTexture;
  51009. /**
  51010. * Clones the color gradind texture.
  51011. */
  51012. clone(): ColorGradingTexture;
  51013. /**
  51014. * Called during delayed load for textures.
  51015. */
  51016. delayLoad(): void;
  51017. /**
  51018. * Parses a color grading texture serialized by Babylon.
  51019. * @param parsedTexture The texture information being parsedTexture
  51020. * @param scene The scene to load the texture in
  51021. * @param rootUrl The root url of the data assets to load
  51022. * @return A color gradind texture
  51023. */
  51024. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  51025. /**
  51026. * Serializes the LUT texture to json format.
  51027. */
  51028. serialize(): any;
  51029. }
  51030. }
  51031. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  51032. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51033. import { Scene } from "babylonjs/scene";
  51034. import { Nullable } from "babylonjs/types";
  51035. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51036. /**
  51037. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  51038. */
  51039. export class EquiRectangularCubeTexture extends BaseTexture {
  51040. /** The six faces of the cube. */
  51041. private static _FacesMapping;
  51042. private _noMipmap;
  51043. private _onLoad;
  51044. private _onError;
  51045. /** The size of the cubemap. */
  51046. private _size;
  51047. /** The buffer of the image. */
  51048. private _buffer;
  51049. /** The width of the input image. */
  51050. private _width;
  51051. /** The height of the input image. */
  51052. private _height;
  51053. /** The URL to the image. */
  51054. url: string;
  51055. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  51056. coordinatesMode: number;
  51057. /**
  51058. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  51059. * @param url The location of the image
  51060. * @param scene The scene the texture will be used in
  51061. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  51062. * @param noMipmap Forces to not generate the mipmap if true
  51063. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  51064. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  51065. * @param onLoad — defines a callback called when texture is loaded
  51066. * @param onError — defines a callback called if there is an error
  51067. */
  51068. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  51069. /**
  51070. * Load the image data, by putting the image on a canvas and extracting its buffer.
  51071. */
  51072. private loadImage;
  51073. /**
  51074. * Convert the image buffer into a cubemap and create a CubeTexture.
  51075. */
  51076. private loadTexture;
  51077. /**
  51078. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  51079. * @param buffer The ArrayBuffer that should be converted.
  51080. * @returns The buffer as Float32Array.
  51081. */
  51082. private getFloat32ArrayFromArrayBuffer;
  51083. /**
  51084. * Get the current class name of the texture useful for serialization or dynamic coding.
  51085. * @returns "EquiRectangularCubeTexture"
  51086. */
  51087. getClassName(): string;
  51088. /**
  51089. * Create a clone of the current EquiRectangularCubeTexture and return it.
  51090. * @returns A clone of the current EquiRectangularCubeTexture.
  51091. */
  51092. clone(): EquiRectangularCubeTexture;
  51093. }
  51094. }
  51095. declare module "babylonjs/Misc/tga" {
  51096. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51097. /**
  51098. * Based on jsTGALoader - Javascript loader for TGA file
  51099. * By Vincent Thibault
  51100. * @see http://blog.robrowser.com/javascript-tga-loader.html
  51101. */
  51102. export class TGATools {
  51103. private static _TYPE_INDEXED;
  51104. private static _TYPE_RGB;
  51105. private static _TYPE_GREY;
  51106. private static _TYPE_RLE_INDEXED;
  51107. private static _TYPE_RLE_RGB;
  51108. private static _TYPE_RLE_GREY;
  51109. private static _ORIGIN_MASK;
  51110. private static _ORIGIN_SHIFT;
  51111. private static _ORIGIN_BL;
  51112. private static _ORIGIN_BR;
  51113. private static _ORIGIN_UL;
  51114. private static _ORIGIN_UR;
  51115. /**
  51116. * Gets the header of a TGA file
  51117. * @param data defines the TGA data
  51118. * @returns the header
  51119. */
  51120. static GetTGAHeader(data: Uint8Array): any;
  51121. /**
  51122. * Uploads TGA content to a Babylon Texture
  51123. * @hidden
  51124. */
  51125. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  51126. /** @hidden */
  51127. 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;
  51128. /** @hidden */
  51129. 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;
  51130. /** @hidden */
  51131. 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;
  51132. /** @hidden */
  51133. 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;
  51134. /** @hidden */
  51135. 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;
  51136. /** @hidden */
  51137. 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;
  51138. }
  51139. }
  51140. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  51141. import { Nullable } from "babylonjs/types";
  51142. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51143. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  51144. /**
  51145. * Implementation of the TGA Texture Loader.
  51146. * @hidden
  51147. */
  51148. export class _TGATextureLoader implements IInternalTextureLoader {
  51149. /**
  51150. * Defines wether the loader supports cascade loading the different faces.
  51151. */
  51152. readonly supportCascades: boolean;
  51153. /**
  51154. * This returns if the loader support the current file information.
  51155. * @param extension defines the file extension of the file being loaded
  51156. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51157. * @param fallback defines the fallback internal texture if any
  51158. * @param isBase64 defines whether the texture is encoded as a base64
  51159. * @param isBuffer defines whether the texture data are stored as a buffer
  51160. * @returns true if the loader can load the specified file
  51161. */
  51162. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  51163. /**
  51164. * Transform the url before loading if required.
  51165. * @param rootUrl the url of the texture
  51166. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51167. * @returns the transformed texture
  51168. */
  51169. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  51170. /**
  51171. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  51172. * @param rootUrl the url of the texture
  51173. * @param textureFormatInUse defines the current compressed format in use iun the engine
  51174. * @returns the fallback texture
  51175. */
  51176. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  51177. /**
  51178. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  51179. * @param data contains the texture data
  51180. * @param texture defines the BabylonJS internal texture
  51181. * @param createPolynomials will be true if polynomials have been requested
  51182. * @param onLoad defines the callback to trigger once the texture is ready
  51183. * @param onError defines the callback to trigger in case of error
  51184. */
  51185. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  51186. /**
  51187. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  51188. * @param data contains the texture data
  51189. * @param texture defines the BabylonJS internal texture
  51190. * @param callback defines the method to call once ready to upload
  51191. */
  51192. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  51193. }
  51194. }
  51195. declare module "babylonjs/Materials/Textures/Loaders/index" {
  51196. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  51197. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  51198. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  51199. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  51200. }
  51201. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  51202. import { Scene } from "babylonjs/scene";
  51203. import { Texture } from "babylonjs/Materials/Textures/texture";
  51204. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51205. /**
  51206. * 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.
  51207. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51208. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51209. */
  51210. export class CustomProceduralTexture extends ProceduralTexture {
  51211. private _animate;
  51212. private _time;
  51213. private _config;
  51214. private _texturePath;
  51215. /**
  51216. * Instantiates a new Custom Procedural Texture.
  51217. * 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.
  51218. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  51219. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  51220. * @param name Define the name of the texture
  51221. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  51222. * @param size Define the size of the texture to create
  51223. * @param scene Define the scene the texture belongs to
  51224. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  51225. * @param generateMipMaps Define if the texture should creates mip maps or not
  51226. */
  51227. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51228. private _loadJson;
  51229. /**
  51230. * Is the texture ready to be used ? (rendered at least once)
  51231. * @returns true if ready, otherwise, false.
  51232. */
  51233. isReady(): boolean;
  51234. /**
  51235. * Render the texture to its associated render target.
  51236. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  51237. */
  51238. render(useCameraPostProcess?: boolean): void;
  51239. /**
  51240. * Update the list of dependant textures samplers in the shader.
  51241. */
  51242. updateTextures(): void;
  51243. /**
  51244. * Update the uniform values of the procedural texture in the shader.
  51245. */
  51246. updateShaderUniforms(): void;
  51247. /**
  51248. * Define if the texture animates or not.
  51249. */
  51250. animate: boolean;
  51251. }
  51252. }
  51253. declare module "babylonjs/Shaders/noise.fragment" {
  51254. /** @hidden */
  51255. export var noisePixelShader: {
  51256. name: string;
  51257. shader: string;
  51258. };
  51259. }
  51260. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  51261. import { Nullable } from "babylonjs/types";
  51262. import { Scene } from "babylonjs/scene";
  51263. import { Texture } from "babylonjs/Materials/Textures/texture";
  51264. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51265. import "babylonjs/Shaders/noise.fragment";
  51266. /**
  51267. * Class used to generate noise procedural textures
  51268. */
  51269. export class NoiseProceduralTexture extends ProceduralTexture {
  51270. private _time;
  51271. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  51272. brightness: number;
  51273. /** Defines the number of octaves to process */
  51274. octaves: number;
  51275. /** Defines the level of persistence (0.8 by default) */
  51276. persistence: number;
  51277. /** Gets or sets animation speed factor (default is 1) */
  51278. animationSpeedFactor: number;
  51279. /**
  51280. * Creates a new NoiseProceduralTexture
  51281. * @param name defines the name fo the texture
  51282. * @param size defines the size of the texture (default is 256)
  51283. * @param scene defines the hosting scene
  51284. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  51285. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  51286. */
  51287. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  51288. private _updateShaderUniforms;
  51289. protected _getDefines(): string;
  51290. /** Generate the current state of the procedural texture */
  51291. render(useCameraPostProcess?: boolean): void;
  51292. /**
  51293. * Serializes this noise procedural texture
  51294. * @returns a serialized noise procedural texture object
  51295. */
  51296. serialize(): any;
  51297. /**
  51298. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  51299. * @param parsedTexture defines parsed texture data
  51300. * @param scene defines the current scene
  51301. * @param rootUrl defines the root URL containing noise procedural texture information
  51302. * @returns a parsed NoiseProceduralTexture
  51303. */
  51304. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  51305. }
  51306. }
  51307. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  51308. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  51309. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  51310. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  51311. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  51312. }
  51313. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  51314. import { Nullable } from "babylonjs/types";
  51315. import { Scene } from "babylonjs/scene";
  51316. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  51317. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  51318. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  51319. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51320. /**
  51321. * Raw cube texture where the raw buffers are passed in
  51322. */
  51323. export class RawCubeTexture extends CubeTexture {
  51324. /**
  51325. * Creates a cube texture where the raw buffers are passed in.
  51326. * @param scene defines the scene the texture is attached to
  51327. * @param data defines the array of data to use to create each face
  51328. * @param size defines the size of the textures
  51329. * @param format defines the format of the data
  51330. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  51331. * @param generateMipMaps defines if the engine should generate the mip levels
  51332. * @param invertY defines if data must be stored with Y axis inverted
  51333. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  51334. * @param compression defines the compression used (null by default)
  51335. */
  51336. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  51337. /**
  51338. * Updates the raw cube texture.
  51339. * @param data defines the data to store
  51340. * @param format defines the data format
  51341. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  51342. * @param invertY defines if data must be stored with Y axis inverted
  51343. * @param compression defines the compression used (null by default)
  51344. * @param level defines which level of the texture to update
  51345. */
  51346. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  51347. /**
  51348. * Updates a raw cube texture with RGBD encoded data.
  51349. * @param data defines the array of data [mipmap][face] to use to create each face
  51350. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  51351. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  51352. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  51353. * @returns a promsie that resolves when the operation is complete
  51354. */
  51355. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  51356. /**
  51357. * Clones the raw cube texture.
  51358. * @return a new cube texture
  51359. */
  51360. clone(): CubeTexture;
  51361. /** @hidden */
  51362. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  51363. }
  51364. }
  51365. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  51366. import { Scene } from "babylonjs/scene";
  51367. import { Texture } from "babylonjs/Materials/Textures/texture";
  51368. import "babylonjs/Engines/Extensions/engine.rawTexture";
  51369. /**
  51370. * Class used to store 3D textures containing user data
  51371. */
  51372. export class RawTexture3D extends Texture {
  51373. /** Gets or sets the texture format to use */
  51374. format: number;
  51375. private _engine;
  51376. /**
  51377. * Create a new RawTexture3D
  51378. * @param data defines the data of the texture
  51379. * @param width defines the width of the texture
  51380. * @param height defines the height of the texture
  51381. * @param depth defines the depth of the texture
  51382. * @param format defines the texture format to use
  51383. * @param scene defines the hosting scene
  51384. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  51385. * @param invertY defines if texture must be stored with Y axis inverted
  51386. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  51387. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  51388. */
  51389. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  51390. /** Gets or sets the texture format to use */
  51391. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  51392. /**
  51393. * Update the texture with new data
  51394. * @param data defines the data to store in the texture
  51395. */
  51396. update(data: ArrayBufferView): void;
  51397. }
  51398. }
  51399. declare module "babylonjs/Materials/Textures/refractionTexture" {
  51400. import { Scene } from "babylonjs/scene";
  51401. import { Plane } from "babylonjs/Maths/math";
  51402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  51403. /**
  51404. * Creates a refraction texture used by refraction channel of the standard material.
  51405. * It is like a mirror but to see through a material.
  51406. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51407. */
  51408. export class RefractionTexture extends RenderTargetTexture {
  51409. /**
  51410. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  51411. * 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.
  51412. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51413. */
  51414. refractionPlane: Plane;
  51415. /**
  51416. * Define how deep under the surface we should see.
  51417. */
  51418. depth: number;
  51419. /**
  51420. * Creates a refraction texture used by refraction channel of the standard material.
  51421. * It is like a mirror but to see through a material.
  51422. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  51423. * @param name Define the texture name
  51424. * @param size Define the size of the underlying texture
  51425. * @param scene Define the scene the refraction belongs to
  51426. * @param generateMipMaps Define if we need to generate mips level for the refraction
  51427. */
  51428. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  51429. /**
  51430. * Clone the refraction texture.
  51431. * @returns the cloned texture
  51432. */
  51433. clone(): RefractionTexture;
  51434. /**
  51435. * Serialize the texture to a JSON representation you could use in Parse later on
  51436. * @returns the serialized JSON representation
  51437. */
  51438. serialize(): any;
  51439. }
  51440. }
  51441. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  51442. import { Nullable } from "babylonjs/types";
  51443. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  51444. import { Matrix } from "babylonjs/Maths/math";
  51445. import { Engine } from "babylonjs/Engines/engine";
  51446. import { Scene } from "babylonjs/scene";
  51447. /**
  51448. * Defines the options related to the creation of an HtmlElementTexture
  51449. */
  51450. export interface IHtmlElementTextureOptions {
  51451. /**
  51452. * Defines wether mip maps should be created or not.
  51453. */
  51454. generateMipMaps?: boolean;
  51455. /**
  51456. * Defines the sampling mode of the texture.
  51457. */
  51458. samplingMode?: number;
  51459. /**
  51460. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  51461. */
  51462. engine: Nullable<Engine>;
  51463. /**
  51464. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  51465. */
  51466. scene: Nullable<Scene>;
  51467. }
  51468. /**
  51469. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  51470. * To be as efficient as possible depending on your constraints nothing aside the first upload
  51471. * is automatically managed.
  51472. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  51473. * in your application.
  51474. *
  51475. * As the update is not automatic, you need to call them manually.
  51476. */
  51477. export class HtmlElementTexture extends BaseTexture {
  51478. /**
  51479. * The texture URL.
  51480. */
  51481. element: HTMLVideoElement | HTMLCanvasElement;
  51482. private static readonly DefaultOptions;
  51483. private _textureMatrix;
  51484. private _engine;
  51485. private _isVideo;
  51486. private _generateMipMaps;
  51487. private _samplingMode;
  51488. /**
  51489. * Instantiates a HtmlElementTexture from the following parameters.
  51490. *
  51491. * @param name Defines the name of the texture
  51492. * @param element Defines the video or canvas the texture is filled with
  51493. * @param options Defines the other none mandatory texture creation options
  51494. */
  51495. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  51496. private _createInternalTexture;
  51497. /**
  51498. * Returns the texture matrix used in most of the material.
  51499. */
  51500. getTextureMatrix(): Matrix;
  51501. /**
  51502. * Updates the content of the texture.
  51503. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  51504. */
  51505. update(invertY?: Nullable<boolean>): void;
  51506. }
  51507. }
  51508. declare module "babylonjs/Materials/Textures/index" {
  51509. export * from "babylonjs/Materials/Textures/baseTexture";
  51510. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  51511. export * from "babylonjs/Materials/Textures/cubeTexture";
  51512. export * from "babylonjs/Materials/Textures/dynamicTexture";
  51513. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  51514. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  51515. export * from "babylonjs/Materials/Textures/internalTexture";
  51516. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  51517. export * from "babylonjs/Materials/Textures/Loaders/index";
  51518. export * from "babylonjs/Materials/Textures/mirrorTexture";
  51519. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  51520. export * from "babylonjs/Materials/Textures/Procedurals/index";
  51521. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  51522. export * from "babylonjs/Materials/Textures/rawTexture";
  51523. export * from "babylonjs/Materials/Textures/rawTexture3D";
  51524. export * from "babylonjs/Materials/Textures/refractionTexture";
  51525. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  51526. export * from "babylonjs/Materials/Textures/texture";
  51527. export * from "babylonjs/Materials/Textures/videoTexture";
  51528. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  51529. }
  51530. declare module "babylonjs/Materials/index" {
  51531. export * from "babylonjs/Materials/Background/index";
  51532. export * from "babylonjs/Materials/colorCurves";
  51533. export * from "babylonjs/Materials/effect";
  51534. export * from "babylonjs/Materials/fresnelParameters";
  51535. export * from "babylonjs/Materials/imageProcessingConfiguration";
  51536. export * from "babylonjs/Materials/material";
  51537. export * from "babylonjs/Materials/materialDefines";
  51538. export * from "babylonjs/Materials/materialHelper";
  51539. export * from "babylonjs/Materials/multiMaterial";
  51540. export * from "babylonjs/Materials/PBR/index";
  51541. export * from "babylonjs/Materials/pushMaterial";
  51542. export * from "babylonjs/Materials/shaderMaterial";
  51543. export * from "babylonjs/Materials/standardMaterial";
  51544. export * from "babylonjs/Materials/Textures/index";
  51545. export * from "babylonjs/Materials/uniformBuffer";
  51546. export * from "babylonjs/Materials/materialFlags";
  51547. }
  51548. declare module "babylonjs/Maths/index" {
  51549. export * from "babylonjs/Maths/math.scalar";
  51550. export * from "babylonjs/Maths/math";
  51551. export * from "babylonjs/Maths/sphericalPolynomial";
  51552. }
  51553. declare module "babylonjs/Misc/workerPool" {
  51554. import { IDisposable } from "babylonjs/scene";
  51555. /**
  51556. * Helper class to push actions to a pool of workers.
  51557. */
  51558. export class WorkerPool implements IDisposable {
  51559. private _workerInfos;
  51560. private _pendingActions;
  51561. /**
  51562. * Constructor
  51563. * @param workers Array of workers to use for actions
  51564. */
  51565. constructor(workers: Array<Worker>);
  51566. /**
  51567. * Terminates all workers and clears any pending actions.
  51568. */
  51569. dispose(): void;
  51570. /**
  51571. * Pushes an action to the worker pool. If all the workers are active, the action will be
  51572. * pended until a worker has completed its action.
  51573. * @param action The action to perform. Call onComplete when the action is complete.
  51574. */
  51575. push(action: (worker: Worker, onComplete: () => void) => void): void;
  51576. private _execute;
  51577. }
  51578. }
  51579. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  51580. import { IDisposable } from "babylonjs/scene";
  51581. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51582. /**
  51583. * Configuration for Draco compression
  51584. */
  51585. export interface IDracoCompressionConfiguration {
  51586. /**
  51587. * Configuration for the decoder.
  51588. */
  51589. decoder?: {
  51590. /**
  51591. * The url to the WebAssembly module.
  51592. */
  51593. wasmUrl?: string;
  51594. /**
  51595. * The url to the WebAssembly binary.
  51596. */
  51597. wasmBinaryUrl?: string;
  51598. /**
  51599. * The url to the fallback JavaScript module.
  51600. */
  51601. fallbackUrl?: string;
  51602. };
  51603. }
  51604. /**
  51605. * Draco compression (https://google.github.io/draco/)
  51606. *
  51607. * This class wraps the Draco module.
  51608. *
  51609. * **Encoder**
  51610. *
  51611. * The encoder is not currently implemented.
  51612. *
  51613. * **Decoder**
  51614. *
  51615. * 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.
  51616. *
  51617. * To update the configuration, use the following code:
  51618. * ```javascript
  51619. * DracoCompression.Configuration = {
  51620. * decoder: {
  51621. * wasmUrl: "<url to the WebAssembly library>",
  51622. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  51623. * fallbackUrl: "<url to the fallback JavaScript library>",
  51624. * }
  51625. * };
  51626. * ```
  51627. *
  51628. * 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.
  51629. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  51630. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  51631. *
  51632. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  51633. * ```javascript
  51634. * var dracoCompression = new DracoCompression();
  51635. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  51636. * [VertexBuffer.PositionKind]: 0
  51637. * });
  51638. * ```
  51639. *
  51640. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  51641. */
  51642. export class DracoCompression implements IDisposable {
  51643. private _workerPoolPromise;
  51644. /**
  51645. * The configuration. Defaults to the following urls:
  51646. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  51647. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  51648. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  51649. */
  51650. static Configuration: IDracoCompressionConfiguration;
  51651. /**
  51652. * Returns true if the decoder is available.
  51653. */
  51654. static readonly DecoderAvailable: boolean;
  51655. /**
  51656. * Default number of workers to create when creating the draco compression object.
  51657. */
  51658. static DefaultNumWorkers: number;
  51659. private static GetDefaultNumWorkers;
  51660. /**
  51661. * Constructor
  51662. * @param numWorkers The number of workers for async operations
  51663. */
  51664. constructor(numWorkers?: number);
  51665. /**
  51666. * Stop all async operations and release resources.
  51667. */
  51668. dispose(): void;
  51669. /**
  51670. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  51671. * @returns a promise that resolves when ready
  51672. */
  51673. whenReadyAsync(): Promise<void>;
  51674. /**
  51675. * Decode Draco compressed mesh data to vertex data.
  51676. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  51677. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  51678. * @returns A promise that resolves with the decoded vertex data
  51679. */
  51680. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  51681. [kind: string]: number;
  51682. }): Promise<VertexData>;
  51683. /**
  51684. * The worker function that gets converted to a blob url to pass into a worker.
  51685. */
  51686. private static _Worker;
  51687. private _loadDecoderWasmBinaryAsync;
  51688. }
  51689. }
  51690. declare module "babylonjs/Meshes/Compression/index" {
  51691. export * from "babylonjs/Meshes/Compression/dracoCompression";
  51692. }
  51693. declare module "babylonjs/Meshes/csg" {
  51694. import { Nullable } from "babylonjs/types";
  51695. import { Scene } from "babylonjs/scene";
  51696. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math";
  51697. import { Mesh } from "babylonjs/Meshes/mesh";
  51698. import { Material } from "babylonjs/Materials/material";
  51699. /**
  51700. * Class for building Constructive Solid Geometry
  51701. */
  51702. export class CSG {
  51703. private polygons;
  51704. /**
  51705. * The world matrix
  51706. */
  51707. matrix: Matrix;
  51708. /**
  51709. * Stores the position
  51710. */
  51711. position: Vector3;
  51712. /**
  51713. * Stores the rotation
  51714. */
  51715. rotation: Vector3;
  51716. /**
  51717. * Stores the rotation quaternion
  51718. */
  51719. rotationQuaternion: Nullable<Quaternion>;
  51720. /**
  51721. * Stores the scaling vector
  51722. */
  51723. scaling: Vector3;
  51724. /**
  51725. * Convert the Mesh to CSG
  51726. * @param mesh The Mesh to convert to CSG
  51727. * @returns A new CSG from the Mesh
  51728. */
  51729. static FromMesh(mesh: Mesh): CSG;
  51730. /**
  51731. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  51732. * @param polygons Polygons used to construct a CSG solid
  51733. */
  51734. private static FromPolygons;
  51735. /**
  51736. * Clones, or makes a deep copy, of the CSG
  51737. * @returns A new CSG
  51738. */
  51739. clone(): CSG;
  51740. /**
  51741. * Unions this CSG with another CSG
  51742. * @param csg The CSG to union against this CSG
  51743. * @returns The unioned CSG
  51744. */
  51745. union(csg: CSG): CSG;
  51746. /**
  51747. * Unions this CSG with another CSG in place
  51748. * @param csg The CSG to union against this CSG
  51749. */
  51750. unionInPlace(csg: CSG): void;
  51751. /**
  51752. * Subtracts this CSG with another CSG
  51753. * @param csg The CSG to subtract against this CSG
  51754. * @returns A new CSG
  51755. */
  51756. subtract(csg: CSG): CSG;
  51757. /**
  51758. * Subtracts this CSG with another CSG in place
  51759. * @param csg The CSG to subtact against this CSG
  51760. */
  51761. subtractInPlace(csg: CSG): void;
  51762. /**
  51763. * Intersect this CSG with another CSG
  51764. * @param csg The CSG to intersect against this CSG
  51765. * @returns A new CSG
  51766. */
  51767. intersect(csg: CSG): CSG;
  51768. /**
  51769. * Intersects this CSG with another CSG in place
  51770. * @param csg The CSG to intersect against this CSG
  51771. */
  51772. intersectInPlace(csg: CSG): void;
  51773. /**
  51774. * Return a new CSG solid with solid and empty space switched. This solid is
  51775. * not modified.
  51776. * @returns A new CSG solid with solid and empty space switched
  51777. */
  51778. inverse(): CSG;
  51779. /**
  51780. * Inverses the CSG in place
  51781. */
  51782. inverseInPlace(): void;
  51783. /**
  51784. * This is used to keep meshes transformations so they can be restored
  51785. * when we build back a Babylon Mesh
  51786. * NB : All CSG operations are performed in world coordinates
  51787. * @param csg The CSG to copy the transform attributes from
  51788. * @returns This CSG
  51789. */
  51790. copyTransformAttributes(csg: CSG): CSG;
  51791. /**
  51792. * Build Raw mesh from CSG
  51793. * Coordinates here are in world space
  51794. * @param name The name of the mesh geometry
  51795. * @param scene The Scene
  51796. * @param keepSubMeshes Specifies if the submeshes should be kept
  51797. * @returns A new Mesh
  51798. */
  51799. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  51800. /**
  51801. * Build Mesh from CSG taking material and transforms into account
  51802. * @param name The name of the Mesh
  51803. * @param material The material of the Mesh
  51804. * @param scene The Scene
  51805. * @param keepSubMeshes Specifies if submeshes should be kept
  51806. * @returns The new Mesh
  51807. */
  51808. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  51809. }
  51810. }
  51811. declare module "babylonjs/Meshes/trailMesh" {
  51812. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51813. import { Mesh } from "babylonjs/Meshes/mesh";
  51814. import { Scene } from "babylonjs/scene";
  51815. /**
  51816. * Class used to create a trail following a mesh
  51817. */
  51818. export class TrailMesh extends Mesh {
  51819. private _generator;
  51820. private _autoStart;
  51821. private _running;
  51822. private _diameter;
  51823. private _length;
  51824. private _sectionPolygonPointsCount;
  51825. private _sectionVectors;
  51826. private _sectionNormalVectors;
  51827. private _beforeRenderObserver;
  51828. /**
  51829. * @constructor
  51830. * @param name The value used by scene.getMeshByName() to do a lookup.
  51831. * @param generator The mesh to generate a trail.
  51832. * @param scene The scene to add this mesh to.
  51833. * @param diameter Diameter of trailing mesh. Default is 1.
  51834. * @param length Length of trailing mesh. Default is 60.
  51835. * @param autoStart Automatically start trailing mesh. Default true.
  51836. */
  51837. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  51838. /**
  51839. * "TrailMesh"
  51840. * @returns "TrailMesh"
  51841. */
  51842. getClassName(): string;
  51843. private _createMesh;
  51844. /**
  51845. * Start trailing mesh.
  51846. */
  51847. start(): void;
  51848. /**
  51849. * Stop trailing mesh.
  51850. */
  51851. stop(): void;
  51852. /**
  51853. * Update trailing mesh geometry.
  51854. */
  51855. update(): void;
  51856. /**
  51857. * Returns a new TrailMesh object.
  51858. * @param name is a string, the name given to the new mesh
  51859. * @param newGenerator use new generator object for cloned trail mesh
  51860. * @returns a new mesh
  51861. */
  51862. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  51863. /**
  51864. * Serializes this trail mesh
  51865. * @param serializationObject object to write serialization to
  51866. */
  51867. serialize(serializationObject: any): void;
  51868. /**
  51869. * Parses a serialized trail mesh
  51870. * @param parsedMesh the serialized mesh
  51871. * @param scene the scene to create the trail mesh in
  51872. * @returns the created trail mesh
  51873. */
  51874. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  51875. }
  51876. }
  51877. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  51878. import { Vector4 } from "babylonjs/Maths/math";
  51879. import { Mesh } from "babylonjs/Meshes/mesh";
  51880. /**
  51881. * Class containing static functions to help procedurally build meshes
  51882. */
  51883. export class TorusKnotBuilder {
  51884. /**
  51885. * Creates a torus knot mesh
  51886. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  51887. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  51888. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  51889. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  51890. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  51891. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  51892. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  51893. * @param name defines the name of the mesh
  51894. * @param options defines the options used to create the mesh
  51895. * @param scene defines the hosting scene
  51896. * @returns the torus knot mesh
  51897. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  51898. */
  51899. static CreateTorusKnot(name: string, options: {
  51900. radius?: number;
  51901. tube?: number;
  51902. radialSegments?: number;
  51903. tubularSegments?: number;
  51904. p?: number;
  51905. q?: number;
  51906. updatable?: boolean;
  51907. sideOrientation?: number;
  51908. frontUVs?: Vector4;
  51909. backUVs?: Vector4;
  51910. }, scene: any): Mesh;
  51911. }
  51912. }
  51913. declare module "babylonjs/Meshes/polygonMesh" {
  51914. import { Scene } from "babylonjs/scene";
  51915. import { Vector2, Path2 } from "babylonjs/Maths/math";
  51916. import { Mesh } from "babylonjs/Meshes/mesh";
  51917. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  51918. /**
  51919. * Polygon
  51920. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  51921. */
  51922. export class Polygon {
  51923. /**
  51924. * Creates a rectangle
  51925. * @param xmin bottom X coord
  51926. * @param ymin bottom Y coord
  51927. * @param xmax top X coord
  51928. * @param ymax top Y coord
  51929. * @returns points that make the resulting rectation
  51930. */
  51931. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  51932. /**
  51933. * Creates a circle
  51934. * @param radius radius of circle
  51935. * @param cx scale in x
  51936. * @param cy scale in y
  51937. * @param numberOfSides number of sides that make up the circle
  51938. * @returns points that make the resulting circle
  51939. */
  51940. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  51941. /**
  51942. * Creates a polygon from input string
  51943. * @param input Input polygon data
  51944. * @returns the parsed points
  51945. */
  51946. static Parse(input: string): Vector2[];
  51947. /**
  51948. * Starts building a polygon from x and y coordinates
  51949. * @param x x coordinate
  51950. * @param y y coordinate
  51951. * @returns the started path2
  51952. */
  51953. static StartingAt(x: number, y: number): Path2;
  51954. }
  51955. /**
  51956. * Builds a polygon
  51957. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  51958. */
  51959. export class PolygonMeshBuilder {
  51960. private _points;
  51961. private _outlinepoints;
  51962. private _holes;
  51963. private _name;
  51964. private _scene;
  51965. private _epoints;
  51966. private _eholes;
  51967. private _addToepoint;
  51968. /**
  51969. * Babylon reference to the earcut plugin.
  51970. */
  51971. bjsEarcut: any;
  51972. /**
  51973. * Creates a PolygonMeshBuilder
  51974. * @param name name of the builder
  51975. * @param contours Path of the polygon
  51976. * @param scene scene to add to when creating the mesh
  51977. * @param earcutInjection can be used to inject your own earcut reference
  51978. */
  51979. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  51980. /**
  51981. * Adds a whole within the polygon
  51982. * @param hole Array of points defining the hole
  51983. * @returns this
  51984. */
  51985. addHole(hole: Vector2[]): PolygonMeshBuilder;
  51986. /**
  51987. * Creates the polygon
  51988. * @param updatable If the mesh should be updatable
  51989. * @param depth The depth of the mesh created
  51990. * @returns the created mesh
  51991. */
  51992. build(updatable?: boolean, depth?: number): Mesh;
  51993. /**
  51994. * Creates the polygon
  51995. * @param depth The depth of the mesh created
  51996. * @returns the created VertexData
  51997. */
  51998. buildVertexData(depth?: number): VertexData;
  51999. /**
  52000. * Adds a side to the polygon
  52001. * @param positions points that make the polygon
  52002. * @param normals normals of the polygon
  52003. * @param uvs uvs of the polygon
  52004. * @param indices indices of the polygon
  52005. * @param bounds bounds of the polygon
  52006. * @param points points of the polygon
  52007. * @param depth depth of the polygon
  52008. * @param flip flip of the polygon
  52009. */
  52010. private addSide;
  52011. }
  52012. }
  52013. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  52014. import { Scene } from "babylonjs/scene";
  52015. import { Vector3, Color4, Vector4 } from "babylonjs/Maths/math";
  52016. import { Mesh } from "babylonjs/Meshes/mesh";
  52017. import { Nullable } from "babylonjs/types";
  52018. /**
  52019. * Class containing static functions to help procedurally build meshes
  52020. */
  52021. export class PolygonBuilder {
  52022. /**
  52023. * Creates a polygon mesh
  52024. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52025. * * 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
  52026. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52027. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52028. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52029. * * Remember you can only change the shape positions, not their number when updating a polygon
  52030. * @param name defines the name of the mesh
  52031. * @param options defines the options used to create the mesh
  52032. * @param scene defines the hosting scene
  52033. * @param earcutInjection can be used to inject your own earcut reference
  52034. * @returns the polygon mesh
  52035. */
  52036. static CreatePolygon(name: string, options: {
  52037. shape: Vector3[];
  52038. holes?: Vector3[][];
  52039. depth?: number;
  52040. faceUV?: Vector4[];
  52041. faceColors?: Color4[];
  52042. updatable?: boolean;
  52043. sideOrientation?: number;
  52044. frontUVs?: Vector4;
  52045. backUVs?: Vector4;
  52046. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52047. /**
  52048. * Creates an extruded polygon mesh, with depth in the Y direction.
  52049. * * 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)
  52050. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52051. * @param name defines the name of the mesh
  52052. * @param options defines the options used to create the mesh
  52053. * @param scene defines the hosting scene
  52054. * @param earcutInjection can be used to inject your own earcut reference
  52055. * @returns the polygon mesh
  52056. */
  52057. static ExtrudePolygon(name: string, options: {
  52058. shape: Vector3[];
  52059. holes?: Vector3[][];
  52060. depth?: number;
  52061. faceUV?: Vector4[];
  52062. faceColors?: Color4[];
  52063. updatable?: boolean;
  52064. sideOrientation?: number;
  52065. frontUVs?: Vector4;
  52066. backUVs?: Vector4;
  52067. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52068. }
  52069. }
  52070. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  52071. import { Scene } from "babylonjs/scene";
  52072. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52073. import { Mesh } from "babylonjs/Meshes/mesh";
  52074. import { Nullable } from "babylonjs/types";
  52075. /**
  52076. * Class containing static functions to help procedurally build meshes
  52077. */
  52078. export class LatheBuilder {
  52079. /**
  52080. * Creates lathe mesh.
  52081. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52082. * * 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
  52083. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52084. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52085. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52086. * * 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
  52087. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52088. * * 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
  52089. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52091. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52092. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52093. * @param name defines the name of the mesh
  52094. * @param options defines the options used to create the mesh
  52095. * @param scene defines the hosting scene
  52096. * @returns the lathe mesh
  52097. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52098. */
  52099. static CreateLathe(name: string, options: {
  52100. shape: Vector3[];
  52101. radius?: number;
  52102. tessellation?: number;
  52103. clip?: number;
  52104. arc?: number;
  52105. closed?: boolean;
  52106. updatable?: boolean;
  52107. sideOrientation?: number;
  52108. frontUVs?: Vector4;
  52109. backUVs?: Vector4;
  52110. cap?: number;
  52111. invertUV?: boolean;
  52112. }, scene?: Nullable<Scene>): Mesh;
  52113. }
  52114. }
  52115. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  52116. import { Nullable } from "babylonjs/types";
  52117. import { Scene } from "babylonjs/scene";
  52118. import { Vector3, Vector4 } from "babylonjs/Maths/math";
  52119. import { Mesh } from "babylonjs/Meshes/mesh";
  52120. /**
  52121. * Class containing static functions to help procedurally build meshes
  52122. */
  52123. export class TubeBuilder {
  52124. /**
  52125. * Creates a tube mesh.
  52126. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52127. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52128. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52129. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52130. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52131. * * 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)
  52132. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52133. * * 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
  52134. * * 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
  52135. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52136. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52137. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52139. * @param name defines the name of the mesh
  52140. * @param options defines the options used to create the mesh
  52141. * @param scene defines the hosting scene
  52142. * @returns the tube mesh
  52143. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52144. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52145. */
  52146. static CreateTube(name: string, options: {
  52147. path: Vector3[];
  52148. radius?: number;
  52149. tessellation?: number;
  52150. radiusFunction?: {
  52151. (i: number, distance: number): number;
  52152. };
  52153. cap?: number;
  52154. arc?: number;
  52155. updatable?: boolean;
  52156. sideOrientation?: number;
  52157. frontUVs?: Vector4;
  52158. backUVs?: Vector4;
  52159. instance?: Mesh;
  52160. invertUV?: boolean;
  52161. }, scene?: Nullable<Scene>): Mesh;
  52162. }
  52163. }
  52164. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  52165. import { Scene } from "babylonjs/scene";
  52166. import { Vector4 } from "babylonjs/Maths/math";
  52167. import { Mesh } from "babylonjs/Meshes/mesh";
  52168. import { Nullable } from "babylonjs/types";
  52169. /**
  52170. * Class containing static functions to help procedurally build meshes
  52171. */
  52172. export class IcoSphereBuilder {
  52173. /**
  52174. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52175. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52176. * * 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`)
  52177. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52178. * * 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
  52179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52182. * @param name defines the name of the mesh
  52183. * @param options defines the options used to create the mesh
  52184. * @param scene defines the hosting scene
  52185. * @returns the icosahedron mesh
  52186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52187. */
  52188. static CreateIcoSphere(name: string, options: {
  52189. radius?: number;
  52190. radiusX?: number;
  52191. radiusY?: number;
  52192. radiusZ?: number;
  52193. flat?: boolean;
  52194. subdivisions?: number;
  52195. sideOrientation?: number;
  52196. frontUVs?: Vector4;
  52197. backUVs?: Vector4;
  52198. updatable?: boolean;
  52199. }, scene?: Nullable<Scene>): Mesh;
  52200. }
  52201. }
  52202. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  52203. import { Vector3 } from "babylonjs/Maths/math";
  52204. import { Mesh } from "babylonjs/Meshes/mesh";
  52205. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52206. /**
  52207. * Class containing static functions to help procedurally build meshes
  52208. */
  52209. export class DecalBuilder {
  52210. /**
  52211. * Creates a decal mesh.
  52212. * 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
  52213. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52214. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52215. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52216. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52217. * @param name defines the name of the mesh
  52218. * @param sourceMesh defines the mesh where the decal must be applied
  52219. * @param options defines the options used to create the mesh
  52220. * @param scene defines the hosting scene
  52221. * @returns the decal mesh
  52222. * @see https://doc.babylonjs.com/how_to/decals
  52223. */
  52224. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52225. position?: Vector3;
  52226. normal?: Vector3;
  52227. size?: Vector3;
  52228. angle?: number;
  52229. }): Mesh;
  52230. }
  52231. }
  52232. declare module "babylonjs/Meshes/meshBuilder" {
  52233. import { Vector4, Color4, Vector3, Vector2, Plane, Color3 } from "babylonjs/Maths/math";
  52234. import { Nullable } from "babylonjs/types";
  52235. import { Scene } from "babylonjs/scene";
  52236. import { Mesh } from "babylonjs/Meshes/mesh";
  52237. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  52238. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  52239. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52240. /**
  52241. * Class containing static functions to help procedurally build meshes
  52242. */
  52243. export class MeshBuilder {
  52244. /**
  52245. * Creates a box mesh
  52246. * * The parameter `size` sets the size (float) of each box side (default 1)
  52247. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  52248. * * 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)
  52249. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52250. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52251. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52252. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52253. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  52254. * @param name defines the name of the mesh
  52255. * @param options defines the options used to create the mesh
  52256. * @param scene defines the hosting scene
  52257. * @returns the box mesh
  52258. */
  52259. static CreateBox(name: string, options: {
  52260. size?: number;
  52261. width?: number;
  52262. height?: number;
  52263. depth?: number;
  52264. faceUV?: Vector4[];
  52265. faceColors?: Color4[];
  52266. sideOrientation?: number;
  52267. frontUVs?: Vector4;
  52268. backUVs?: Vector4;
  52269. updatable?: boolean;
  52270. }, scene?: Nullable<Scene>): Mesh;
  52271. /**
  52272. * Creates a sphere mesh
  52273. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  52274. * * 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`)
  52275. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  52276. * * 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
  52277. * * 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)
  52278. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52279. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52280. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52281. * @param name defines the name of the mesh
  52282. * @param options defines the options used to create the mesh
  52283. * @param scene defines the hosting scene
  52284. * @returns the sphere mesh
  52285. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  52286. */
  52287. static CreateSphere(name: string, options: {
  52288. segments?: number;
  52289. diameter?: number;
  52290. diameterX?: number;
  52291. diameterY?: number;
  52292. diameterZ?: number;
  52293. arc?: number;
  52294. slice?: number;
  52295. sideOrientation?: number;
  52296. frontUVs?: Vector4;
  52297. backUVs?: Vector4;
  52298. updatable?: boolean;
  52299. }, scene?: Nullable<Scene>): Mesh;
  52300. /**
  52301. * Creates a plane polygonal mesh. By default, this is a disc
  52302. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  52303. * * 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
  52304. * * 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
  52305. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52306. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52308. * @param name defines the name of the mesh
  52309. * @param options defines the options used to create the mesh
  52310. * @param scene defines the hosting scene
  52311. * @returns the plane polygonal mesh
  52312. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  52313. */
  52314. static CreateDisc(name: string, options: {
  52315. radius?: number;
  52316. tessellation?: number;
  52317. arc?: number;
  52318. updatable?: boolean;
  52319. sideOrientation?: number;
  52320. frontUVs?: Vector4;
  52321. backUVs?: Vector4;
  52322. }, scene?: Nullable<Scene>): Mesh;
  52323. /**
  52324. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  52325. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  52326. * * 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`)
  52327. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  52328. * * 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
  52329. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52330. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52331. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52332. * @param name defines the name of the mesh
  52333. * @param options defines the options used to create the mesh
  52334. * @param scene defines the hosting scene
  52335. * @returns the icosahedron mesh
  52336. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  52337. */
  52338. static CreateIcoSphere(name: string, options: {
  52339. radius?: number;
  52340. radiusX?: number;
  52341. radiusY?: number;
  52342. radiusZ?: number;
  52343. flat?: boolean;
  52344. subdivisions?: number;
  52345. sideOrientation?: number;
  52346. frontUVs?: Vector4;
  52347. backUVs?: Vector4;
  52348. updatable?: boolean;
  52349. }, scene?: Nullable<Scene>): Mesh;
  52350. /**
  52351. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52352. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  52353. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  52354. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  52355. * * 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
  52356. * * 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
  52357. * * 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
  52358. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52359. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52360. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52361. * * 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
  52362. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  52363. * * 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
  52364. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  52365. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52366. * @param name defines the name of the mesh
  52367. * @param options defines the options used to create the mesh
  52368. * @param scene defines the hosting scene
  52369. * @returns the ribbon mesh
  52370. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  52371. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52372. */
  52373. static CreateRibbon(name: string, options: {
  52374. pathArray: Vector3[][];
  52375. closeArray?: boolean;
  52376. closePath?: boolean;
  52377. offset?: number;
  52378. updatable?: boolean;
  52379. sideOrientation?: number;
  52380. frontUVs?: Vector4;
  52381. backUVs?: Vector4;
  52382. instance?: Mesh;
  52383. invertUV?: boolean;
  52384. uvs?: Vector2[];
  52385. colors?: Color4[];
  52386. }, scene?: Nullable<Scene>): Mesh;
  52387. /**
  52388. * Creates a cylinder or a cone mesh
  52389. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  52390. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  52391. * * 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.
  52392. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  52393. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  52394. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  52395. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  52396. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  52397. * * 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).
  52398. * * 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
  52399. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  52400. * * 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
  52401. * * 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.
  52402. * * If `enclose` is false, a ring surface is one element.
  52403. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  52404. * * 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
  52405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52408. * @param name defines the name of the mesh
  52409. * @param options defines the options used to create the mesh
  52410. * @param scene defines the hosting scene
  52411. * @returns the cylinder mesh
  52412. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  52413. */
  52414. static CreateCylinder(name: string, options: {
  52415. height?: number;
  52416. diameterTop?: number;
  52417. diameterBottom?: number;
  52418. diameter?: number;
  52419. tessellation?: number;
  52420. subdivisions?: number;
  52421. arc?: number;
  52422. faceColors?: Color4[];
  52423. faceUV?: Vector4[];
  52424. updatable?: boolean;
  52425. hasRings?: boolean;
  52426. enclose?: boolean;
  52427. sideOrientation?: number;
  52428. frontUVs?: Vector4;
  52429. backUVs?: Vector4;
  52430. }, scene?: Nullable<Scene>): Mesh;
  52431. /**
  52432. * Creates a torus mesh
  52433. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  52434. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  52435. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  52436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52437. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52439. * @param name defines the name of the mesh
  52440. * @param options defines the options used to create the mesh
  52441. * @param scene defines the hosting scene
  52442. * @returns the torus mesh
  52443. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  52444. */
  52445. static CreateTorus(name: string, options: {
  52446. diameter?: number;
  52447. thickness?: number;
  52448. tessellation?: number;
  52449. updatable?: boolean;
  52450. sideOrientation?: number;
  52451. frontUVs?: Vector4;
  52452. backUVs?: Vector4;
  52453. }, scene?: Nullable<Scene>): Mesh;
  52454. /**
  52455. * Creates a torus knot mesh
  52456. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  52457. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  52458. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  52459. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  52460. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52461. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52462. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52463. * @param name defines the name of the mesh
  52464. * @param options defines the options used to create the mesh
  52465. * @param scene defines the hosting scene
  52466. * @returns the torus knot mesh
  52467. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  52468. */
  52469. static CreateTorusKnot(name: string, options: {
  52470. radius?: number;
  52471. tube?: number;
  52472. radialSegments?: number;
  52473. tubularSegments?: number;
  52474. p?: number;
  52475. q?: number;
  52476. updatable?: boolean;
  52477. sideOrientation?: number;
  52478. frontUVs?: Vector4;
  52479. backUVs?: Vector4;
  52480. }, scene?: Nullable<Scene>): Mesh;
  52481. /**
  52482. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  52483. * * 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
  52484. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  52485. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  52486. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  52487. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  52488. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  52489. * * 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
  52490. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  52491. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52492. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  52493. * @param name defines the name of the new line system
  52494. * @param options defines the options used to create the line system
  52495. * @param scene defines the hosting scene
  52496. * @returns a new line system mesh
  52497. */
  52498. static CreateLineSystem(name: string, options: {
  52499. lines: Vector3[][];
  52500. updatable?: boolean;
  52501. instance?: Nullable<LinesMesh>;
  52502. colors?: Nullable<Color4[][]>;
  52503. useVertexAlpha?: boolean;
  52504. }, scene: Nullable<Scene>): LinesMesh;
  52505. /**
  52506. * Creates a line mesh
  52507. * 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
  52508. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52509. * * The parameter `points` is an array successive Vector3
  52510. * * 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
  52511. * * The optional parameter `colors` is an array of successive Color4, one per line point
  52512. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  52513. * * When updating an instance, remember that only point positions can change, not the number of points
  52514. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52515. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  52516. * @param name defines the name of the new line system
  52517. * @param options defines the options used to create the line system
  52518. * @param scene defines the hosting scene
  52519. * @returns a new line mesh
  52520. */
  52521. static CreateLines(name: string, options: {
  52522. points: Vector3[];
  52523. updatable?: boolean;
  52524. instance?: Nullable<LinesMesh>;
  52525. colors?: Color4[];
  52526. useVertexAlpha?: boolean;
  52527. }, scene?: Nullable<Scene>): LinesMesh;
  52528. /**
  52529. * Creates a dashed line mesh
  52530. * * 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
  52531. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  52532. * * The parameter `points` is an array successive Vector3
  52533. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  52534. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  52535. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  52536. * * 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
  52537. * * When updating an instance, remember that only point positions can change, not the number of points
  52538. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52539. * @param name defines the name of the mesh
  52540. * @param options defines the options used to create the mesh
  52541. * @param scene defines the hosting scene
  52542. * @returns the dashed line mesh
  52543. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  52544. */
  52545. static CreateDashedLines(name: string, options: {
  52546. points: Vector3[];
  52547. dashSize?: number;
  52548. gapSize?: number;
  52549. dashNb?: number;
  52550. updatable?: boolean;
  52551. instance?: LinesMesh;
  52552. }, scene?: Nullable<Scene>): LinesMesh;
  52553. /**
  52554. * 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.
  52555. * * 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.
  52556. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52557. * * 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.
  52558. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  52559. * * 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
  52560. * * 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
  52561. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  52562. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52563. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52564. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  52565. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52566. * @param name defines the name of the mesh
  52567. * @param options defines the options used to create the mesh
  52568. * @param scene defines the hosting scene
  52569. * @returns the extruded shape mesh
  52570. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52571. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52572. */
  52573. static ExtrudeShape(name: string, options: {
  52574. shape: Vector3[];
  52575. path: Vector3[];
  52576. scale?: number;
  52577. rotation?: number;
  52578. cap?: number;
  52579. updatable?: boolean;
  52580. sideOrientation?: number;
  52581. frontUVs?: Vector4;
  52582. backUVs?: Vector4;
  52583. instance?: Mesh;
  52584. invertUV?: boolean;
  52585. }, scene?: Nullable<Scene>): Mesh;
  52586. /**
  52587. * Creates an custom extruded shape mesh.
  52588. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  52589. * * 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.
  52590. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  52591. * * 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
  52592. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  52593. * * 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
  52594. * * It must returns a float value that will be the scale value applied to the shape on each path point
  52595. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  52596. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  52597. * * 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
  52598. * * 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
  52599. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  52600. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52601. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52602. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52603. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52604. * @param name defines the name of the mesh
  52605. * @param options defines the options used to create the mesh
  52606. * @param scene defines the hosting scene
  52607. * @returns the custom extruded shape mesh
  52608. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  52609. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52610. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  52611. */
  52612. static ExtrudeShapeCustom(name: string, options: {
  52613. shape: Vector3[];
  52614. path: Vector3[];
  52615. scaleFunction?: any;
  52616. rotationFunction?: any;
  52617. ribbonCloseArray?: boolean;
  52618. ribbonClosePath?: boolean;
  52619. cap?: number;
  52620. updatable?: boolean;
  52621. sideOrientation?: number;
  52622. frontUVs?: Vector4;
  52623. backUVs?: Vector4;
  52624. instance?: Mesh;
  52625. invertUV?: boolean;
  52626. }, scene?: Nullable<Scene>): Mesh;
  52627. /**
  52628. * Creates lathe mesh.
  52629. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  52630. * * 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
  52631. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  52632. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  52633. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  52634. * * 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
  52635. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  52636. * * 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
  52637. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52638. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52639. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52640. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52641. * @param name defines the name of the mesh
  52642. * @param options defines the options used to create the mesh
  52643. * @param scene defines the hosting scene
  52644. * @returns the lathe mesh
  52645. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  52646. */
  52647. static CreateLathe(name: string, options: {
  52648. shape: Vector3[];
  52649. radius?: number;
  52650. tessellation?: number;
  52651. clip?: number;
  52652. arc?: number;
  52653. closed?: boolean;
  52654. updatable?: boolean;
  52655. sideOrientation?: number;
  52656. frontUVs?: Vector4;
  52657. backUVs?: Vector4;
  52658. cap?: number;
  52659. invertUV?: boolean;
  52660. }, scene?: Nullable<Scene>): Mesh;
  52661. /**
  52662. * Creates a plane mesh
  52663. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  52664. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  52665. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  52666. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52667. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52668. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52669. * @param name defines the name of the mesh
  52670. * @param options defines the options used to create the mesh
  52671. * @param scene defines the hosting scene
  52672. * @returns the plane mesh
  52673. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  52674. */
  52675. static CreatePlane(name: string, options: {
  52676. size?: number;
  52677. width?: number;
  52678. height?: number;
  52679. sideOrientation?: number;
  52680. frontUVs?: Vector4;
  52681. backUVs?: Vector4;
  52682. updatable?: boolean;
  52683. sourcePlane?: Plane;
  52684. }, scene?: Nullable<Scene>): Mesh;
  52685. /**
  52686. * Creates a ground mesh
  52687. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  52688. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  52689. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52690. * @param name defines the name of the mesh
  52691. * @param options defines the options used to create the mesh
  52692. * @param scene defines the hosting scene
  52693. * @returns the ground mesh
  52694. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  52695. */
  52696. static CreateGround(name: string, options: {
  52697. width?: number;
  52698. height?: number;
  52699. subdivisions?: number;
  52700. subdivisionsX?: number;
  52701. subdivisionsY?: number;
  52702. updatable?: boolean;
  52703. }, scene?: Nullable<Scene>): Mesh;
  52704. /**
  52705. * Creates a tiled ground mesh
  52706. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  52707. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  52708. * * 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
  52709. * * 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
  52710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52711. * @param name defines the name of the mesh
  52712. * @param options defines the options used to create the mesh
  52713. * @param scene defines the hosting scene
  52714. * @returns the tiled ground mesh
  52715. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  52716. */
  52717. static CreateTiledGround(name: string, options: {
  52718. xmin: number;
  52719. zmin: number;
  52720. xmax: number;
  52721. zmax: number;
  52722. subdivisions?: {
  52723. w: number;
  52724. h: number;
  52725. };
  52726. precision?: {
  52727. w: number;
  52728. h: number;
  52729. };
  52730. updatable?: boolean;
  52731. }, scene?: Nullable<Scene>): Mesh;
  52732. /**
  52733. * Creates a ground mesh from a height map
  52734. * * The parameter `url` sets the URL of the height map image resource.
  52735. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  52736. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  52737. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  52738. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  52739. * * 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.
  52740. * * 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).
  52741. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  52742. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  52743. * @param name defines the name of the mesh
  52744. * @param url defines the url to the height map
  52745. * @param options defines the options used to create the mesh
  52746. * @param scene defines the hosting scene
  52747. * @returns the ground mesh
  52748. * @see https://doc.babylonjs.com/babylon101/height_map
  52749. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  52750. */
  52751. static CreateGroundFromHeightMap(name: string, url: string, options: {
  52752. width?: number;
  52753. height?: number;
  52754. subdivisions?: number;
  52755. minHeight?: number;
  52756. maxHeight?: number;
  52757. colorFilter?: Color3;
  52758. alphaFilter?: number;
  52759. updatable?: boolean;
  52760. onReady?: (mesh: GroundMesh) => void;
  52761. }, scene?: Nullable<Scene>): GroundMesh;
  52762. /**
  52763. * Creates a polygon mesh
  52764. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  52765. * * 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
  52766. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  52767. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52768. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  52769. * * Remember you can only change the shape positions, not their number when updating a polygon
  52770. * @param name defines the name of the mesh
  52771. * @param options defines the options used to create the mesh
  52772. * @param scene defines the hosting scene
  52773. * @param earcutInjection can be used to inject your own earcut reference
  52774. * @returns the polygon mesh
  52775. */
  52776. static CreatePolygon(name: string, options: {
  52777. shape: Vector3[];
  52778. holes?: Vector3[][];
  52779. depth?: number;
  52780. faceUV?: Vector4[];
  52781. faceColors?: Color4[];
  52782. updatable?: boolean;
  52783. sideOrientation?: number;
  52784. frontUVs?: Vector4;
  52785. backUVs?: Vector4;
  52786. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52787. /**
  52788. * Creates an extruded polygon mesh, with depth in the Y direction.
  52789. * * 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)
  52790. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  52791. * @param name defines the name of the mesh
  52792. * @param options defines the options used to create the mesh
  52793. * @param scene defines the hosting scene
  52794. * @param earcutInjection can be used to inject your own earcut reference
  52795. * @returns the polygon mesh
  52796. */
  52797. static ExtrudePolygon(name: string, options: {
  52798. shape: Vector3[];
  52799. holes?: Vector3[][];
  52800. depth?: number;
  52801. faceUV?: Vector4[];
  52802. faceColors?: Color4[];
  52803. updatable?: boolean;
  52804. sideOrientation?: number;
  52805. frontUVs?: Vector4;
  52806. backUVs?: Vector4;
  52807. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  52808. /**
  52809. * Creates a tube mesh.
  52810. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  52811. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  52812. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  52813. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  52814. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  52815. * * 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)
  52816. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  52817. * * 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
  52818. * * 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
  52819. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52820. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52821. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  52822. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52823. * @param name defines the name of the mesh
  52824. * @param options defines the options used to create the mesh
  52825. * @param scene defines the hosting scene
  52826. * @returns the tube mesh
  52827. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  52828. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  52829. */
  52830. static CreateTube(name: string, options: {
  52831. path: Vector3[];
  52832. radius?: number;
  52833. tessellation?: number;
  52834. radiusFunction?: {
  52835. (i: number, distance: number): number;
  52836. };
  52837. cap?: number;
  52838. arc?: number;
  52839. updatable?: boolean;
  52840. sideOrientation?: number;
  52841. frontUVs?: Vector4;
  52842. backUVs?: Vector4;
  52843. instance?: Mesh;
  52844. invertUV?: boolean;
  52845. }, scene?: Nullable<Scene>): Mesh;
  52846. /**
  52847. * Creates a polyhedron mesh
  52848. * * 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
  52849. * * The parameter `size` (positive float, default 1) sets the polygon size
  52850. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  52851. * * 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`
  52852. * * 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
  52853. * * 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)`)
  52854. * * 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
  52855. * * 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
  52856. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  52857. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  52858. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  52859. * @param name defines the name of the mesh
  52860. * @param options defines the options used to create the mesh
  52861. * @param scene defines the hosting scene
  52862. * @returns the polyhedron mesh
  52863. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  52864. */
  52865. static CreatePolyhedron(name: string, options: {
  52866. type?: number;
  52867. size?: number;
  52868. sizeX?: number;
  52869. sizeY?: number;
  52870. sizeZ?: number;
  52871. custom?: any;
  52872. faceUV?: Vector4[];
  52873. faceColors?: Color4[];
  52874. flat?: boolean;
  52875. updatable?: boolean;
  52876. sideOrientation?: number;
  52877. frontUVs?: Vector4;
  52878. backUVs?: Vector4;
  52879. }, scene?: Nullable<Scene>): Mesh;
  52880. /**
  52881. * Creates a decal mesh.
  52882. * 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
  52883. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  52884. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  52885. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  52886. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  52887. * @param name defines the name of the mesh
  52888. * @param sourceMesh defines the mesh where the decal must be applied
  52889. * @param options defines the options used to create the mesh
  52890. * @param scene defines the hosting scene
  52891. * @returns the decal mesh
  52892. * @see https://doc.babylonjs.com/how_to/decals
  52893. */
  52894. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  52895. position?: Vector3;
  52896. normal?: Vector3;
  52897. size?: Vector3;
  52898. angle?: number;
  52899. }): Mesh;
  52900. }
  52901. }
  52902. declare module "babylonjs/Meshes/meshSimplification" {
  52903. import { Mesh } from "babylonjs/Meshes/mesh";
  52904. /**
  52905. * A simplifier interface for future simplification implementations
  52906. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52907. */
  52908. export interface ISimplifier {
  52909. /**
  52910. * Simplification of a given mesh according to the given settings.
  52911. * Since this requires computation, it is assumed that the function runs async.
  52912. * @param settings The settings of the simplification, including quality and distance
  52913. * @param successCallback A callback that will be called after the mesh was simplified.
  52914. * @param errorCallback in case of an error, this callback will be called. optional.
  52915. */
  52916. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  52917. }
  52918. /**
  52919. * Expected simplification settings.
  52920. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  52921. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52922. */
  52923. export interface ISimplificationSettings {
  52924. /**
  52925. * Gets or sets the expected quality
  52926. */
  52927. quality: number;
  52928. /**
  52929. * Gets or sets the distance when this optimized version should be used
  52930. */
  52931. distance: number;
  52932. /**
  52933. * Gets an already optimized mesh
  52934. */
  52935. optimizeMesh?: boolean;
  52936. }
  52937. /**
  52938. * Class used to specify simplification options
  52939. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52940. */
  52941. export class SimplificationSettings implements ISimplificationSettings {
  52942. /** expected quality */
  52943. quality: number;
  52944. /** distance when this optimized version should be used */
  52945. distance: number;
  52946. /** already optimized mesh */
  52947. optimizeMesh?: boolean | undefined;
  52948. /**
  52949. * Creates a SimplificationSettings
  52950. * @param quality expected quality
  52951. * @param distance distance when this optimized version should be used
  52952. * @param optimizeMesh already optimized mesh
  52953. */
  52954. constructor(
  52955. /** expected quality */
  52956. quality: number,
  52957. /** distance when this optimized version should be used */
  52958. distance: number,
  52959. /** already optimized mesh */
  52960. optimizeMesh?: boolean | undefined);
  52961. }
  52962. /**
  52963. * Interface used to define a simplification task
  52964. */
  52965. export interface ISimplificationTask {
  52966. /**
  52967. * Array of settings
  52968. */
  52969. settings: Array<ISimplificationSettings>;
  52970. /**
  52971. * Simplification type
  52972. */
  52973. simplificationType: SimplificationType;
  52974. /**
  52975. * Mesh to simplify
  52976. */
  52977. mesh: Mesh;
  52978. /**
  52979. * Callback called on success
  52980. */
  52981. successCallback?: () => void;
  52982. /**
  52983. * Defines if parallel processing can be used
  52984. */
  52985. parallelProcessing: boolean;
  52986. }
  52987. /**
  52988. * Queue used to order the simplification tasks
  52989. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  52990. */
  52991. export class SimplificationQueue {
  52992. private _simplificationArray;
  52993. /**
  52994. * Gets a boolean indicating that the process is still running
  52995. */
  52996. running: boolean;
  52997. /**
  52998. * Creates a new queue
  52999. */
  53000. constructor();
  53001. /**
  53002. * Adds a new simplification task
  53003. * @param task defines a task to add
  53004. */
  53005. addTask(task: ISimplificationTask): void;
  53006. /**
  53007. * Execute next task
  53008. */
  53009. executeNext(): void;
  53010. /**
  53011. * Execute a simplification task
  53012. * @param task defines the task to run
  53013. */
  53014. runSimplification(task: ISimplificationTask): void;
  53015. private getSimplifier;
  53016. }
  53017. /**
  53018. * The implemented types of simplification
  53019. * At the moment only Quadratic Error Decimation is implemented
  53020. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53021. */
  53022. export enum SimplificationType {
  53023. /** Quadratic error decimation */
  53024. QUADRATIC = 0
  53025. }
  53026. }
  53027. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  53028. import { Scene } from "babylonjs/scene";
  53029. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  53030. import { ISceneComponent } from "babylonjs/sceneComponent";
  53031. module "babylonjs/scene" {
  53032. interface Scene {
  53033. /** @hidden (Backing field) */
  53034. _simplificationQueue: SimplificationQueue;
  53035. /**
  53036. * Gets or sets the simplification queue attached to the scene
  53037. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  53038. */
  53039. simplificationQueue: SimplificationQueue;
  53040. }
  53041. }
  53042. module "babylonjs/Meshes/mesh" {
  53043. interface Mesh {
  53044. /**
  53045. * Simplify the mesh according to the given array of settings.
  53046. * Function will return immediately and will simplify async
  53047. * @param settings a collection of simplification settings
  53048. * @param parallelProcessing should all levels calculate parallel or one after the other
  53049. * @param simplificationType the type of simplification to run
  53050. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  53051. * @returns the current mesh
  53052. */
  53053. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  53054. }
  53055. }
  53056. /**
  53057. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  53058. * created in a scene
  53059. */
  53060. export class SimplicationQueueSceneComponent implements ISceneComponent {
  53061. /**
  53062. * The component name helpfull to identify the component in the list of scene components.
  53063. */
  53064. readonly name: string;
  53065. /**
  53066. * The scene the component belongs to.
  53067. */
  53068. scene: Scene;
  53069. /**
  53070. * Creates a new instance of the component for the given scene
  53071. * @param scene Defines the scene to register the component in
  53072. */
  53073. constructor(scene: Scene);
  53074. /**
  53075. * Registers the component in a given scene
  53076. */
  53077. register(): void;
  53078. /**
  53079. * Rebuilds the elements related to this component in case of
  53080. * context lost for instance.
  53081. */
  53082. rebuild(): void;
  53083. /**
  53084. * Disposes the component and the associated ressources
  53085. */
  53086. dispose(): void;
  53087. private _beforeCameraUpdate;
  53088. }
  53089. }
  53090. declare module "babylonjs/Meshes/Builders/index" {
  53091. export * from "babylonjs/Meshes/Builders/boxBuilder";
  53092. export * from "babylonjs/Meshes/Builders/discBuilder";
  53093. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  53094. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  53095. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  53096. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  53097. export * from "babylonjs/Meshes/Builders/torusBuilder";
  53098. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  53099. export * from "babylonjs/Meshes/Builders/linesBuilder";
  53100. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  53101. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  53102. export * from "babylonjs/Meshes/Builders/latheBuilder";
  53103. export * from "babylonjs/Meshes/Builders/planeBuilder";
  53104. export * from "babylonjs/Meshes/Builders/groundBuilder";
  53105. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  53106. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  53107. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  53108. export * from "babylonjs/Meshes/Builders/decalBuilder";
  53109. }
  53110. declare module "babylonjs/Meshes/index" {
  53111. export * from "babylonjs/Meshes/abstractMesh";
  53112. export * from "babylonjs/Meshes/buffer";
  53113. export * from "babylonjs/Meshes/Compression/index";
  53114. export * from "babylonjs/Meshes/csg";
  53115. export * from "babylonjs/Meshes/geometry";
  53116. export * from "babylonjs/Meshes/groundMesh";
  53117. export * from "babylonjs/Meshes/trailMesh";
  53118. export * from "babylonjs/Meshes/instancedMesh";
  53119. export * from "babylonjs/Meshes/linesMesh";
  53120. export * from "babylonjs/Meshes/mesh";
  53121. export * from "babylonjs/Meshes/mesh.vertexData";
  53122. export * from "babylonjs/Meshes/meshBuilder";
  53123. export * from "babylonjs/Meshes/meshSimplification";
  53124. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  53125. export * from "babylonjs/Meshes/polygonMesh";
  53126. export * from "babylonjs/Meshes/subMesh";
  53127. export * from "babylonjs/Meshes/transformNode";
  53128. export * from "babylonjs/Meshes/Builders/index";
  53129. }
  53130. declare module "babylonjs/Morph/index" {
  53131. export * from "babylonjs/Morph/morphTarget";
  53132. export * from "babylonjs/Morph/morphTargetManager";
  53133. }
  53134. declare module "babylonjs/Offline/database" {
  53135. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  53136. /**
  53137. * Class used to enable access to IndexedDB
  53138. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  53139. */
  53140. export class Database implements IOfflineProvider {
  53141. private _callbackManifestChecked;
  53142. private _currentSceneUrl;
  53143. private _db;
  53144. private _enableSceneOffline;
  53145. private _enableTexturesOffline;
  53146. private _manifestVersionFound;
  53147. private _mustUpdateRessources;
  53148. private _hasReachedQuota;
  53149. private _isSupported;
  53150. private _idbFactory;
  53151. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  53152. private static IsUASupportingBlobStorage;
  53153. /**
  53154. * Gets a boolean indicating if Database storate is enabled (off by default)
  53155. */
  53156. static IDBStorageEnabled: boolean;
  53157. /**
  53158. * Gets a boolean indicating if scene must be saved in the database
  53159. */
  53160. readonly enableSceneOffline: boolean;
  53161. /**
  53162. * Gets a boolean indicating if textures must be saved in the database
  53163. */
  53164. readonly enableTexturesOffline: boolean;
  53165. /**
  53166. * Creates a new Database
  53167. * @param urlToScene defines the url to load the scene
  53168. * @param callbackManifestChecked defines the callback to use when manifest is checked
  53169. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  53170. */
  53171. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  53172. private static _ParseURL;
  53173. private static _ReturnFullUrlLocation;
  53174. private _checkManifestFile;
  53175. /**
  53176. * Open the database and make it available
  53177. * @param successCallback defines the callback to call on success
  53178. * @param errorCallback defines the callback to call on error
  53179. */
  53180. open(successCallback: () => void, errorCallback: () => void): void;
  53181. /**
  53182. * Loads an image from the database
  53183. * @param url defines the url to load from
  53184. * @param image defines the target DOM image
  53185. */
  53186. loadImage(url: string, image: HTMLImageElement): void;
  53187. private _loadImageFromDBAsync;
  53188. private _saveImageIntoDBAsync;
  53189. private _checkVersionFromDB;
  53190. private _loadVersionFromDBAsync;
  53191. private _saveVersionIntoDBAsync;
  53192. /**
  53193. * Loads a file from database
  53194. * @param url defines the URL to load from
  53195. * @param sceneLoaded defines a callback to call on success
  53196. * @param progressCallBack defines a callback to call when progress changed
  53197. * @param errorCallback defines a callback to call on error
  53198. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  53199. */
  53200. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  53201. private _loadFileAsync;
  53202. private _saveFileAsync;
  53203. /**
  53204. * Validates if xhr data is correct
  53205. * @param xhr defines the request to validate
  53206. * @param dataType defines the expected data type
  53207. * @returns true if data is correct
  53208. */
  53209. private static _ValidateXHRData;
  53210. }
  53211. }
  53212. declare module "babylonjs/Offline/index" {
  53213. export * from "babylonjs/Offline/database";
  53214. export * from "babylonjs/Offline/IOfflineProvider";
  53215. }
  53216. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  53217. /** @hidden */
  53218. export var gpuUpdateParticlesPixelShader: {
  53219. name: string;
  53220. shader: string;
  53221. };
  53222. }
  53223. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  53224. /** @hidden */
  53225. export var gpuUpdateParticlesVertexShader: {
  53226. name: string;
  53227. shader: string;
  53228. };
  53229. }
  53230. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  53231. /** @hidden */
  53232. export var clipPlaneFragmentDeclaration2: {
  53233. name: string;
  53234. shader: string;
  53235. };
  53236. }
  53237. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  53238. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  53239. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  53240. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  53241. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  53242. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  53243. /** @hidden */
  53244. export var gpuRenderParticlesPixelShader: {
  53245. name: string;
  53246. shader: string;
  53247. };
  53248. }
  53249. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  53250. /** @hidden */
  53251. export var clipPlaneVertexDeclaration2: {
  53252. name: string;
  53253. shader: string;
  53254. };
  53255. }
  53256. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  53257. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  53258. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  53259. /** @hidden */
  53260. export var gpuRenderParticlesVertexShader: {
  53261. name: string;
  53262. shader: string;
  53263. };
  53264. }
  53265. declare module "babylonjs/Particles/gpuParticleSystem" {
  53266. import { Nullable } from "babylonjs/types";
  53267. import { IAnimatable, IValueGradient, Color3Gradient } from "babylonjs/Misc/tools";
  53268. import { Observable } from "babylonjs/Misc/observable";
  53269. import { Color4, Color3 } from "babylonjs/Maths/math";
  53270. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53271. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  53272. import { Scene, IDisposable } from "babylonjs/scene";
  53273. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  53274. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  53275. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  53276. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  53277. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  53278. /**
  53279. * This represents a GPU particle system in Babylon
  53280. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  53281. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  53282. */
  53283. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  53284. /**
  53285. * The layer mask we are rendering the particles through.
  53286. */
  53287. layerMask: number;
  53288. private _capacity;
  53289. private _activeCount;
  53290. private _currentActiveCount;
  53291. private _accumulatedCount;
  53292. private _renderEffect;
  53293. private _updateEffect;
  53294. private _buffer0;
  53295. private _buffer1;
  53296. private _spriteBuffer;
  53297. private _updateVAO;
  53298. private _renderVAO;
  53299. private _targetIndex;
  53300. private _sourceBuffer;
  53301. private _targetBuffer;
  53302. private _engine;
  53303. private _currentRenderId;
  53304. private _started;
  53305. private _stopped;
  53306. private _timeDelta;
  53307. private _randomTexture;
  53308. private _randomTexture2;
  53309. private _attributesStrideSize;
  53310. private _updateEffectOptions;
  53311. private _randomTextureSize;
  53312. private _actualFrame;
  53313. private readonly _rawTextureWidth;
  53314. /**
  53315. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  53316. */
  53317. static readonly IsSupported: boolean;
  53318. /**
  53319. * An event triggered when the system is disposed.
  53320. */
  53321. onDisposeObservable: Observable<GPUParticleSystem>;
  53322. /**
  53323. * Gets the maximum number of particles active at the same time.
  53324. * @returns The max number of active particles.
  53325. */
  53326. getCapacity(): number;
  53327. /**
  53328. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  53329. * to override the particles.
  53330. */
  53331. forceDepthWrite: boolean;
  53332. /**
  53333. * Gets or set the number of active particles
  53334. */
  53335. activeParticleCount: number;
  53336. private _preWarmDone;
  53337. /**
  53338. * Is this system ready to be used/rendered
  53339. * @return true if the system is ready
  53340. */
  53341. isReady(): boolean;
  53342. /**
  53343. * Gets if the system has been started. (Note: this will still be true after stop is called)
  53344. * @returns True if it has been started, otherwise false.
  53345. */
  53346. isStarted(): boolean;
  53347. /**
  53348. * Starts the particle system and begins to emit
  53349. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  53350. */
  53351. start(delay?: number): void;
  53352. /**
  53353. * Stops the particle system.
  53354. */
  53355. stop(): void;
  53356. /**
  53357. * Remove all active particles
  53358. */
  53359. reset(): void;
  53360. /**
  53361. * Returns the string "GPUParticleSystem"
  53362. * @returns a string containing the class name
  53363. */
  53364. getClassName(): string;
  53365. private _colorGradientsTexture;
  53366. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  53367. /**
  53368. * Adds a new color gradient
  53369. * @param gradient defines the gradient to use (between 0 and 1)
  53370. * @param color1 defines the color to affect to the specified gradient
  53371. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  53372. * @returns the current particle system
  53373. */
  53374. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  53375. /**
  53376. * Remove a specific color gradient
  53377. * @param gradient defines the gradient to remove
  53378. * @returns the current particle system
  53379. */
  53380. removeColorGradient(gradient: number): GPUParticleSystem;
  53381. private _angularSpeedGradientsTexture;
  53382. private _sizeGradientsTexture;
  53383. private _velocityGradientsTexture;
  53384. private _limitVelocityGradientsTexture;
  53385. private _dragGradientsTexture;
  53386. private _addFactorGradient;
  53387. /**
  53388. * Adds a new size gradient
  53389. * @param gradient defines the gradient to use (between 0 and 1)
  53390. * @param factor defines the size factor to affect to the specified gradient
  53391. * @returns the current particle system
  53392. */
  53393. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  53394. /**
  53395. * Remove a specific size gradient
  53396. * @param gradient defines the gradient to remove
  53397. * @returns the current particle system
  53398. */
  53399. removeSizeGradient(gradient: number): GPUParticleSystem;
  53400. /**
  53401. * Adds a new angular speed gradient
  53402. * @param gradient defines the gradient to use (between 0 and 1)
  53403. * @param factor defines the angular speed to affect to the specified gradient
  53404. * @returns the current particle system
  53405. */
  53406. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  53407. /**
  53408. * Remove a specific angular speed gradient
  53409. * @param gradient defines the gradient to remove
  53410. * @returns the current particle system
  53411. */
  53412. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  53413. /**
  53414. * Adds a new velocity gradient
  53415. * @param gradient defines the gradient to use (between 0 and 1)
  53416. * @param factor defines the velocity to affect to the specified gradient
  53417. * @returns the current particle system
  53418. */
  53419. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53420. /**
  53421. * Remove a specific velocity gradient
  53422. * @param gradient defines the gradient to remove
  53423. * @returns the current particle system
  53424. */
  53425. removeVelocityGradient(gradient: number): GPUParticleSystem;
  53426. /**
  53427. * Adds a new limit velocity gradient
  53428. * @param gradient defines the gradient to use (between 0 and 1)
  53429. * @param factor defines the limit velocity value to affect to the specified gradient
  53430. * @returns the current particle system
  53431. */
  53432. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  53433. /**
  53434. * Remove a specific limit velocity gradient
  53435. * @param gradient defines the gradient to remove
  53436. * @returns the current particle system
  53437. */
  53438. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  53439. /**
  53440. * Adds a new drag gradient
  53441. * @param gradient defines the gradient to use (between 0 and 1)
  53442. * @param factor defines the drag value to affect to the specified gradient
  53443. * @returns the current particle system
  53444. */
  53445. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  53446. /**
  53447. * Remove a specific drag gradient
  53448. * @param gradient defines the gradient to remove
  53449. * @returns the current particle system
  53450. */
  53451. removeDragGradient(gradient: number): GPUParticleSystem;
  53452. /**
  53453. * Not supported by GPUParticleSystem
  53454. * @param gradient defines the gradient to use (between 0 and 1)
  53455. * @param factor defines the emit rate value to affect to the specified gradient
  53456. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53457. * @returns the current particle system
  53458. */
  53459. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53460. /**
  53461. * Not supported by GPUParticleSystem
  53462. * @param gradient defines the gradient to remove
  53463. * @returns the current particle system
  53464. */
  53465. removeEmitRateGradient(gradient: number): IParticleSystem;
  53466. /**
  53467. * Not supported by GPUParticleSystem
  53468. * @param gradient defines the gradient to use (between 0 and 1)
  53469. * @param factor defines the start size value to affect to the specified gradient
  53470. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53471. * @returns the current particle system
  53472. */
  53473. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53474. /**
  53475. * Not supported by GPUParticleSystem
  53476. * @param gradient defines the gradient to remove
  53477. * @returns the current particle system
  53478. */
  53479. removeStartSizeGradient(gradient: number): IParticleSystem;
  53480. /**
  53481. * Not supported by GPUParticleSystem
  53482. * @param gradient defines the gradient to use (between 0 and 1)
  53483. * @param min defines the color remap minimal range
  53484. * @param max defines the color remap maximal range
  53485. * @returns the current particle system
  53486. */
  53487. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53488. /**
  53489. * Not supported by GPUParticleSystem
  53490. * @param gradient defines the gradient to remove
  53491. * @returns the current particle system
  53492. */
  53493. removeColorRemapGradient(): IParticleSystem;
  53494. /**
  53495. * Not supported by GPUParticleSystem
  53496. * @param gradient defines the gradient to use (between 0 and 1)
  53497. * @param min defines the alpha remap minimal range
  53498. * @param max defines the alpha remap maximal range
  53499. * @returns the current particle system
  53500. */
  53501. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  53502. /**
  53503. * Not supported by GPUParticleSystem
  53504. * @param gradient defines the gradient to remove
  53505. * @returns the current particle system
  53506. */
  53507. removeAlphaRemapGradient(): IParticleSystem;
  53508. /**
  53509. * Not supported by GPUParticleSystem
  53510. * @param gradient defines the gradient to use (between 0 and 1)
  53511. * @param color defines the color to affect to the specified gradient
  53512. * @returns the current particle system
  53513. */
  53514. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  53515. /**
  53516. * Not supported by GPUParticleSystem
  53517. * @param gradient defines the gradient to remove
  53518. * @returns the current particle system
  53519. */
  53520. removeRampGradient(): IParticleSystem;
  53521. /**
  53522. * Not supported by GPUParticleSystem
  53523. * @returns the list of ramp gradients
  53524. */
  53525. getRampGradients(): Nullable<Array<Color3Gradient>>;
  53526. /**
  53527. * Not supported by GPUParticleSystem
  53528. * Gets or sets a boolean indicating that ramp gradients must be used
  53529. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  53530. */
  53531. useRampGradients: boolean;
  53532. /**
  53533. * Not supported by GPUParticleSystem
  53534. * @param gradient defines the gradient to use (between 0 and 1)
  53535. * @param factor defines the life time factor to affect to the specified gradient
  53536. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  53537. * @returns the current particle system
  53538. */
  53539. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  53540. /**
  53541. * Not supported by GPUParticleSystem
  53542. * @param gradient defines the gradient to remove
  53543. * @returns the current particle system
  53544. */
  53545. removeLifeTimeGradient(gradient: number): IParticleSystem;
  53546. /**
  53547. * Instantiates a GPU particle system.
  53548. * 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.
  53549. * @param name The name of the particle system
  53550. * @param options The options used to create the system
  53551. * @param scene The scene the particle system belongs to
  53552. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  53553. */
  53554. constructor(name: string, options: Partial<{
  53555. capacity: number;
  53556. randomTextureSize: number;
  53557. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  53558. protected _reset(): void;
  53559. private _createUpdateVAO;
  53560. private _createRenderVAO;
  53561. private _initialize;
  53562. /** @hidden */
  53563. _recreateUpdateEffect(): void;
  53564. /** @hidden */
  53565. _recreateRenderEffect(): void;
  53566. /**
  53567. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  53568. * @param preWarm defines if we are in the pre-warmimg phase
  53569. */
  53570. animate(preWarm?: boolean): void;
  53571. private _createFactorGradientTexture;
  53572. private _createSizeGradientTexture;
  53573. private _createAngularSpeedGradientTexture;
  53574. private _createVelocityGradientTexture;
  53575. private _createLimitVelocityGradientTexture;
  53576. private _createDragGradientTexture;
  53577. private _createColorGradientTexture;
  53578. /**
  53579. * Renders the particle system in its current state
  53580. * @param preWarm defines if the system should only update the particles but not render them
  53581. * @returns the current number of particles
  53582. */
  53583. render(preWarm?: boolean): number;
  53584. /**
  53585. * Rebuilds the particle system
  53586. */
  53587. rebuild(): void;
  53588. private _releaseBuffers;
  53589. private _releaseVAOs;
  53590. /**
  53591. * Disposes the particle system and free the associated resources
  53592. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  53593. */
  53594. dispose(disposeTexture?: boolean): void;
  53595. /**
  53596. * Clones the particle system.
  53597. * @param name The name of the cloned object
  53598. * @param newEmitter The new emitter to use
  53599. * @returns the cloned particle system
  53600. */
  53601. clone(name: string, newEmitter: any): GPUParticleSystem;
  53602. /**
  53603. * Serializes the particle system to a JSON object.
  53604. * @returns the JSON object
  53605. */
  53606. serialize(): any;
  53607. /**
  53608. * Parses a JSON object to create a GPU particle system.
  53609. * @param parsedParticleSystem The JSON object to parse
  53610. * @param scene The scene to create the particle system in
  53611. * @param rootUrl The root url to use to load external dependencies like texture
  53612. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  53613. * @returns the parsed GPU particle system
  53614. */
  53615. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  53616. }
  53617. }
  53618. declare module "babylonjs/Particles/particleSystemSet" {
  53619. import { Nullable } from "babylonjs/types";
  53620. import { Color3 } from "babylonjs/Maths/math";
  53621. import { TransformNode } from "babylonjs/Meshes/transformNode";
  53622. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53623. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53624. import { Scene, IDisposable } from "babylonjs/scene";
  53625. /**
  53626. * Represents a set of particle systems working together to create a specific effect
  53627. */
  53628. export class ParticleSystemSet implements IDisposable {
  53629. private _emitterCreationOptions;
  53630. private _emitterNode;
  53631. /**
  53632. * Gets the particle system list
  53633. */
  53634. systems: IParticleSystem[];
  53635. /**
  53636. * Gets the emitter node used with this set
  53637. */
  53638. readonly emitterNode: Nullable<TransformNode>;
  53639. /**
  53640. * Creates a new emitter mesh as a sphere
  53641. * @param options defines the options used to create the sphere
  53642. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  53643. * @param scene defines the hosting scene
  53644. */
  53645. setEmitterAsSphere(options: {
  53646. diameter: number;
  53647. segments: number;
  53648. color: Color3;
  53649. }, renderingGroupId: number, scene: Scene): void;
  53650. /**
  53651. * Starts all particle systems of the set
  53652. * @param emitter defines an optional mesh to use as emitter for the particle systems
  53653. */
  53654. start(emitter?: AbstractMesh): void;
  53655. /**
  53656. * Release all associated resources
  53657. */
  53658. dispose(): void;
  53659. /**
  53660. * Serialize the set into a JSON compatible object
  53661. * @returns a JSON compatible representation of the set
  53662. */
  53663. serialize(): any;
  53664. /**
  53665. * Parse a new ParticleSystemSet from a serialized source
  53666. * @param data defines a JSON compatible representation of the set
  53667. * @param scene defines the hosting scene
  53668. * @param gpu defines if we want GPU particles or CPU particles
  53669. * @returns a new ParticleSystemSet
  53670. */
  53671. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  53672. }
  53673. }
  53674. declare module "babylonjs/Particles/particleHelper" {
  53675. import { Nullable } from "babylonjs/types";
  53676. import { Scene } from "babylonjs/scene";
  53677. import { Vector3 } from "babylonjs/Maths/math";
  53678. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53679. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53680. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  53681. /**
  53682. * This class is made for on one-liner static method to help creating particle system set.
  53683. */
  53684. export class ParticleHelper {
  53685. /**
  53686. * Gets or sets base Assets URL
  53687. */
  53688. static BaseAssetsUrl: string;
  53689. /**
  53690. * Create a default particle system that you can tweak
  53691. * @param emitter defines the emitter to use
  53692. * @param capacity defines the system capacity (default is 500 particles)
  53693. * @param scene defines the hosting scene
  53694. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  53695. * @returns the new Particle system
  53696. */
  53697. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  53698. /**
  53699. * This is the main static method (one-liner) of this helper to create different particle systems
  53700. * @param type This string represents the type to the particle system to create
  53701. * @param scene The scene where the particle system should live
  53702. * @param gpu If the system will use gpu
  53703. * @returns the ParticleSystemSet created
  53704. */
  53705. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  53706. /**
  53707. * Static function used to export a particle system to a ParticleSystemSet variable.
  53708. * Please note that the emitter shape is not exported
  53709. * @param systems defines the particle systems to export
  53710. * @returns the created particle system set
  53711. */
  53712. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  53713. }
  53714. }
  53715. declare module "babylonjs/Particles/particleSystemComponent" {
  53716. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  53717. import { Effect, EffectFallbacks } from "babylonjs/Materials/effect";
  53718. import "babylonjs/Shaders/particles.vertex";
  53719. module "babylonjs/Engines/engine" {
  53720. interface Engine {
  53721. /**
  53722. * Create an effect to use with particle systems.
  53723. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  53724. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  53725. * @param uniformsNames defines a list of attribute names
  53726. * @param samplers defines an array of string used to represent textures
  53727. * @param defines defines the string containing the defines to use to compile the shaders
  53728. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  53729. * @param onCompiled defines a function to call when the effect creation is successful
  53730. * @param onError defines a function to call when the effect creation has failed
  53731. * @returns the new Effect
  53732. */
  53733. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  53734. }
  53735. }
  53736. module "babylonjs/Meshes/mesh" {
  53737. interface Mesh {
  53738. /**
  53739. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  53740. * @returns an array of IParticleSystem
  53741. */
  53742. getEmittedParticleSystems(): IParticleSystem[];
  53743. /**
  53744. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  53745. * @returns an array of IParticleSystem
  53746. */
  53747. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  53748. }
  53749. }
  53750. /**
  53751. * @hidden
  53752. */
  53753. export var _IDoNeedToBeInTheBuild: number;
  53754. }
  53755. declare module "babylonjs/Particles/index" {
  53756. export * from "babylonjs/Particles/baseParticleSystem";
  53757. export * from "babylonjs/Particles/EmitterTypes/index";
  53758. export * from "babylonjs/Particles/gpuParticleSystem";
  53759. export * from "babylonjs/Particles/IParticleSystem";
  53760. export * from "babylonjs/Particles/particle";
  53761. export * from "babylonjs/Particles/particleHelper";
  53762. export * from "babylonjs/Particles/particleSystem";
  53763. export * from "babylonjs/Particles/particleSystemComponent";
  53764. export * from "babylonjs/Particles/particleSystemSet";
  53765. export * from "babylonjs/Particles/solidParticle";
  53766. export * from "babylonjs/Particles/solidParticleSystem";
  53767. export * from "babylonjs/Particles/subEmitter";
  53768. }
  53769. declare module "babylonjs/Physics/physicsEngineComponent" {
  53770. import { Nullable } from "babylonjs/types";
  53771. import { Observable, Observer } from "babylonjs/Misc/observable";
  53772. import { Vector3 } from "babylonjs/Maths/math";
  53773. import { Mesh } from "babylonjs/Meshes/mesh";
  53774. import { ISceneComponent } from "babylonjs/sceneComponent";
  53775. import { Scene } from "babylonjs/scene";
  53776. import { Node } from "babylonjs/node";
  53777. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53778. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53779. module "babylonjs/scene" {
  53780. interface Scene {
  53781. /** @hidden (Backing field) */
  53782. _physicsEngine: Nullable<IPhysicsEngine>;
  53783. /**
  53784. * Gets the current physics engine
  53785. * @returns a IPhysicsEngine or null if none attached
  53786. */
  53787. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  53788. /**
  53789. * Enables physics to the current scene
  53790. * @param gravity defines the scene's gravity for the physics engine
  53791. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  53792. * @return a boolean indicating if the physics engine was initialized
  53793. */
  53794. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  53795. /**
  53796. * Disables and disposes the physics engine associated with the scene
  53797. */
  53798. disablePhysicsEngine(): void;
  53799. /**
  53800. * Gets a boolean indicating if there is an active physics engine
  53801. * @returns a boolean indicating if there is an active physics engine
  53802. */
  53803. isPhysicsEnabled(): boolean;
  53804. /**
  53805. * Deletes a physics compound impostor
  53806. * @param compound defines the compound to delete
  53807. */
  53808. deleteCompoundImpostor(compound: any): void;
  53809. /**
  53810. * An event triggered when physic simulation is about to be run
  53811. */
  53812. onBeforePhysicsObservable: Observable<Scene>;
  53813. /**
  53814. * An event triggered when physic simulation has been done
  53815. */
  53816. onAfterPhysicsObservable: Observable<Scene>;
  53817. }
  53818. }
  53819. module "babylonjs/Meshes/abstractMesh" {
  53820. interface AbstractMesh {
  53821. /** @hidden */
  53822. _physicsImpostor: Nullable<PhysicsImpostor>;
  53823. /**
  53824. * Gets or sets impostor used for physic simulation
  53825. * @see http://doc.babylonjs.com/features/physics_engine
  53826. */
  53827. physicsImpostor: Nullable<PhysicsImpostor>;
  53828. /**
  53829. * Gets the current physics impostor
  53830. * @see http://doc.babylonjs.com/features/physics_engine
  53831. * @returns a physics impostor or null
  53832. */
  53833. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  53834. /** Apply a physic impulse to the mesh
  53835. * @param force defines the force to apply
  53836. * @param contactPoint defines where to apply the force
  53837. * @returns the current mesh
  53838. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  53839. */
  53840. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  53841. /**
  53842. * Creates a physic joint between two meshes
  53843. * @param otherMesh defines the other mesh to use
  53844. * @param pivot1 defines the pivot to use on this mesh
  53845. * @param pivot2 defines the pivot to use on the other mesh
  53846. * @param options defines additional options (can be plugin dependent)
  53847. * @returns the current mesh
  53848. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  53849. */
  53850. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  53851. /** @hidden */
  53852. _disposePhysicsObserver: Nullable<Observer<Node>>;
  53853. }
  53854. }
  53855. /**
  53856. * Defines the physics engine scene component responsible to manage a physics engine
  53857. */
  53858. export class PhysicsEngineSceneComponent implements ISceneComponent {
  53859. /**
  53860. * The component name helpful to identify the component in the list of scene components.
  53861. */
  53862. readonly name: string;
  53863. /**
  53864. * The scene the component belongs to.
  53865. */
  53866. scene: Scene;
  53867. /**
  53868. * Creates a new instance of the component for the given scene
  53869. * @param scene Defines the scene to register the component in
  53870. */
  53871. constructor(scene: Scene);
  53872. /**
  53873. * Registers the component in a given scene
  53874. */
  53875. register(): void;
  53876. /**
  53877. * Rebuilds the elements related to this component in case of
  53878. * context lost for instance.
  53879. */
  53880. rebuild(): void;
  53881. /**
  53882. * Disposes the component and the associated ressources
  53883. */
  53884. dispose(): void;
  53885. }
  53886. }
  53887. declare module "babylonjs/Physics/physicsHelper" {
  53888. import { Nullable } from "babylonjs/types";
  53889. import { Vector3 } from "babylonjs/Maths/math";
  53890. import { Mesh } from "babylonjs/Meshes/mesh";
  53891. import { Scene } from "babylonjs/scene";
  53892. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53893. /**
  53894. * A helper for physics simulations
  53895. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  53896. */
  53897. export class PhysicsHelper {
  53898. private _scene;
  53899. private _physicsEngine;
  53900. /**
  53901. * Initializes the Physics helper
  53902. * @param scene Babylon.js scene
  53903. */
  53904. constructor(scene: Scene);
  53905. /**
  53906. * Applies a radial explosion impulse
  53907. * @param origin the origin of the explosion
  53908. * @param radiusOrEventOptions the radius or the options of radial explosion
  53909. * @param strength the explosion strength
  53910. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53911. * @returns A physics radial explosion event, or null
  53912. */
  53913. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53914. /**
  53915. * Applies a radial explosion force
  53916. * @param origin the origin of the explosion
  53917. * @param radiusOrEventOptions the radius or the options of radial explosion
  53918. * @param strength the explosion strength
  53919. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53920. * @returns A physics radial explosion event, or null
  53921. */
  53922. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  53923. /**
  53924. * Creates a gravitational field
  53925. * @param origin the origin of the explosion
  53926. * @param radiusOrEventOptions the radius or the options of radial explosion
  53927. * @param strength the explosion strength
  53928. * @param falloff possible options: Constant & Linear. Defaults to Constant
  53929. * @returns A physics gravitational field event, or null
  53930. */
  53931. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  53932. /**
  53933. * Creates a physics updraft event
  53934. * @param origin the origin of the updraft
  53935. * @param radiusOrEventOptions the radius or the options of the updraft
  53936. * @param strength the strength of the updraft
  53937. * @param height the height of the updraft
  53938. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  53939. * @returns A physics updraft event, or null
  53940. */
  53941. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  53942. /**
  53943. * Creates a physics vortex event
  53944. * @param origin the of the vortex
  53945. * @param radiusOrEventOptions the radius or the options of the vortex
  53946. * @param strength the strength of the vortex
  53947. * @param height the height of the vortex
  53948. * @returns a Physics vortex event, or null
  53949. * A physics vortex event or null
  53950. */
  53951. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  53952. }
  53953. /**
  53954. * Represents a physics radial explosion event
  53955. */
  53956. class PhysicsRadialExplosionEvent {
  53957. private _scene;
  53958. private _options;
  53959. private _sphere;
  53960. private _dataFetched;
  53961. /**
  53962. * Initializes a radial explosioin event
  53963. * @param _scene BabylonJS scene
  53964. * @param _options The options for the vortex event
  53965. */
  53966. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  53967. /**
  53968. * Returns the data related to the radial explosion event (sphere).
  53969. * @returns The radial explosion event data
  53970. */
  53971. getData(): PhysicsRadialExplosionEventData;
  53972. /**
  53973. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  53974. * @param impostor A physics imposter
  53975. * @param origin the origin of the explosion
  53976. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  53977. */
  53978. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  53979. /**
  53980. * Triggers affecterd impostors callbacks
  53981. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  53982. */
  53983. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  53984. /**
  53985. * Disposes the sphere.
  53986. * @param force Specifies if the sphere should be disposed by force
  53987. */
  53988. dispose(force?: boolean): void;
  53989. /*** Helpers ***/
  53990. private _prepareSphere;
  53991. private _intersectsWithSphere;
  53992. }
  53993. /**
  53994. * Represents a gravitational field event
  53995. */
  53996. class PhysicsGravitationalFieldEvent {
  53997. private _physicsHelper;
  53998. private _scene;
  53999. private _origin;
  54000. private _options;
  54001. private _tickCallback;
  54002. private _sphere;
  54003. private _dataFetched;
  54004. /**
  54005. * Initializes the physics gravitational field event
  54006. * @param _physicsHelper A physics helper
  54007. * @param _scene BabylonJS scene
  54008. * @param _origin The origin position of the gravitational field event
  54009. * @param _options The options for the vortex event
  54010. */
  54011. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  54012. /**
  54013. * Returns the data related to the gravitational field event (sphere).
  54014. * @returns A gravitational field event
  54015. */
  54016. getData(): PhysicsGravitationalFieldEventData;
  54017. /**
  54018. * Enables the gravitational field.
  54019. */
  54020. enable(): void;
  54021. /**
  54022. * Disables the gravitational field.
  54023. */
  54024. disable(): void;
  54025. /**
  54026. * Disposes the sphere.
  54027. * @param force The force to dispose from the gravitational field event
  54028. */
  54029. dispose(force?: boolean): void;
  54030. private _tick;
  54031. }
  54032. /**
  54033. * Represents a physics updraft event
  54034. */
  54035. class PhysicsUpdraftEvent {
  54036. private _scene;
  54037. private _origin;
  54038. private _options;
  54039. private _physicsEngine;
  54040. private _originTop;
  54041. private _originDirection;
  54042. private _tickCallback;
  54043. private _cylinder;
  54044. private _cylinderPosition;
  54045. private _dataFetched;
  54046. /**
  54047. * Initializes the physics updraft event
  54048. * @param _scene BabylonJS scene
  54049. * @param _origin The origin position of the updraft
  54050. * @param _options The options for the updraft event
  54051. */
  54052. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  54053. /**
  54054. * Returns the data related to the updraft event (cylinder).
  54055. * @returns A physics updraft event
  54056. */
  54057. getData(): PhysicsUpdraftEventData;
  54058. /**
  54059. * Enables the updraft.
  54060. */
  54061. enable(): void;
  54062. /**
  54063. * Disables the updraft.
  54064. */
  54065. disable(): void;
  54066. /**
  54067. * Disposes the cylinder.
  54068. * @param force Specifies if the updraft should be disposed by force
  54069. */
  54070. dispose(force?: boolean): void;
  54071. private getImpostorHitData;
  54072. private _tick;
  54073. /*** Helpers ***/
  54074. private _prepareCylinder;
  54075. private _intersectsWithCylinder;
  54076. }
  54077. /**
  54078. * Represents a physics vortex event
  54079. */
  54080. class PhysicsVortexEvent {
  54081. private _scene;
  54082. private _origin;
  54083. private _options;
  54084. private _physicsEngine;
  54085. private _originTop;
  54086. private _tickCallback;
  54087. private _cylinder;
  54088. private _cylinderPosition;
  54089. private _dataFetched;
  54090. /**
  54091. * Initializes the physics vortex event
  54092. * @param _scene The BabylonJS scene
  54093. * @param _origin The origin position of the vortex
  54094. * @param _options The options for the vortex event
  54095. */
  54096. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  54097. /**
  54098. * Returns the data related to the vortex event (cylinder).
  54099. * @returns The physics vortex event data
  54100. */
  54101. getData(): PhysicsVortexEventData;
  54102. /**
  54103. * Enables the vortex.
  54104. */
  54105. enable(): void;
  54106. /**
  54107. * Disables the cortex.
  54108. */
  54109. disable(): void;
  54110. /**
  54111. * Disposes the sphere.
  54112. * @param force
  54113. */
  54114. dispose(force?: boolean): void;
  54115. private getImpostorHitData;
  54116. private _tick;
  54117. /*** Helpers ***/
  54118. private _prepareCylinder;
  54119. private _intersectsWithCylinder;
  54120. }
  54121. /**
  54122. * Options fot the radial explosion event
  54123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54124. */
  54125. export class PhysicsRadialExplosionEventOptions {
  54126. /**
  54127. * The radius of the sphere for the radial explosion.
  54128. */
  54129. radius: number;
  54130. /**
  54131. * The strenth of the explosion.
  54132. */
  54133. strength: number;
  54134. /**
  54135. * The strenght of the force in correspondence to the distance of the affected object
  54136. */
  54137. falloff: PhysicsRadialImpulseFalloff;
  54138. /**
  54139. * Sphere options for the radial explosion.
  54140. */
  54141. sphere: {
  54142. segments: number;
  54143. diameter: number;
  54144. };
  54145. /**
  54146. * Sphere options for the radial explosion.
  54147. */
  54148. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  54149. }
  54150. /**
  54151. * Options fot the updraft event
  54152. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54153. */
  54154. export class PhysicsUpdraftEventOptions {
  54155. /**
  54156. * The radius of the cylinder for the vortex
  54157. */
  54158. radius: number;
  54159. /**
  54160. * The strenth of the updraft.
  54161. */
  54162. strength: number;
  54163. /**
  54164. * The height of the cylinder for the updraft.
  54165. */
  54166. height: number;
  54167. /**
  54168. * The mode for the the updraft.
  54169. */
  54170. updraftMode: PhysicsUpdraftMode;
  54171. }
  54172. /**
  54173. * Options fot the vortex event
  54174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54175. */
  54176. export class PhysicsVortexEventOptions {
  54177. /**
  54178. * The radius of the cylinder for the vortex
  54179. */
  54180. radius: number;
  54181. /**
  54182. * The strenth of the vortex.
  54183. */
  54184. strength: number;
  54185. /**
  54186. * The height of the cylinder for the vortex.
  54187. */
  54188. height: number;
  54189. /**
  54190. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  54191. */
  54192. centripetalForceThreshold: number;
  54193. /**
  54194. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  54195. */
  54196. centripetalForceMultiplier: number;
  54197. /**
  54198. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  54199. */
  54200. centrifugalForceMultiplier: number;
  54201. /**
  54202. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  54203. */
  54204. updraftForceMultiplier: number;
  54205. }
  54206. /**
  54207. * The strenght of the force in correspondence to the distance of the affected object
  54208. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54209. */
  54210. export enum PhysicsRadialImpulseFalloff {
  54211. /** Defines that impulse is constant in strength across it's whole radius */
  54212. Constant = 0,
  54213. /** Defines that impulse gets weaker if it's further from the origin */
  54214. Linear = 1
  54215. }
  54216. /**
  54217. * The strength of the force in correspondence to the distance of the affected object
  54218. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54219. */
  54220. export enum PhysicsUpdraftMode {
  54221. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  54222. Center = 0,
  54223. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  54224. Perpendicular = 1
  54225. }
  54226. /**
  54227. * Interface for a physics hit data
  54228. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54229. */
  54230. export interface PhysicsHitData {
  54231. /**
  54232. * The force applied at the contact point
  54233. */
  54234. force: Vector3;
  54235. /**
  54236. * The contact point
  54237. */
  54238. contactPoint: Vector3;
  54239. /**
  54240. * The distance from the origin to the contact point
  54241. */
  54242. distanceFromOrigin: number;
  54243. }
  54244. /**
  54245. * Interface for radial explosion event data
  54246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54247. */
  54248. export interface PhysicsRadialExplosionEventData {
  54249. /**
  54250. * A sphere used for the radial explosion event
  54251. */
  54252. sphere: Mesh;
  54253. }
  54254. /**
  54255. * Interface for gravitational field event data
  54256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54257. */
  54258. export interface PhysicsGravitationalFieldEventData {
  54259. /**
  54260. * A sphere mesh used for the gravitational field event
  54261. */
  54262. sphere: Mesh;
  54263. }
  54264. /**
  54265. * Interface for updraft event data
  54266. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54267. */
  54268. export interface PhysicsUpdraftEventData {
  54269. /**
  54270. * A cylinder used for the updraft event
  54271. */
  54272. cylinder: Mesh;
  54273. }
  54274. /**
  54275. * Interface for vortex event data
  54276. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54277. */
  54278. export interface PhysicsVortexEventData {
  54279. /**
  54280. * A cylinder used for the vortex event
  54281. */
  54282. cylinder: Mesh;
  54283. }
  54284. /**
  54285. * Interface for an affected physics impostor
  54286. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  54287. */
  54288. export interface PhysicsAffectedImpostorWithData {
  54289. /**
  54290. * The impostor affected by the effect
  54291. */
  54292. impostor: PhysicsImpostor;
  54293. /**
  54294. * The data about the hit/horce from the explosion
  54295. */
  54296. hitData: PhysicsHitData;
  54297. }
  54298. }
  54299. declare module "babylonjs/Physics/Plugins/index" {
  54300. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  54301. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  54302. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  54303. }
  54304. declare module "babylonjs/Physics/index" {
  54305. export * from "babylonjs/Physics/IPhysicsEngine";
  54306. export * from "babylonjs/Physics/physicsEngine";
  54307. export * from "babylonjs/Physics/physicsEngineComponent";
  54308. export * from "babylonjs/Physics/physicsHelper";
  54309. export * from "babylonjs/Physics/physicsImpostor";
  54310. export * from "babylonjs/Physics/physicsJoint";
  54311. export * from "babylonjs/Physics/Plugins/index";
  54312. }
  54313. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  54314. /** @hidden */
  54315. export var blackAndWhitePixelShader: {
  54316. name: string;
  54317. shader: string;
  54318. };
  54319. }
  54320. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  54321. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54322. import { Camera } from "babylonjs/Cameras/camera";
  54323. import { Engine } from "babylonjs/Engines/engine";
  54324. import "babylonjs/Shaders/blackAndWhite.fragment";
  54325. /**
  54326. * Post process used to render in black and white
  54327. */
  54328. export class BlackAndWhitePostProcess extends PostProcess {
  54329. /**
  54330. * Linear about to convert he result to black and white (default: 1)
  54331. */
  54332. degree: number;
  54333. /**
  54334. * Creates a black and white post process
  54335. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  54336. * @param name The name of the effect.
  54337. * @param options The required width/height ratio to downsize to before computing the render pass.
  54338. * @param camera The camera to apply the render pass to.
  54339. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54340. * @param engine The engine which the post process will be applied. (default: current engine)
  54341. * @param reusable If the post process can be reused on the same frame. (default: false)
  54342. */
  54343. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54344. }
  54345. }
  54346. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  54347. import { Nullable } from "babylonjs/types";
  54348. import { Camera } from "babylonjs/Cameras/camera";
  54349. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54350. import { Engine } from "babylonjs/Engines/engine";
  54351. /**
  54352. * This represents a set of one or more post processes in Babylon.
  54353. * A post process can be used to apply a shader to a texture after it is rendered.
  54354. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  54355. */
  54356. export class PostProcessRenderEffect {
  54357. private _postProcesses;
  54358. private _getPostProcesses;
  54359. private _singleInstance;
  54360. private _cameras;
  54361. private _indicesForCamera;
  54362. /**
  54363. * Name of the effect
  54364. * @hidden
  54365. */
  54366. _name: string;
  54367. /**
  54368. * Instantiates a post process render effect.
  54369. * A post process can be used to apply a shader to a texture after it is rendered.
  54370. * @param engine The engine the effect is tied to
  54371. * @param name The name of the effect
  54372. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  54373. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  54374. */
  54375. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  54376. /**
  54377. * Checks if all the post processes in the effect are supported.
  54378. */
  54379. readonly isSupported: boolean;
  54380. /**
  54381. * Updates the current state of the effect
  54382. * @hidden
  54383. */
  54384. _update(): void;
  54385. /**
  54386. * Attaches the effect on cameras
  54387. * @param cameras The camera to attach to.
  54388. * @hidden
  54389. */
  54390. _attachCameras(cameras: Camera): void;
  54391. /**
  54392. * Attaches the effect on cameras
  54393. * @param cameras The camera to attach to.
  54394. * @hidden
  54395. */
  54396. _attachCameras(cameras: Camera[]): void;
  54397. /**
  54398. * Detatches the effect on cameras
  54399. * @param cameras The camera to detatch from.
  54400. * @hidden
  54401. */
  54402. _detachCameras(cameras: Camera): void;
  54403. /**
  54404. * Detatches the effect on cameras
  54405. * @param cameras The camera to detatch from.
  54406. * @hidden
  54407. */
  54408. _detachCameras(cameras: Camera[]): void;
  54409. /**
  54410. * Enables the effect on given cameras
  54411. * @param cameras The camera to enable.
  54412. * @hidden
  54413. */
  54414. _enable(cameras: Camera): void;
  54415. /**
  54416. * Enables the effect on given cameras
  54417. * @param cameras The camera to enable.
  54418. * @hidden
  54419. */
  54420. _enable(cameras: Nullable<Camera[]>): void;
  54421. /**
  54422. * Disables the effect on the given cameras
  54423. * @param cameras The camera to disable.
  54424. * @hidden
  54425. */
  54426. _disable(cameras: Camera): void;
  54427. /**
  54428. * Disables the effect on the given cameras
  54429. * @param cameras The camera to disable.
  54430. * @hidden
  54431. */
  54432. _disable(cameras: Nullable<Camera[]>): void;
  54433. /**
  54434. * Gets a list of the post processes contained in the effect.
  54435. * @param camera The camera to get the post processes on.
  54436. * @returns The list of the post processes in the effect.
  54437. */
  54438. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  54439. }
  54440. }
  54441. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  54442. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54443. /** @hidden */
  54444. export var extractHighlightsPixelShader: {
  54445. name: string;
  54446. shader: string;
  54447. };
  54448. }
  54449. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  54450. import { Nullable } from "babylonjs/types";
  54451. import { Camera } from "babylonjs/Cameras/camera";
  54452. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54453. import { Engine } from "babylonjs/Engines/engine";
  54454. import "babylonjs/Shaders/extractHighlights.fragment";
  54455. /**
  54456. * 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.
  54457. */
  54458. export class ExtractHighlightsPostProcess extends PostProcess {
  54459. /**
  54460. * The luminance threshold, pixels below this value will be set to black.
  54461. */
  54462. threshold: number;
  54463. /** @hidden */
  54464. _exposure: number;
  54465. /**
  54466. * Post process which has the input texture to be used when performing highlight extraction
  54467. * @hidden
  54468. */
  54469. _inputPostProcess: Nullable<PostProcess>;
  54470. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54471. }
  54472. }
  54473. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  54474. /** @hidden */
  54475. export var bloomMergePixelShader: {
  54476. name: string;
  54477. shader: string;
  54478. };
  54479. }
  54480. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  54481. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54482. import { Nullable } from "babylonjs/types";
  54483. import { Engine } from "babylonjs/Engines/engine";
  54484. import { Camera } from "babylonjs/Cameras/camera";
  54485. import "babylonjs/Shaders/bloomMerge.fragment";
  54486. /**
  54487. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54488. */
  54489. export class BloomMergePostProcess extends PostProcess {
  54490. /** Weight of the bloom to be added to the original input. */
  54491. weight: number;
  54492. /**
  54493. * Creates a new instance of @see BloomMergePostProcess
  54494. * @param name The name of the effect.
  54495. * @param originalFromInput Post process which's input will be used for the merge.
  54496. * @param blurred Blurred highlights post process which's output will be used.
  54497. * @param weight Weight of the bloom to be added to the original input.
  54498. * @param options The required width/height ratio to downsize to before computing the render pass.
  54499. * @param camera The camera to apply the render pass to.
  54500. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54501. * @param engine The engine which the post process will be applied. (default: current engine)
  54502. * @param reusable If the post process can be reused on the same frame. (default: false)
  54503. * @param textureType Type of textures used when performing the post process. (default: 0)
  54504. * @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)
  54505. */
  54506. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  54507. /** Weight of the bloom to be added to the original input. */
  54508. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54509. }
  54510. }
  54511. declare module "babylonjs/PostProcesses/bloomEffect" {
  54512. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54513. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54514. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  54515. import { Camera } from "babylonjs/Cameras/camera";
  54516. import { Scene } from "babylonjs/scene";
  54517. /**
  54518. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  54519. */
  54520. export class BloomEffect extends PostProcessRenderEffect {
  54521. private bloomScale;
  54522. /**
  54523. * @hidden Internal
  54524. */
  54525. _effects: Array<PostProcess>;
  54526. /**
  54527. * @hidden Internal
  54528. */
  54529. _downscale: ExtractHighlightsPostProcess;
  54530. private _blurX;
  54531. private _blurY;
  54532. private _merge;
  54533. /**
  54534. * The luminance threshold to find bright areas of the image to bloom.
  54535. */
  54536. threshold: number;
  54537. /**
  54538. * The strength of the bloom.
  54539. */
  54540. weight: number;
  54541. /**
  54542. * Specifies the size of the bloom blur kernel, relative to the final output size
  54543. */
  54544. kernel: number;
  54545. /**
  54546. * Creates a new instance of @see BloomEffect
  54547. * @param scene The scene the effect belongs to.
  54548. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  54549. * @param bloomKernel The size of the kernel to be used when applying the blur.
  54550. * @param bloomWeight The the strength of bloom.
  54551. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54552. * @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)
  54553. */
  54554. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  54555. /**
  54556. * Disposes each of the internal effects for a given camera.
  54557. * @param camera The camera to dispose the effect on.
  54558. */
  54559. disposeEffects(camera: Camera): void;
  54560. /**
  54561. * @hidden Internal
  54562. */
  54563. _updateEffects(): void;
  54564. /**
  54565. * Internal
  54566. * @returns if all the contained post processes are ready.
  54567. * @hidden
  54568. */
  54569. _isReady(): boolean;
  54570. }
  54571. }
  54572. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  54573. /** @hidden */
  54574. export var chromaticAberrationPixelShader: {
  54575. name: string;
  54576. shader: string;
  54577. };
  54578. }
  54579. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  54580. import { Vector2 } from "babylonjs/Maths/math";
  54581. import { Nullable } from "babylonjs/types";
  54582. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54583. import { Camera } from "babylonjs/Cameras/camera";
  54584. import { Engine } from "babylonjs/Engines/engine";
  54585. import "babylonjs/Shaders/chromaticAberration.fragment";
  54586. /**
  54587. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  54588. */
  54589. export class ChromaticAberrationPostProcess extends PostProcess {
  54590. /**
  54591. * The amount of seperation of rgb channels (default: 30)
  54592. */
  54593. aberrationAmount: number;
  54594. /**
  54595. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  54596. */
  54597. radialIntensity: number;
  54598. /**
  54599. * 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))
  54600. */
  54601. direction: Vector2;
  54602. /**
  54603. * 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))
  54604. */
  54605. centerPosition: Vector2;
  54606. /**
  54607. * Creates a new instance ChromaticAberrationPostProcess
  54608. * @param name The name of the effect.
  54609. * @param screenWidth The width of the screen to apply the effect on.
  54610. * @param screenHeight The height of the screen to apply the effect on.
  54611. * @param options The required width/height ratio to downsize to before computing the render pass.
  54612. * @param camera The camera to apply the render pass to.
  54613. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54614. * @param engine The engine which the post process will be applied. (default: current engine)
  54615. * @param reusable If the post process can be reused on the same frame. (default: false)
  54616. * @param textureType Type of textures used when performing the post process. (default: 0)
  54617. * @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)
  54618. */
  54619. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54620. }
  54621. }
  54622. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  54623. /** @hidden */
  54624. export var circleOfConfusionPixelShader: {
  54625. name: string;
  54626. shader: string;
  54627. };
  54628. }
  54629. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  54630. import { Nullable } from "babylonjs/types";
  54631. import { Engine } from "babylonjs/Engines/engine";
  54632. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54633. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54634. import { Camera } from "babylonjs/Cameras/camera";
  54635. import "babylonjs/Shaders/circleOfConfusion.fragment";
  54636. /**
  54637. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  54638. */
  54639. export class CircleOfConfusionPostProcess extends PostProcess {
  54640. /**
  54641. * 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.
  54642. */
  54643. lensSize: number;
  54644. /**
  54645. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54646. */
  54647. fStop: number;
  54648. /**
  54649. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54650. */
  54651. focusDistance: number;
  54652. /**
  54653. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  54654. */
  54655. focalLength: number;
  54656. private _depthTexture;
  54657. /**
  54658. * Creates a new instance CircleOfConfusionPostProcess
  54659. * @param name The name of the effect.
  54660. * @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.
  54661. * @param options The required width/height ratio to downsize to before computing the render pass.
  54662. * @param camera The camera to apply the render pass to.
  54663. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54664. * @param engine The engine which the post process will be applied. (default: current engine)
  54665. * @param reusable If the post process can be reused on the same frame. (default: false)
  54666. * @param textureType Type of textures used when performing the post process. (default: 0)
  54667. * @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)
  54668. */
  54669. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54670. /**
  54671. * 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.
  54672. */
  54673. depthTexture: RenderTargetTexture;
  54674. }
  54675. }
  54676. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  54677. /** @hidden */
  54678. export var colorCorrectionPixelShader: {
  54679. name: string;
  54680. shader: string;
  54681. };
  54682. }
  54683. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  54684. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54685. import { Engine } from "babylonjs/Engines/engine";
  54686. import { Camera } from "babylonjs/Cameras/camera";
  54687. import "babylonjs/Shaders/colorCorrection.fragment";
  54688. /**
  54689. *
  54690. * This post-process allows the modification of rendered colors by using
  54691. * a 'look-up table' (LUT). This effect is also called Color Grading.
  54692. *
  54693. * The object needs to be provided an url to a texture containing the color
  54694. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  54695. * Use an image editing software to tweak the LUT to match your needs.
  54696. *
  54697. * For an example of a color LUT, see here:
  54698. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  54699. * For explanations on color grading, see here:
  54700. * @see http://udn.epicgames.com/Three/ColorGrading.html
  54701. *
  54702. */
  54703. export class ColorCorrectionPostProcess extends PostProcess {
  54704. private _colorTableTexture;
  54705. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54706. }
  54707. }
  54708. declare module "babylonjs/Shaders/convolution.fragment" {
  54709. /** @hidden */
  54710. export var convolutionPixelShader: {
  54711. name: string;
  54712. shader: string;
  54713. };
  54714. }
  54715. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  54716. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54717. import { Nullable } from "babylonjs/types";
  54718. import { Camera } from "babylonjs/Cameras/camera";
  54719. import { Engine } from "babylonjs/Engines/engine";
  54720. import "babylonjs/Shaders/convolution.fragment";
  54721. /**
  54722. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  54723. * input texture to perform effects such as edge detection or sharpening
  54724. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  54725. */
  54726. export class ConvolutionPostProcess extends PostProcess {
  54727. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54728. kernel: number[];
  54729. /**
  54730. * Creates a new instance ConvolutionPostProcess
  54731. * @param name The name of the effect.
  54732. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  54733. * @param options The required width/height ratio to downsize to before computing the render pass.
  54734. * @param camera The camera to apply the render pass to.
  54735. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54736. * @param engine The engine which the post process will be applied. (default: current engine)
  54737. * @param reusable If the post process can be reused on the same frame. (default: false)
  54738. * @param textureType Type of textures used when performing the post process. (default: 0)
  54739. */
  54740. constructor(name: string,
  54741. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  54742. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  54743. /**
  54744. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54745. */
  54746. static EdgeDetect0Kernel: number[];
  54747. /**
  54748. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54749. */
  54750. static EdgeDetect1Kernel: number[];
  54751. /**
  54752. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54753. */
  54754. static EdgeDetect2Kernel: number[];
  54755. /**
  54756. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54757. */
  54758. static SharpenKernel: number[];
  54759. /**
  54760. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54761. */
  54762. static EmbossKernel: number[];
  54763. /**
  54764. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  54765. */
  54766. static GaussianKernel: number[];
  54767. }
  54768. }
  54769. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  54770. import { Nullable } from "babylonjs/types";
  54771. import { Vector2 } from "babylonjs/Maths/math";
  54772. import { Camera } from "babylonjs/Cameras/camera";
  54773. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54774. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  54775. import { Engine } from "babylonjs/Engines/engine";
  54776. import { Scene } from "babylonjs/scene";
  54777. /**
  54778. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  54779. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  54780. * based on samples that have a large difference in distance than the center pixel.
  54781. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  54782. */
  54783. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  54784. direction: Vector2;
  54785. /**
  54786. * Creates a new instance CircleOfConfusionPostProcess
  54787. * @param name The name of the effect.
  54788. * @param scene The scene the effect belongs to.
  54789. * @param direction The direction the blur should be applied.
  54790. * @param kernel The size of the kernel used to blur.
  54791. * @param options The required width/height ratio to downsize to before computing the render pass.
  54792. * @param camera The camera to apply the render pass to.
  54793. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  54794. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  54795. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54796. * @param engine The engine which the post process will be applied. (default: current engine)
  54797. * @param reusable If the post process can be reused on the same frame. (default: false)
  54798. * @param textureType Type of textures used when performing the post process. (default: 0)
  54799. * @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)
  54800. */
  54801. 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);
  54802. }
  54803. }
  54804. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  54805. /** @hidden */
  54806. export var depthOfFieldMergePixelShader: {
  54807. name: string;
  54808. shader: string;
  54809. };
  54810. }
  54811. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  54812. import { Nullable } from "babylonjs/types";
  54813. import { Camera } from "babylonjs/Cameras/camera";
  54814. import { Effect } from "babylonjs/Materials/effect";
  54815. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54816. import { Engine } from "babylonjs/Engines/engine";
  54817. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  54818. /**
  54819. * Options to be set when merging outputs from the default pipeline.
  54820. */
  54821. export class DepthOfFieldMergePostProcessOptions {
  54822. /**
  54823. * The original image to merge on top of
  54824. */
  54825. originalFromInput: PostProcess;
  54826. /**
  54827. * Parameters to perform the merge of the depth of field effect
  54828. */
  54829. depthOfField?: {
  54830. circleOfConfusion: PostProcess;
  54831. blurSteps: Array<PostProcess>;
  54832. };
  54833. /**
  54834. * Parameters to perform the merge of bloom effect
  54835. */
  54836. bloom?: {
  54837. blurred: PostProcess;
  54838. weight: number;
  54839. };
  54840. }
  54841. /**
  54842. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  54843. */
  54844. export class DepthOfFieldMergePostProcess extends PostProcess {
  54845. private blurSteps;
  54846. /**
  54847. * Creates a new instance of DepthOfFieldMergePostProcess
  54848. * @param name The name of the effect.
  54849. * @param originalFromInput Post process which's input will be used for the merge.
  54850. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  54851. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  54852. * @param options The required width/height ratio to downsize to before computing the render pass.
  54853. * @param camera The camera to apply the render pass to.
  54854. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54855. * @param engine The engine which the post process will be applied. (default: current engine)
  54856. * @param reusable If the post process can be reused on the same frame. (default: false)
  54857. * @param textureType Type of textures used when performing the post process. (default: 0)
  54858. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  54859. */
  54860. constructor(name: string, originalFromInput: PostProcess, circleOfConfusion: PostProcess, blurSteps: Array<PostProcess>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  54861. /**
  54862. * Updates the effect with the current post process compile time values and recompiles the shader.
  54863. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  54864. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  54865. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  54866. * @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
  54867. * @param onCompiled Called when the shader has been compiled.
  54868. * @param onError Called if there is an error when compiling a shader.
  54869. */
  54870. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  54871. }
  54872. }
  54873. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  54874. import { Nullable } from "babylonjs/types";
  54875. import { Camera } from "babylonjs/Cameras/camera";
  54876. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  54877. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  54878. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  54879. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  54880. import { Scene } from "babylonjs/scene";
  54881. /**
  54882. * Specifies the level of max blur that should be applied when using the depth of field effect
  54883. */
  54884. export enum DepthOfFieldEffectBlurLevel {
  54885. /**
  54886. * Subtle blur
  54887. */
  54888. Low = 0,
  54889. /**
  54890. * Medium blur
  54891. */
  54892. Medium = 1,
  54893. /**
  54894. * Large blur
  54895. */
  54896. High = 2
  54897. }
  54898. /**
  54899. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  54900. */
  54901. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  54902. private _circleOfConfusion;
  54903. /**
  54904. * @hidden Internal, blurs from high to low
  54905. */
  54906. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  54907. private _depthOfFieldBlurY;
  54908. private _dofMerge;
  54909. /**
  54910. * @hidden Internal post processes in depth of field effect
  54911. */
  54912. _effects: Array<PostProcess>;
  54913. /**
  54914. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  54915. */
  54916. focalLength: number;
  54917. /**
  54918. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  54919. */
  54920. fStop: number;
  54921. /**
  54922. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  54923. */
  54924. focusDistance: number;
  54925. /**
  54926. * 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.
  54927. */
  54928. lensSize: number;
  54929. /**
  54930. * Creates a new instance DepthOfFieldEffect
  54931. * @param scene The scene the effect belongs to.
  54932. * @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.
  54933. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  54934. * @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)
  54935. */
  54936. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  54937. /**
  54938. * 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.
  54939. */
  54940. depthTexture: RenderTargetTexture;
  54941. /**
  54942. * Disposes each of the internal effects for a given camera.
  54943. * @param camera The camera to dispose the effect on.
  54944. */
  54945. disposeEffects(camera: Camera): void;
  54946. /**
  54947. * @hidden Internal
  54948. */
  54949. _updateEffects(): void;
  54950. /**
  54951. * Internal
  54952. * @returns if all the contained post processes are ready.
  54953. * @hidden
  54954. */
  54955. _isReady(): boolean;
  54956. }
  54957. }
  54958. declare module "babylonjs/Shaders/displayPass.fragment" {
  54959. /** @hidden */
  54960. export var displayPassPixelShader: {
  54961. name: string;
  54962. shader: string;
  54963. };
  54964. }
  54965. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  54966. import { Nullable } from "babylonjs/types";
  54967. import { Camera } from "babylonjs/Cameras/camera";
  54968. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54969. import { Engine } from "babylonjs/Engines/engine";
  54970. import "babylonjs/Shaders/displayPass.fragment";
  54971. /**
  54972. * DisplayPassPostProcess which produces an output the same as it's input
  54973. */
  54974. export class DisplayPassPostProcess extends PostProcess {
  54975. /**
  54976. * Creates the DisplayPassPostProcess
  54977. * @param name The name of the effect.
  54978. * @param options The required width/height ratio to downsize to before computing the render pass.
  54979. * @param camera The camera to apply the render pass to.
  54980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  54981. * @param engine The engine which the post process will be applied. (default: current engine)
  54982. * @param reusable If the post process can be reused on the same frame. (default: false)
  54983. */
  54984. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  54985. }
  54986. }
  54987. declare module "babylonjs/Shaders/filter.fragment" {
  54988. /** @hidden */
  54989. export var filterPixelShader: {
  54990. name: string;
  54991. shader: string;
  54992. };
  54993. }
  54994. declare module "babylonjs/PostProcesses/filterPostProcess" {
  54995. import { Nullable } from "babylonjs/types";
  54996. import { Matrix } from "babylonjs/Maths/math";
  54997. import { Camera } from "babylonjs/Cameras/camera";
  54998. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  54999. import { Engine } from "babylonjs/Engines/engine";
  55000. import "babylonjs/Shaders/filter.fragment";
  55001. /**
  55002. * Applies a kernel filter to the image
  55003. */
  55004. export class FilterPostProcess extends PostProcess {
  55005. /** The matrix to be applied to the image */
  55006. kernelMatrix: Matrix;
  55007. /**
  55008. *
  55009. * @param name The name of the effect.
  55010. * @param kernelMatrix The matrix to be applied to the image
  55011. * @param options The required width/height ratio to downsize to before computing the render pass.
  55012. * @param camera The camera to apply the render pass to.
  55013. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55014. * @param engine The engine which the post process will be applied. (default: current engine)
  55015. * @param reusable If the post process can be reused on the same frame. (default: false)
  55016. */
  55017. constructor(name: string,
  55018. /** The matrix to be applied to the image */
  55019. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55020. }
  55021. }
  55022. declare module "babylonjs/Shaders/fxaa.fragment" {
  55023. /** @hidden */
  55024. export var fxaaPixelShader: {
  55025. name: string;
  55026. shader: string;
  55027. };
  55028. }
  55029. declare module "babylonjs/Shaders/fxaa.vertex" {
  55030. /** @hidden */
  55031. export var fxaaVertexShader: {
  55032. name: string;
  55033. shader: string;
  55034. };
  55035. }
  55036. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  55037. import { Nullable } from "babylonjs/types";
  55038. import { Camera } from "babylonjs/Cameras/camera";
  55039. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55040. import { Engine } from "babylonjs/Engines/engine";
  55041. import "babylonjs/Shaders/fxaa.fragment";
  55042. import "babylonjs/Shaders/fxaa.vertex";
  55043. /**
  55044. * Fxaa post process
  55045. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  55046. */
  55047. export class FxaaPostProcess extends PostProcess {
  55048. /** @hidden */
  55049. texelWidth: number;
  55050. /** @hidden */
  55051. texelHeight: number;
  55052. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55053. private _getDefines;
  55054. }
  55055. }
  55056. declare module "babylonjs/Shaders/grain.fragment" {
  55057. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  55058. /** @hidden */
  55059. export var grainPixelShader: {
  55060. name: string;
  55061. shader: string;
  55062. };
  55063. }
  55064. declare module "babylonjs/PostProcesses/grainPostProcess" {
  55065. import { Nullable } from "babylonjs/types";
  55066. import { Camera } from "babylonjs/Cameras/camera";
  55067. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55068. import { Engine } from "babylonjs/Engines/engine";
  55069. import "babylonjs/Shaders/grain.fragment";
  55070. /**
  55071. * The GrainPostProcess adds noise to the image at mid luminance levels
  55072. */
  55073. export class GrainPostProcess extends PostProcess {
  55074. /**
  55075. * The intensity of the grain added (default: 30)
  55076. */
  55077. intensity: number;
  55078. /**
  55079. * If the grain should be randomized on every frame
  55080. */
  55081. animated: boolean;
  55082. /**
  55083. * Creates a new instance of @see GrainPostProcess
  55084. * @param name The name of the effect.
  55085. * @param options The required width/height ratio to downsize to before computing the render pass.
  55086. * @param camera The camera to apply the render pass to.
  55087. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55088. * @param engine The engine which the post process will be applied. (default: current engine)
  55089. * @param reusable If the post process can be reused on the same frame. (default: false)
  55090. * @param textureType Type of textures used when performing the post process. (default: 0)
  55091. * @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)
  55092. */
  55093. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55094. }
  55095. }
  55096. declare module "babylonjs/Shaders/highlights.fragment" {
  55097. /** @hidden */
  55098. export var highlightsPixelShader: {
  55099. name: string;
  55100. shader: string;
  55101. };
  55102. }
  55103. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  55104. import { Nullable } from "babylonjs/types";
  55105. import { Camera } from "babylonjs/Cameras/camera";
  55106. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55107. import { Engine } from "babylonjs/Engines/engine";
  55108. import "babylonjs/Shaders/highlights.fragment";
  55109. /**
  55110. * Extracts highlights from the image
  55111. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55112. */
  55113. export class HighlightsPostProcess extends PostProcess {
  55114. /**
  55115. * Extracts highlights from the image
  55116. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  55117. * @param name The name of the effect.
  55118. * @param options The required width/height ratio to downsize to before computing the render pass.
  55119. * @param camera The camera to apply the render pass to.
  55120. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55121. * @param engine The engine which the post process will be applied. (default: current engine)
  55122. * @param reusable If the post process can be reused on the same frame. (default: false)
  55123. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  55124. */
  55125. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  55126. }
  55127. }
  55128. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  55129. /** @hidden */
  55130. export var mrtFragmentDeclaration: {
  55131. name: string;
  55132. shader: string;
  55133. };
  55134. }
  55135. declare module "babylonjs/Shaders/geometry.fragment" {
  55136. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  55137. /** @hidden */
  55138. export var geometryPixelShader: {
  55139. name: string;
  55140. shader: string;
  55141. };
  55142. }
  55143. declare module "babylonjs/Shaders/geometry.vertex" {
  55144. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  55145. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  55146. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  55147. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  55148. /** @hidden */
  55149. export var geometryVertexShader: {
  55150. name: string;
  55151. shader: string;
  55152. };
  55153. }
  55154. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  55155. import { Matrix } from "babylonjs/Maths/math";
  55156. import { SubMesh } from "babylonjs/Meshes/subMesh";
  55157. import { Mesh } from "babylonjs/Meshes/mesh";
  55158. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  55159. import { Effect } from "babylonjs/Materials/effect";
  55160. import { Scene } from "babylonjs/scene";
  55161. import "babylonjs/Shaders/geometry.fragment";
  55162. import "babylonjs/Shaders/geometry.vertex";
  55163. /**
  55164. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  55165. */
  55166. export class GeometryBufferRenderer {
  55167. /**
  55168. * Constant used to retrieve the position texture index in the G-Buffer textures array
  55169. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  55170. */
  55171. static readonly POSITION_TEXTURE_TYPE: number;
  55172. /**
  55173. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  55174. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  55175. */
  55176. static readonly VELOCITY_TEXTURE_TYPE: number;
  55177. /**
  55178. * Dictionary used to store the previous transformation matrices of each rendered mesh
  55179. * in order to compute objects velocities when enableVelocity is set to "true"
  55180. * @hidden
  55181. */
  55182. _previousTransformationMatrices: {
  55183. [index: number]: Matrix;
  55184. };
  55185. private _scene;
  55186. private _multiRenderTarget;
  55187. private _ratio;
  55188. private _enablePosition;
  55189. private _enableVelocity;
  55190. private _positionIndex;
  55191. private _velocityIndex;
  55192. protected _effect: Effect;
  55193. protected _cachedDefines: string;
  55194. /**
  55195. * Set the render list (meshes to be rendered) used in the G buffer.
  55196. */
  55197. renderList: Mesh[];
  55198. /**
  55199. * Gets wether or not G buffer are supported by the running hardware.
  55200. * This requires draw buffer supports
  55201. */
  55202. readonly isSupported: boolean;
  55203. /**
  55204. * Returns the index of the given texture type in the G-Buffer textures array
  55205. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  55206. * @returns the index of the given texture type in the G-Buffer textures array
  55207. */
  55208. getTextureIndex(textureType: number): number;
  55209. /**
  55210. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  55211. */
  55212. /**
  55213. * Sets whether or not objects positions are enabled for the G buffer.
  55214. */
  55215. enablePosition: boolean;
  55216. /**
  55217. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  55218. */
  55219. /**
  55220. * Sets wether or not objects velocities are enabled for the G buffer.
  55221. */
  55222. enableVelocity: boolean;
  55223. /**
  55224. * Gets the scene associated with the buffer.
  55225. */
  55226. readonly scene: Scene;
  55227. /**
  55228. * Gets the ratio used by the buffer during its creation.
  55229. * How big is the buffer related to the main canvas.
  55230. */
  55231. readonly ratio: number;
  55232. /** @hidden */
  55233. static _SceneComponentInitialization: (scene: Scene) => void;
  55234. /**
  55235. * Creates a new G Buffer for the scene
  55236. * @param scene The scene the buffer belongs to
  55237. * @param ratio How big is the buffer related to the main canvas.
  55238. */
  55239. constructor(scene: Scene, ratio?: number);
  55240. /**
  55241. * Checks wether everything is ready to render a submesh to the G buffer.
  55242. * @param subMesh the submesh to check readiness for
  55243. * @param useInstances is the mesh drawn using instance or not
  55244. * @returns true if ready otherwise false
  55245. */
  55246. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  55247. /**
  55248. * Gets the current underlying G Buffer.
  55249. * @returns the buffer
  55250. */
  55251. getGBuffer(): MultiRenderTarget;
  55252. /**
  55253. * Gets the number of samples used to render the buffer (anti aliasing).
  55254. */
  55255. /**
  55256. * Sets the number of samples used to render the buffer (anti aliasing).
  55257. */
  55258. samples: number;
  55259. /**
  55260. * Disposes the renderer and frees up associated resources.
  55261. */
  55262. dispose(): void;
  55263. protected _createRenderTargets(): void;
  55264. }
  55265. }
  55266. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  55267. import { Nullable } from "babylonjs/types";
  55268. import { Scene } from "babylonjs/scene";
  55269. import { ISceneComponent } from "babylonjs/sceneComponent";
  55270. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  55271. module "babylonjs/scene" {
  55272. interface Scene {
  55273. /** @hidden (Backing field) */
  55274. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55275. /**
  55276. * Gets or Sets the current geometry buffer associated to the scene.
  55277. */
  55278. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  55279. /**
  55280. * Enables a GeometryBufferRender and associates it with the scene
  55281. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  55282. * @returns the GeometryBufferRenderer
  55283. */
  55284. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  55285. /**
  55286. * Disables the GeometryBufferRender associated with the scene
  55287. */
  55288. disableGeometryBufferRenderer(): void;
  55289. }
  55290. }
  55291. /**
  55292. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  55293. * in several rendering techniques.
  55294. */
  55295. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  55296. /**
  55297. * The component name helpful to identify the component in the list of scene components.
  55298. */
  55299. readonly name: string;
  55300. /**
  55301. * The scene the component belongs to.
  55302. */
  55303. scene: Scene;
  55304. /**
  55305. * Creates a new instance of the component for the given scene
  55306. * @param scene Defines the scene to register the component in
  55307. */
  55308. constructor(scene: Scene);
  55309. /**
  55310. * Registers the component in a given scene
  55311. */
  55312. register(): void;
  55313. /**
  55314. * Rebuilds the elements related to this component in case of
  55315. * context lost for instance.
  55316. */
  55317. rebuild(): void;
  55318. /**
  55319. * Disposes the component and the associated ressources
  55320. */
  55321. dispose(): void;
  55322. private _gatherRenderTargets;
  55323. }
  55324. }
  55325. declare module "babylonjs/Shaders/motionBlur.fragment" {
  55326. /** @hidden */
  55327. export var motionBlurPixelShader: {
  55328. name: string;
  55329. shader: string;
  55330. };
  55331. }
  55332. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  55333. import { Nullable } from "babylonjs/types";
  55334. import { Camera } from "babylonjs/Cameras/camera";
  55335. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55336. import { Scene } from "babylonjs/scene";
  55337. import "babylonjs/Animations/animatable";
  55338. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  55339. import "babylonjs/Shaders/motionBlur.fragment";
  55340. import { Engine } from "babylonjs/Engines/engine";
  55341. /**
  55342. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  55343. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  55344. * As an example, all you have to do is to create the post-process:
  55345. * var mb = new BABYLON.MotionBlurPostProcess(
  55346. * 'mb', // The name of the effect.
  55347. * scene, // The scene containing the objects to blur according to their velocity.
  55348. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  55349. * camera // The camera to apply the render pass to.
  55350. * );
  55351. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  55352. */
  55353. export class MotionBlurPostProcess extends PostProcess {
  55354. /**
  55355. * Defines how much the image is blurred by the movement. Default value is equal to 1
  55356. */
  55357. motionStrength: number;
  55358. /**
  55359. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  55360. */
  55361. /**
  55362. * Sets the number of iterations to be used for motion blur quality
  55363. */
  55364. motionBlurSamples: number;
  55365. private _motionBlurSamples;
  55366. private _geometryBufferRenderer;
  55367. /**
  55368. * Creates a new instance MotionBlurPostProcess
  55369. * @param name The name of the effect.
  55370. * @param scene The scene containing the objects to blur according to their velocity.
  55371. * @param options The required width/height ratio to downsize to before computing the render pass.
  55372. * @param camera The camera to apply the render pass to.
  55373. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55374. * @param engine The engine which the post process will be applied. (default: current engine)
  55375. * @param reusable If the post process can be reused on the same frame. (default: false)
  55376. * @param textureType Type of textures used when performing the post process. (default: 0)
  55377. * @param blockCompilation If compilation of the shader should not be done in the constructor. The updateEffect method can be used to compile the shader at a later time. (default: false)
  55378. */
  55379. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55380. /**
  55381. * Disposes the post process.
  55382. * @param camera The camera to dispose the post process on.
  55383. */
  55384. dispose(camera?: Camera): void;
  55385. }
  55386. }
  55387. declare module "babylonjs/Shaders/refraction.fragment" {
  55388. /** @hidden */
  55389. export var refractionPixelShader: {
  55390. name: string;
  55391. shader: string;
  55392. };
  55393. }
  55394. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  55395. import { Color3 } from "babylonjs/Maths/math";
  55396. import { Camera } from "babylonjs/Cameras/camera";
  55397. import { Texture } from "babylonjs/Materials/Textures/texture";
  55398. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55399. import { Engine } from "babylonjs/Engines/engine";
  55400. import "babylonjs/Shaders/refraction.fragment";
  55401. /**
  55402. * Post process which applies a refractin texture
  55403. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55404. */
  55405. export class RefractionPostProcess extends PostProcess {
  55406. /** the base color of the refraction (used to taint the rendering) */
  55407. color: Color3;
  55408. /** simulated refraction depth */
  55409. depth: number;
  55410. /** the coefficient of the base color (0 to remove base color tainting) */
  55411. colorLevel: number;
  55412. private _refTexture;
  55413. private _ownRefractionTexture;
  55414. /**
  55415. * Gets or sets the refraction texture
  55416. * Please note that you are responsible for disposing the texture if you set it manually
  55417. */
  55418. refractionTexture: Texture;
  55419. /**
  55420. * Initializes the RefractionPostProcess
  55421. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  55422. * @param name The name of the effect.
  55423. * @param refractionTextureUrl Url of the refraction texture to use
  55424. * @param color the base color of the refraction (used to taint the rendering)
  55425. * @param depth simulated refraction depth
  55426. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  55427. * @param camera The camera to apply the render pass to.
  55428. * @param options The required width/height ratio to downsize to before computing the render pass.
  55429. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55430. * @param engine The engine which the post process will be applied. (default: current engine)
  55431. * @param reusable If the post process can be reused on the same frame. (default: false)
  55432. */
  55433. constructor(name: string, refractionTextureUrl: string,
  55434. /** the base color of the refraction (used to taint the rendering) */
  55435. color: Color3,
  55436. /** simulated refraction depth */
  55437. depth: number,
  55438. /** the coefficient of the base color (0 to remove base color tainting) */
  55439. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  55440. /**
  55441. * Disposes of the post process
  55442. * @param camera Camera to dispose post process on
  55443. */
  55444. dispose(camera: Camera): void;
  55445. }
  55446. }
  55447. declare module "babylonjs/Shaders/sharpen.fragment" {
  55448. /** @hidden */
  55449. export var sharpenPixelShader: {
  55450. name: string;
  55451. shader: string;
  55452. };
  55453. }
  55454. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  55455. import { Nullable } from "babylonjs/types";
  55456. import { Camera } from "babylonjs/Cameras/camera";
  55457. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  55458. import "babylonjs/Shaders/sharpen.fragment";
  55459. import { Engine } from "babylonjs/Engines/engine";
  55460. /**
  55461. * The SharpenPostProcess applies a sharpen kernel to every pixel
  55462. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  55463. */
  55464. export class SharpenPostProcess extends PostProcess {
  55465. /**
  55466. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  55467. */
  55468. colorAmount: number;
  55469. /**
  55470. * How much sharpness should be applied (default: 0.3)
  55471. */
  55472. edgeAmount: number;
  55473. /**
  55474. * Creates a new instance ConvolutionPostProcess
  55475. * @param name The name of the effect.
  55476. * @param options The required width/height ratio to downsize to before computing the render pass.
  55477. * @param camera The camera to apply the render pass to.
  55478. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  55479. * @param engine The engine which the post process will be applied. (default: current engine)
  55480. * @param reusable If the post process can be reused on the same frame. (default: false)
  55481. * @param textureType Type of textures used when performing the post process. (default: 0)
  55482. * @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)
  55483. */
  55484. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  55485. }
  55486. }
  55487. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  55488. import { Nullable } from "babylonjs/types";
  55489. import { Camera } from "babylonjs/Cameras/camera";
  55490. import { Engine } from "babylonjs/Engines/engine";
  55491. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  55492. import { IInspectable } from "babylonjs/Misc/iInspectable";
  55493. /**
  55494. * PostProcessRenderPipeline
  55495. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55496. */
  55497. export class PostProcessRenderPipeline {
  55498. private engine;
  55499. private _renderEffects;
  55500. private _renderEffectsForIsolatedPass;
  55501. /**
  55502. * List of inspectable custom properties (used by the Inspector)
  55503. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  55504. */
  55505. inspectableCustomProperties: IInspectable[];
  55506. /**
  55507. * @hidden
  55508. */
  55509. protected _cameras: Camera[];
  55510. /** @hidden */
  55511. _name: string;
  55512. /**
  55513. * Gets pipeline name
  55514. */
  55515. readonly name: string;
  55516. /**
  55517. * Initializes a PostProcessRenderPipeline
  55518. * @param engine engine to add the pipeline to
  55519. * @param name name of the pipeline
  55520. */
  55521. constructor(engine: Engine, name: string);
  55522. /**
  55523. * Gets the class name
  55524. * @returns "PostProcessRenderPipeline"
  55525. */
  55526. getClassName(): string;
  55527. /**
  55528. * If all the render effects in the pipeline are supported
  55529. */
  55530. readonly isSupported: boolean;
  55531. /**
  55532. * Adds an effect to the pipeline
  55533. * @param renderEffect the effect to add
  55534. */
  55535. addEffect(renderEffect: PostProcessRenderEffect): void;
  55536. /** @hidden */
  55537. _rebuild(): void;
  55538. /** @hidden */
  55539. _enableEffect(renderEffectName: string, cameras: Camera): void;
  55540. /** @hidden */
  55541. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  55542. /** @hidden */
  55543. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55544. /** @hidden */
  55545. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  55546. /** @hidden */
  55547. _attachCameras(cameras: Camera, unique: boolean): void;
  55548. /** @hidden */
  55549. _attachCameras(cameras: Camera[], unique: boolean): void;
  55550. /** @hidden */
  55551. _detachCameras(cameras: Camera): void;
  55552. /** @hidden */
  55553. _detachCameras(cameras: Nullable<Camera[]>): void;
  55554. /** @hidden */
  55555. _update(): void;
  55556. /** @hidden */
  55557. _reset(): void;
  55558. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  55559. /**
  55560. * Disposes of the pipeline
  55561. */
  55562. dispose(): void;
  55563. }
  55564. }
  55565. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  55566. import { Camera } from "babylonjs/Cameras/camera";
  55567. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55568. /**
  55569. * PostProcessRenderPipelineManager class
  55570. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55571. */
  55572. export class PostProcessRenderPipelineManager {
  55573. private _renderPipelines;
  55574. /**
  55575. * Initializes a PostProcessRenderPipelineManager
  55576. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55577. */
  55578. constructor();
  55579. /**
  55580. * Gets the list of supported render pipelines
  55581. */
  55582. readonly supportedPipelines: PostProcessRenderPipeline[];
  55583. /**
  55584. * Adds a pipeline to the manager
  55585. * @param renderPipeline The pipeline to add
  55586. */
  55587. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  55588. /**
  55589. * Attaches a camera to the pipeline
  55590. * @param renderPipelineName The name of the pipeline to attach to
  55591. * @param cameras the camera to attach
  55592. * @param unique if the camera can be attached multiple times to the pipeline
  55593. */
  55594. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  55595. /**
  55596. * Detaches a camera from the pipeline
  55597. * @param renderPipelineName The name of the pipeline to detach from
  55598. * @param cameras the camera to detach
  55599. */
  55600. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  55601. /**
  55602. * Enables an effect by name on a pipeline
  55603. * @param renderPipelineName the name of the pipeline to enable the effect in
  55604. * @param renderEffectName the name of the effect to enable
  55605. * @param cameras the cameras that the effect should be enabled on
  55606. */
  55607. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55608. /**
  55609. * Disables an effect by name on a pipeline
  55610. * @param renderPipelineName the name of the pipeline to disable the effect in
  55611. * @param renderEffectName the name of the effect to disable
  55612. * @param cameras the cameras that the effect should be disabled on
  55613. */
  55614. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  55615. /**
  55616. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  55617. */
  55618. update(): void;
  55619. /** @hidden */
  55620. _rebuild(): void;
  55621. /**
  55622. * Disposes of the manager and pipelines
  55623. */
  55624. dispose(): void;
  55625. }
  55626. }
  55627. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  55628. import { ISceneComponent } from "babylonjs/sceneComponent";
  55629. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  55630. import { Scene } from "babylonjs/scene";
  55631. module "babylonjs/scene" {
  55632. interface Scene {
  55633. /** @hidden (Backing field) */
  55634. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55635. /**
  55636. * Gets the postprocess render pipeline manager
  55637. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  55638. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55639. */
  55640. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  55641. }
  55642. }
  55643. /**
  55644. * Defines the Render Pipeline scene component responsible to rendering pipelines
  55645. */
  55646. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  55647. /**
  55648. * The component name helpfull to identify the component in the list of scene components.
  55649. */
  55650. readonly name: string;
  55651. /**
  55652. * The scene the component belongs to.
  55653. */
  55654. scene: Scene;
  55655. /**
  55656. * Creates a new instance of the component for the given scene
  55657. * @param scene Defines the scene to register the component in
  55658. */
  55659. constructor(scene: Scene);
  55660. /**
  55661. * Registers the component in a given scene
  55662. */
  55663. register(): void;
  55664. /**
  55665. * Rebuilds the elements related to this component in case of
  55666. * context lost for instance.
  55667. */
  55668. rebuild(): void;
  55669. /**
  55670. * Disposes the component and the associated ressources
  55671. */
  55672. dispose(): void;
  55673. private _gatherRenderTargets;
  55674. }
  55675. }
  55676. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  55677. import { IAnimatable } from "babylonjs/Misc/tools";
  55678. import { Camera } from "babylonjs/Cameras/camera";
  55679. import { IDisposable } from "babylonjs/scene";
  55680. import { Scene } from "babylonjs/scene";
  55681. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  55682. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  55683. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  55684. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  55685. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  55686. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55687. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  55688. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  55689. import { Animation } from "babylonjs/Animations/animation";
  55690. /**
  55691. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  55692. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  55693. */
  55694. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  55695. private _scene;
  55696. private _camerasToBeAttached;
  55697. /**
  55698. * ID of the sharpen post process,
  55699. */
  55700. private readonly SharpenPostProcessId;
  55701. /**
  55702. * @ignore
  55703. * ID of the image processing post process;
  55704. */
  55705. readonly ImageProcessingPostProcessId: string;
  55706. /**
  55707. * @ignore
  55708. * ID of the Fast Approximate Anti-Aliasing post process;
  55709. */
  55710. readonly FxaaPostProcessId: string;
  55711. /**
  55712. * ID of the chromatic aberration post process,
  55713. */
  55714. private readonly ChromaticAberrationPostProcessId;
  55715. /**
  55716. * ID of the grain post process
  55717. */
  55718. private readonly GrainPostProcessId;
  55719. /**
  55720. * Sharpen post process which will apply a sharpen convolution to enhance edges
  55721. */
  55722. sharpen: SharpenPostProcess;
  55723. private _sharpenEffect;
  55724. private bloom;
  55725. /**
  55726. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  55727. */
  55728. depthOfField: DepthOfFieldEffect;
  55729. /**
  55730. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  55731. */
  55732. fxaa: FxaaPostProcess;
  55733. /**
  55734. * Image post processing pass used to perform operations such as tone mapping or color grading.
  55735. */
  55736. imageProcessing: ImageProcessingPostProcess;
  55737. /**
  55738. * Chromatic aberration post process which will shift rgb colors in the image
  55739. */
  55740. chromaticAberration: ChromaticAberrationPostProcess;
  55741. private _chromaticAberrationEffect;
  55742. /**
  55743. * Grain post process which add noise to the image
  55744. */
  55745. grain: GrainPostProcess;
  55746. private _grainEffect;
  55747. /**
  55748. * Glow post process which adds a glow to emissive areas of the image
  55749. */
  55750. private _glowLayer;
  55751. /**
  55752. * Animations which can be used to tweak settings over a period of time
  55753. */
  55754. animations: Animation[];
  55755. private _imageProcessingConfigurationObserver;
  55756. private _sharpenEnabled;
  55757. private _bloomEnabled;
  55758. private _depthOfFieldEnabled;
  55759. private _depthOfFieldBlurLevel;
  55760. private _fxaaEnabled;
  55761. private _imageProcessingEnabled;
  55762. private _defaultPipelineTextureType;
  55763. private _bloomScale;
  55764. private _chromaticAberrationEnabled;
  55765. private _grainEnabled;
  55766. private _buildAllowed;
  55767. /**
  55768. * Gets active scene
  55769. */
  55770. readonly scene: Scene;
  55771. /**
  55772. * Enable or disable the sharpen process from the pipeline
  55773. */
  55774. sharpenEnabled: boolean;
  55775. private _resizeObserver;
  55776. private _hardwareScaleLevel;
  55777. private _bloomKernel;
  55778. /**
  55779. * Specifies the size of the bloom blur kernel, relative to the final output size
  55780. */
  55781. bloomKernel: number;
  55782. /**
  55783. * Specifies the weight of the bloom in the final rendering
  55784. */
  55785. private _bloomWeight;
  55786. /**
  55787. * Specifies the luma threshold for the area that will be blurred by the bloom
  55788. */
  55789. private _bloomThreshold;
  55790. private _hdr;
  55791. /**
  55792. * The strength of the bloom.
  55793. */
  55794. bloomWeight: number;
  55795. /**
  55796. * The strength of the bloom.
  55797. */
  55798. bloomThreshold: number;
  55799. /**
  55800. * The scale of the bloom, lower value will provide better performance.
  55801. */
  55802. bloomScale: number;
  55803. /**
  55804. * Enable or disable the bloom from the pipeline
  55805. */
  55806. bloomEnabled: boolean;
  55807. private _rebuildBloom;
  55808. /**
  55809. * If the depth of field is enabled.
  55810. */
  55811. depthOfFieldEnabled: boolean;
  55812. /**
  55813. * Blur level of the depth of field effect. (Higher blur will effect performance)
  55814. */
  55815. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  55816. /**
  55817. * If the anti aliasing is enabled.
  55818. */
  55819. fxaaEnabled: boolean;
  55820. private _samples;
  55821. /**
  55822. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  55823. */
  55824. samples: number;
  55825. /**
  55826. * If image processing is enabled.
  55827. */
  55828. imageProcessingEnabled: boolean;
  55829. /**
  55830. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  55831. */
  55832. glowLayerEnabled: boolean;
  55833. /**
  55834. * Enable or disable the chromaticAberration process from the pipeline
  55835. */
  55836. chromaticAberrationEnabled: boolean;
  55837. /**
  55838. * Enable or disable the grain process from the pipeline
  55839. */
  55840. grainEnabled: boolean;
  55841. /**
  55842. * @constructor
  55843. * @param name - The rendering pipeline name (default: "")
  55844. * @param hdr - If high dynamic range textures should be used (default: true)
  55845. * @param scene - The scene linked to this pipeline (default: the last created scene)
  55846. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  55847. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  55848. */
  55849. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  55850. /**
  55851. * Get the class name
  55852. * @returns "DefaultRenderingPipeline"
  55853. */
  55854. getClassName(): string;
  55855. /**
  55856. * Force the compilation of the entire pipeline.
  55857. */
  55858. prepare(): void;
  55859. private _hasCleared;
  55860. private _prevPostProcess;
  55861. private _prevPrevPostProcess;
  55862. private _setAutoClearAndTextureSharing;
  55863. private _depthOfFieldSceneObserver;
  55864. private _buildPipeline;
  55865. private _disposePostProcesses;
  55866. /**
  55867. * Adds a camera to the pipeline
  55868. * @param camera the camera to be added
  55869. */
  55870. addCamera(camera: Camera): void;
  55871. /**
  55872. * Removes a camera from the pipeline
  55873. * @param camera the camera to remove
  55874. */
  55875. removeCamera(camera: Camera): void;
  55876. /**
  55877. * Dispose of the pipeline and stop all post processes
  55878. */
  55879. dispose(): void;
  55880. /**
  55881. * Serialize the rendering pipeline (Used when exporting)
  55882. * @returns the serialized object
  55883. */
  55884. serialize(): any;
  55885. /**
  55886. * Parse the serialized pipeline
  55887. * @param source Source pipeline.
  55888. * @param scene The scene to load the pipeline to.
  55889. * @param rootUrl The URL of the serialized pipeline.
  55890. * @returns An instantiated pipeline from the serialized object.
  55891. */
  55892. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  55893. }
  55894. }
  55895. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  55896. /** @hidden */
  55897. export var lensHighlightsPixelShader: {
  55898. name: string;
  55899. shader: string;
  55900. };
  55901. }
  55902. declare module "babylonjs/Shaders/depthOfField.fragment" {
  55903. /** @hidden */
  55904. export var depthOfFieldPixelShader: {
  55905. name: string;
  55906. shader: string;
  55907. };
  55908. }
  55909. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  55910. import { Camera } from "babylonjs/Cameras/camera";
  55911. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  55912. import { Scene } from "babylonjs/scene";
  55913. import "babylonjs/Shaders/chromaticAberration.fragment";
  55914. import "babylonjs/Shaders/lensHighlights.fragment";
  55915. import "babylonjs/Shaders/depthOfField.fragment";
  55916. /**
  55917. * BABYLON.JS Chromatic Aberration GLSL Shader
  55918. * Author: Olivier Guyot
  55919. * Separates very slightly R, G and B colors on the edges of the screen
  55920. * Inspired by Francois Tarlier & Martins Upitis
  55921. */
  55922. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  55923. /**
  55924. * @ignore
  55925. * The chromatic aberration PostProcess id in the pipeline
  55926. */
  55927. LensChromaticAberrationEffect: string;
  55928. /**
  55929. * @ignore
  55930. * The highlights enhancing PostProcess id in the pipeline
  55931. */
  55932. HighlightsEnhancingEffect: string;
  55933. /**
  55934. * @ignore
  55935. * The depth-of-field PostProcess id in the pipeline
  55936. */
  55937. LensDepthOfFieldEffect: string;
  55938. private _scene;
  55939. private _depthTexture;
  55940. private _grainTexture;
  55941. private _chromaticAberrationPostProcess;
  55942. private _highlightsPostProcess;
  55943. private _depthOfFieldPostProcess;
  55944. private _edgeBlur;
  55945. private _grainAmount;
  55946. private _chromaticAberration;
  55947. private _distortion;
  55948. private _highlightsGain;
  55949. private _highlightsThreshold;
  55950. private _dofDistance;
  55951. private _dofAperture;
  55952. private _dofDarken;
  55953. private _dofPentagon;
  55954. private _blurNoise;
  55955. /**
  55956. * @constructor
  55957. *
  55958. * Effect parameters are as follow:
  55959. * {
  55960. * chromatic_aberration: number; // from 0 to x (1 for realism)
  55961. * edge_blur: number; // from 0 to x (1 for realism)
  55962. * distortion: number; // from 0 to x (1 for realism)
  55963. * grain_amount: number; // from 0 to 1
  55964. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  55965. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  55966. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  55967. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  55968. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  55969. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  55970. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  55971. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  55972. * }
  55973. * Note: if an effect parameter is unset, effect is disabled
  55974. *
  55975. * @param name The rendering pipeline name
  55976. * @param parameters - An object containing all parameters (see above)
  55977. * @param scene The scene linked to this pipeline
  55978. * @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)
  55979. * @param cameras The array of cameras that the rendering pipeline will be attached to
  55980. */
  55981. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  55982. /**
  55983. * Get the class name
  55984. * @returns "LensRenderingPipeline"
  55985. */
  55986. getClassName(): string;
  55987. /**
  55988. * Gets associated scene
  55989. */
  55990. readonly scene: Scene;
  55991. /**
  55992. * Gets or sets the edge blur
  55993. */
  55994. edgeBlur: number;
  55995. /**
  55996. * Gets or sets the grain amount
  55997. */
  55998. grainAmount: number;
  55999. /**
  56000. * Gets or sets the chromatic aberration amount
  56001. */
  56002. chromaticAberration: number;
  56003. /**
  56004. * Gets or sets the depth of field aperture
  56005. */
  56006. dofAperture: number;
  56007. /**
  56008. * Gets or sets the edge distortion
  56009. */
  56010. edgeDistortion: number;
  56011. /**
  56012. * Gets or sets the depth of field distortion
  56013. */
  56014. dofDistortion: number;
  56015. /**
  56016. * Gets or sets the darken out of focus amount
  56017. */
  56018. darkenOutOfFocus: number;
  56019. /**
  56020. * Gets or sets a boolean indicating if blur noise is enabled
  56021. */
  56022. blurNoise: boolean;
  56023. /**
  56024. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  56025. */
  56026. pentagonBokeh: boolean;
  56027. /**
  56028. * Gets or sets the highlight grain amount
  56029. */
  56030. highlightsGain: number;
  56031. /**
  56032. * Gets or sets the highlight threshold
  56033. */
  56034. highlightsThreshold: number;
  56035. /**
  56036. * Sets the amount of blur at the edges
  56037. * @param amount blur amount
  56038. */
  56039. setEdgeBlur(amount: number): void;
  56040. /**
  56041. * Sets edge blur to 0
  56042. */
  56043. disableEdgeBlur(): void;
  56044. /**
  56045. * Sets the amout of grain
  56046. * @param amount Amount of grain
  56047. */
  56048. setGrainAmount(amount: number): void;
  56049. /**
  56050. * Set grain amount to 0
  56051. */
  56052. disableGrain(): void;
  56053. /**
  56054. * Sets the chromatic aberration amount
  56055. * @param amount amount of chromatic aberration
  56056. */
  56057. setChromaticAberration(amount: number): void;
  56058. /**
  56059. * Sets chromatic aberration amount to 0
  56060. */
  56061. disableChromaticAberration(): void;
  56062. /**
  56063. * Sets the EdgeDistortion amount
  56064. * @param amount amount of EdgeDistortion
  56065. */
  56066. setEdgeDistortion(amount: number): void;
  56067. /**
  56068. * Sets edge distortion to 0
  56069. */
  56070. disableEdgeDistortion(): void;
  56071. /**
  56072. * Sets the FocusDistance amount
  56073. * @param amount amount of FocusDistance
  56074. */
  56075. setFocusDistance(amount: number): void;
  56076. /**
  56077. * Disables depth of field
  56078. */
  56079. disableDepthOfField(): void;
  56080. /**
  56081. * Sets the Aperture amount
  56082. * @param amount amount of Aperture
  56083. */
  56084. setAperture(amount: number): void;
  56085. /**
  56086. * Sets the DarkenOutOfFocus amount
  56087. * @param amount amount of DarkenOutOfFocus
  56088. */
  56089. setDarkenOutOfFocus(amount: number): void;
  56090. private _pentagonBokehIsEnabled;
  56091. /**
  56092. * Creates a pentagon bokeh effect
  56093. */
  56094. enablePentagonBokeh(): void;
  56095. /**
  56096. * Disables the pentagon bokeh effect
  56097. */
  56098. disablePentagonBokeh(): void;
  56099. /**
  56100. * Enables noise blur
  56101. */
  56102. enableNoiseBlur(): void;
  56103. /**
  56104. * Disables noise blur
  56105. */
  56106. disableNoiseBlur(): void;
  56107. /**
  56108. * Sets the HighlightsGain amount
  56109. * @param amount amount of HighlightsGain
  56110. */
  56111. setHighlightsGain(amount: number): void;
  56112. /**
  56113. * Sets the HighlightsThreshold amount
  56114. * @param amount amount of HighlightsThreshold
  56115. */
  56116. setHighlightsThreshold(amount: number): void;
  56117. /**
  56118. * Disables highlights
  56119. */
  56120. disableHighlights(): void;
  56121. /**
  56122. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  56123. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  56124. */
  56125. dispose(disableDepthRender?: boolean): void;
  56126. private _createChromaticAberrationPostProcess;
  56127. private _createHighlightsPostProcess;
  56128. private _createDepthOfFieldPostProcess;
  56129. private _createGrainTexture;
  56130. }
  56131. }
  56132. declare module "babylonjs/Shaders/ssao2.fragment" {
  56133. /** @hidden */
  56134. export var ssao2PixelShader: {
  56135. name: string;
  56136. shader: string;
  56137. };
  56138. }
  56139. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  56140. /** @hidden */
  56141. export var ssaoCombinePixelShader: {
  56142. name: string;
  56143. shader: string;
  56144. };
  56145. }
  56146. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  56147. import { Camera } from "babylonjs/Cameras/camera";
  56148. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56149. import { Scene } from "babylonjs/scene";
  56150. import "babylonjs/Shaders/ssao2.fragment";
  56151. import "babylonjs/Shaders/ssaoCombine.fragment";
  56152. /**
  56153. * Render pipeline to produce ssao effect
  56154. */
  56155. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  56156. /**
  56157. * @ignore
  56158. * The PassPostProcess id in the pipeline that contains the original scene color
  56159. */
  56160. SSAOOriginalSceneColorEffect: string;
  56161. /**
  56162. * @ignore
  56163. * The SSAO PostProcess id in the pipeline
  56164. */
  56165. SSAORenderEffect: string;
  56166. /**
  56167. * @ignore
  56168. * The horizontal blur PostProcess id in the pipeline
  56169. */
  56170. SSAOBlurHRenderEffect: string;
  56171. /**
  56172. * @ignore
  56173. * The vertical blur PostProcess id in the pipeline
  56174. */
  56175. SSAOBlurVRenderEffect: string;
  56176. /**
  56177. * @ignore
  56178. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56179. */
  56180. SSAOCombineRenderEffect: string;
  56181. /**
  56182. * The output strength of the SSAO post-process. Default value is 1.0.
  56183. */
  56184. totalStrength: number;
  56185. /**
  56186. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  56187. */
  56188. maxZ: number;
  56189. /**
  56190. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  56191. */
  56192. minZAspect: number;
  56193. private _samples;
  56194. /**
  56195. * Number of samples used for the SSAO calculations. Default value is 8
  56196. */
  56197. samples: number;
  56198. private _textureSamples;
  56199. /**
  56200. * Number of samples to use for antialiasing
  56201. */
  56202. textureSamples: number;
  56203. /**
  56204. * Ratio object used for SSAO ratio and blur ratio
  56205. */
  56206. private _ratio;
  56207. /**
  56208. * Dynamically generated sphere sampler.
  56209. */
  56210. private _sampleSphere;
  56211. /**
  56212. * Blur filter offsets
  56213. */
  56214. private _samplerOffsets;
  56215. private _expensiveBlur;
  56216. /**
  56217. * If bilateral blur should be used
  56218. */
  56219. expensiveBlur: boolean;
  56220. /**
  56221. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  56222. */
  56223. radius: number;
  56224. /**
  56225. * The base color of the SSAO post-process
  56226. * The final result is "base + ssao" between [0, 1]
  56227. */
  56228. base: number;
  56229. /**
  56230. * Support test.
  56231. */
  56232. static readonly IsSupported: boolean;
  56233. private _scene;
  56234. private _depthTexture;
  56235. private _normalTexture;
  56236. private _randomTexture;
  56237. private _originalColorPostProcess;
  56238. private _ssaoPostProcess;
  56239. private _blurHPostProcess;
  56240. private _blurVPostProcess;
  56241. private _ssaoCombinePostProcess;
  56242. private _firstUpdate;
  56243. /**
  56244. * Gets active scene
  56245. */
  56246. readonly scene: Scene;
  56247. /**
  56248. * @constructor
  56249. * @param name The rendering pipeline name
  56250. * @param scene The scene linked to this pipeline
  56251. * @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 }
  56252. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56253. */
  56254. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56255. /**
  56256. * Get the class name
  56257. * @returns "SSAO2RenderingPipeline"
  56258. */
  56259. getClassName(): string;
  56260. /**
  56261. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56262. */
  56263. dispose(disableGeometryBufferRenderer?: boolean): void;
  56264. private _createBlurPostProcess;
  56265. /** @hidden */
  56266. _rebuild(): void;
  56267. private _bits;
  56268. private _radicalInverse_VdC;
  56269. private _hammersley;
  56270. private _hemisphereSample_uniform;
  56271. private _generateHemisphere;
  56272. private _createSSAOPostProcess;
  56273. private _createSSAOCombinePostProcess;
  56274. private _createRandomTexture;
  56275. /**
  56276. * Serialize the rendering pipeline (Used when exporting)
  56277. * @returns the serialized object
  56278. */
  56279. serialize(): any;
  56280. /**
  56281. * Parse the serialized pipeline
  56282. * @param source Source pipeline.
  56283. * @param scene The scene to load the pipeline to.
  56284. * @param rootUrl The URL of the serialized pipeline.
  56285. * @returns An instantiated pipeline from the serialized object.
  56286. */
  56287. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  56288. }
  56289. }
  56290. declare module "babylonjs/Shaders/ssao.fragment" {
  56291. /** @hidden */
  56292. export var ssaoPixelShader: {
  56293. name: string;
  56294. shader: string;
  56295. };
  56296. }
  56297. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  56298. import { Camera } from "babylonjs/Cameras/camera";
  56299. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56300. import { Scene } from "babylonjs/scene";
  56301. import "babylonjs/Shaders/ssao.fragment";
  56302. import "babylonjs/Shaders/ssaoCombine.fragment";
  56303. /**
  56304. * Render pipeline to produce ssao effect
  56305. */
  56306. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  56307. /**
  56308. * @ignore
  56309. * The PassPostProcess id in the pipeline that contains the original scene color
  56310. */
  56311. SSAOOriginalSceneColorEffect: string;
  56312. /**
  56313. * @ignore
  56314. * The SSAO PostProcess id in the pipeline
  56315. */
  56316. SSAORenderEffect: string;
  56317. /**
  56318. * @ignore
  56319. * The horizontal blur PostProcess id in the pipeline
  56320. */
  56321. SSAOBlurHRenderEffect: string;
  56322. /**
  56323. * @ignore
  56324. * The vertical blur PostProcess id in the pipeline
  56325. */
  56326. SSAOBlurVRenderEffect: string;
  56327. /**
  56328. * @ignore
  56329. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  56330. */
  56331. SSAOCombineRenderEffect: string;
  56332. /**
  56333. * The output strength of the SSAO post-process. Default value is 1.0.
  56334. */
  56335. totalStrength: number;
  56336. /**
  56337. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  56338. */
  56339. radius: number;
  56340. /**
  56341. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  56342. * Must not be equal to fallOff and superior to fallOff.
  56343. * Default value is 0.0075
  56344. */
  56345. area: number;
  56346. /**
  56347. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  56348. * Must not be equal to area and inferior to area.
  56349. * Default value is 0.000001
  56350. */
  56351. fallOff: number;
  56352. /**
  56353. * The base color of the SSAO post-process
  56354. * The final result is "base + ssao" between [0, 1]
  56355. */
  56356. base: number;
  56357. private _scene;
  56358. private _depthTexture;
  56359. private _randomTexture;
  56360. private _originalColorPostProcess;
  56361. private _ssaoPostProcess;
  56362. private _blurHPostProcess;
  56363. private _blurVPostProcess;
  56364. private _ssaoCombinePostProcess;
  56365. private _firstUpdate;
  56366. /**
  56367. * Gets active scene
  56368. */
  56369. readonly scene: Scene;
  56370. /**
  56371. * @constructor
  56372. * @param name - The rendering pipeline name
  56373. * @param scene - The scene linked to this pipeline
  56374. * @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 }
  56375. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  56376. */
  56377. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  56378. /**
  56379. * Get the class name
  56380. * @returns "SSAORenderingPipeline"
  56381. */
  56382. getClassName(): string;
  56383. /**
  56384. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  56385. */
  56386. dispose(disableDepthRender?: boolean): void;
  56387. private _createBlurPostProcess;
  56388. /** @hidden */
  56389. _rebuild(): void;
  56390. private _createSSAOPostProcess;
  56391. private _createSSAOCombinePostProcess;
  56392. private _createRandomTexture;
  56393. }
  56394. }
  56395. declare module "babylonjs/Shaders/standard.fragment" {
  56396. /** @hidden */
  56397. export var standardPixelShader: {
  56398. name: string;
  56399. shader: string;
  56400. };
  56401. }
  56402. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  56403. import { Nullable } from "babylonjs/types";
  56404. import { IAnimatable } from "babylonjs/Misc/tools";
  56405. import { Camera } from "babylonjs/Cameras/camera";
  56406. import { Texture } from "babylonjs/Materials/Textures/texture";
  56407. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56408. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56409. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  56410. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  56411. import { IDisposable } from "babylonjs/scene";
  56412. import { SpotLight } from "babylonjs/Lights/spotLight";
  56413. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  56414. import { Scene } from "babylonjs/scene";
  56415. import { Animation } from "babylonjs/Animations/animation";
  56416. import "babylonjs/Shaders/standard.fragment";
  56417. /**
  56418. * Standard rendering pipeline
  56419. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56420. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  56421. */
  56422. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  56423. /**
  56424. * Public members
  56425. */
  56426. /**
  56427. * Post-process which contains the original scene color before the pipeline applies all the effects
  56428. */
  56429. originalPostProcess: Nullable<PostProcess>;
  56430. /**
  56431. * Post-process used to down scale an image x4
  56432. */
  56433. downSampleX4PostProcess: Nullable<PostProcess>;
  56434. /**
  56435. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  56436. */
  56437. brightPassPostProcess: Nullable<PostProcess>;
  56438. /**
  56439. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  56440. */
  56441. blurHPostProcesses: PostProcess[];
  56442. /**
  56443. * Post-process array storing all the vertical blur post-processes used by the pipeline
  56444. */
  56445. blurVPostProcesses: PostProcess[];
  56446. /**
  56447. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  56448. */
  56449. textureAdderPostProcess: Nullable<PostProcess>;
  56450. /**
  56451. * Post-process used to create volumetric lighting effect
  56452. */
  56453. volumetricLightPostProcess: Nullable<PostProcess>;
  56454. /**
  56455. * Post-process used to smooth the previous volumetric light post-process on the X axis
  56456. */
  56457. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  56458. /**
  56459. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  56460. */
  56461. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  56462. /**
  56463. * Post-process used to merge the volumetric light effect and the real scene color
  56464. */
  56465. volumetricLightMergePostProces: Nullable<PostProcess>;
  56466. /**
  56467. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  56468. */
  56469. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  56470. /**
  56471. * Base post-process used to calculate the average luminance of the final image for HDR
  56472. */
  56473. luminancePostProcess: Nullable<PostProcess>;
  56474. /**
  56475. * Post-processes used to create down sample post-processes in order to get
  56476. * the average luminance of the final image for HDR
  56477. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  56478. */
  56479. luminanceDownSamplePostProcesses: PostProcess[];
  56480. /**
  56481. * Post-process used to create a HDR effect (light adaptation)
  56482. */
  56483. hdrPostProcess: Nullable<PostProcess>;
  56484. /**
  56485. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  56486. */
  56487. textureAdderFinalPostProcess: Nullable<PostProcess>;
  56488. /**
  56489. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  56490. */
  56491. lensFlareFinalPostProcess: Nullable<PostProcess>;
  56492. /**
  56493. * Post-process used to merge the final HDR post-process and the real scene color
  56494. */
  56495. hdrFinalPostProcess: Nullable<PostProcess>;
  56496. /**
  56497. * Post-process used to create a lens flare effect
  56498. */
  56499. lensFlarePostProcess: Nullable<PostProcess>;
  56500. /**
  56501. * Post-process that merges the result of the lens flare post-process and the real scene color
  56502. */
  56503. lensFlareComposePostProcess: Nullable<PostProcess>;
  56504. /**
  56505. * Post-process used to create a motion blur effect
  56506. */
  56507. motionBlurPostProcess: Nullable<PostProcess>;
  56508. /**
  56509. * Post-process used to create a depth of field effect
  56510. */
  56511. depthOfFieldPostProcess: Nullable<PostProcess>;
  56512. /**
  56513. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  56514. */
  56515. fxaaPostProcess: Nullable<FxaaPostProcess>;
  56516. /**
  56517. * Represents the brightness threshold in order to configure the illuminated surfaces
  56518. */
  56519. brightThreshold: number;
  56520. /**
  56521. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  56522. */
  56523. blurWidth: number;
  56524. /**
  56525. * Sets if the blur for highlighted surfaces must be only horizontal
  56526. */
  56527. horizontalBlur: boolean;
  56528. /**
  56529. * Gets the overall exposure used by the pipeline
  56530. */
  56531. /**
  56532. * Sets the overall exposure used by the pipeline
  56533. */
  56534. exposure: number;
  56535. /**
  56536. * Texture used typically to simulate "dirty" on camera lens
  56537. */
  56538. lensTexture: Nullable<Texture>;
  56539. /**
  56540. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  56541. */
  56542. volumetricLightCoefficient: number;
  56543. /**
  56544. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  56545. */
  56546. volumetricLightPower: number;
  56547. /**
  56548. * Used the set the blur intensity to smooth the volumetric lights
  56549. */
  56550. volumetricLightBlurScale: number;
  56551. /**
  56552. * Light (spot or directional) used to generate the volumetric lights rays
  56553. * The source light must have a shadow generate so the pipeline can get its
  56554. * depth map
  56555. */
  56556. sourceLight: Nullable<SpotLight | DirectionalLight>;
  56557. /**
  56558. * For eye adaptation, represents the minimum luminance the eye can see
  56559. */
  56560. hdrMinimumLuminance: number;
  56561. /**
  56562. * For eye adaptation, represents the decrease luminance speed
  56563. */
  56564. hdrDecreaseRate: number;
  56565. /**
  56566. * For eye adaptation, represents the increase luminance speed
  56567. */
  56568. hdrIncreaseRate: number;
  56569. /**
  56570. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56571. */
  56572. /**
  56573. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  56574. */
  56575. hdrAutoExposure: boolean;
  56576. /**
  56577. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  56578. */
  56579. lensColorTexture: Nullable<Texture>;
  56580. /**
  56581. * The overall strengh for the lens flare effect
  56582. */
  56583. lensFlareStrength: number;
  56584. /**
  56585. * Dispersion coefficient for lens flare ghosts
  56586. */
  56587. lensFlareGhostDispersal: number;
  56588. /**
  56589. * Main lens flare halo width
  56590. */
  56591. lensFlareHaloWidth: number;
  56592. /**
  56593. * Based on the lens distortion effect, defines how much the lens flare result
  56594. * is distorted
  56595. */
  56596. lensFlareDistortionStrength: number;
  56597. /**
  56598. * Lens star texture must be used to simulate rays on the flares and is available
  56599. * in the documentation
  56600. */
  56601. lensStarTexture: Nullable<Texture>;
  56602. /**
  56603. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  56604. * flare effect by taking account of the dirt texture
  56605. */
  56606. lensFlareDirtTexture: Nullable<Texture>;
  56607. /**
  56608. * Represents the focal length for the depth of field effect
  56609. */
  56610. depthOfFieldDistance: number;
  56611. /**
  56612. * Represents the blur intensity for the blurred part of the depth of field effect
  56613. */
  56614. depthOfFieldBlurWidth: number;
  56615. /**
  56616. * For motion blur, defines how much the image is blurred by the movement
  56617. */
  56618. motionStrength: number;
  56619. /**
  56620. * List of animations for the pipeline (IAnimatable implementation)
  56621. */
  56622. animations: Animation[];
  56623. /**
  56624. * Private members
  56625. */
  56626. private _scene;
  56627. private _currentDepthOfFieldSource;
  56628. private _basePostProcess;
  56629. private _fixedExposure;
  56630. private _currentExposure;
  56631. private _hdrAutoExposure;
  56632. private _hdrCurrentLuminance;
  56633. private _floatTextureType;
  56634. private _ratio;
  56635. private _bloomEnabled;
  56636. private _depthOfFieldEnabled;
  56637. private _vlsEnabled;
  56638. private _lensFlareEnabled;
  56639. private _hdrEnabled;
  56640. private _motionBlurEnabled;
  56641. private _fxaaEnabled;
  56642. private _motionBlurSamples;
  56643. private _volumetricLightStepsCount;
  56644. private _samples;
  56645. /**
  56646. * @ignore
  56647. * Specifies if the bloom pipeline is enabled
  56648. */
  56649. BloomEnabled: boolean;
  56650. /**
  56651. * @ignore
  56652. * Specifies if the depth of field pipeline is enabed
  56653. */
  56654. DepthOfFieldEnabled: boolean;
  56655. /**
  56656. * @ignore
  56657. * Specifies if the lens flare pipeline is enabed
  56658. */
  56659. LensFlareEnabled: boolean;
  56660. /**
  56661. * @ignore
  56662. * Specifies if the HDR pipeline is enabled
  56663. */
  56664. HDREnabled: boolean;
  56665. /**
  56666. * @ignore
  56667. * Specifies if the volumetric lights scattering effect is enabled
  56668. */
  56669. VLSEnabled: boolean;
  56670. /**
  56671. * @ignore
  56672. * Specifies if the motion blur effect is enabled
  56673. */
  56674. MotionBlurEnabled: boolean;
  56675. /**
  56676. * Specifies if anti-aliasing is enabled
  56677. */
  56678. fxaaEnabled: boolean;
  56679. /**
  56680. * Specifies the number of steps used to calculate the volumetric lights
  56681. * Typically in interval [50, 200]
  56682. */
  56683. volumetricLightStepsCount: number;
  56684. /**
  56685. * Specifies the number of samples used for the motion blur effect
  56686. * Typically in interval [16, 64]
  56687. */
  56688. motionBlurSamples: number;
  56689. /**
  56690. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  56691. */
  56692. samples: number;
  56693. /**
  56694. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  56695. * @constructor
  56696. * @param name The rendering pipeline name
  56697. * @param scene The scene linked to this pipeline
  56698. * @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)
  56699. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  56700. * @param cameras The array of cameras that the rendering pipeline will be attached to
  56701. */
  56702. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  56703. private _buildPipeline;
  56704. private _createDownSampleX4PostProcess;
  56705. private _createBrightPassPostProcess;
  56706. private _createBlurPostProcesses;
  56707. private _createTextureAdderPostProcess;
  56708. private _createVolumetricLightPostProcess;
  56709. private _createLuminancePostProcesses;
  56710. private _createHdrPostProcess;
  56711. private _createLensFlarePostProcess;
  56712. private _createDepthOfFieldPostProcess;
  56713. private _createMotionBlurPostProcess;
  56714. private _getDepthTexture;
  56715. private _disposePostProcesses;
  56716. /**
  56717. * Dispose of the pipeline and stop all post processes
  56718. */
  56719. dispose(): void;
  56720. /**
  56721. * Serialize the rendering pipeline (Used when exporting)
  56722. * @returns the serialized object
  56723. */
  56724. serialize(): any;
  56725. /**
  56726. * Parse the serialized pipeline
  56727. * @param source Source pipeline.
  56728. * @param scene The scene to load the pipeline to.
  56729. * @param rootUrl The URL of the serialized pipeline.
  56730. * @returns An instantiated pipeline from the serialized object.
  56731. */
  56732. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  56733. /**
  56734. * Luminance steps
  56735. */
  56736. static LuminanceSteps: number;
  56737. }
  56738. }
  56739. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  56740. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  56741. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  56742. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  56743. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  56744. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  56745. }
  56746. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  56747. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  56748. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  56749. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  56750. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  56751. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  56752. }
  56753. declare module "babylonjs/Shaders/tonemap.fragment" {
  56754. /** @hidden */
  56755. export var tonemapPixelShader: {
  56756. name: string;
  56757. shader: string;
  56758. };
  56759. }
  56760. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  56761. import { Camera } from "babylonjs/Cameras/camera";
  56762. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56763. import "babylonjs/Shaders/tonemap.fragment";
  56764. import { Engine } from "babylonjs/Engines/engine";
  56765. /** Defines operator used for tonemapping */
  56766. export enum TonemappingOperator {
  56767. /** Hable */
  56768. Hable = 0,
  56769. /** Reinhard */
  56770. Reinhard = 1,
  56771. /** HejiDawson */
  56772. HejiDawson = 2,
  56773. /** Photographic */
  56774. Photographic = 3
  56775. }
  56776. /**
  56777. * Defines a post process to apply tone mapping
  56778. */
  56779. export class TonemapPostProcess extends PostProcess {
  56780. private _operator;
  56781. /** Defines the required exposure adjustement */
  56782. exposureAdjustment: number;
  56783. /**
  56784. * Creates a new TonemapPostProcess
  56785. * @param name defines the name of the postprocess
  56786. * @param _operator defines the operator to use
  56787. * @param exposureAdjustment defines the required exposure adjustement
  56788. * @param camera defines the camera to use (can be null)
  56789. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  56790. * @param engine defines the hosting engine (can be ignore if camera is set)
  56791. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  56792. */
  56793. constructor(name: string, _operator: TonemappingOperator,
  56794. /** Defines the required exposure adjustement */
  56795. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  56796. }
  56797. }
  56798. declare module "babylonjs/Shaders/depth.vertex" {
  56799. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  56800. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  56801. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  56802. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  56803. /** @hidden */
  56804. export var depthVertexShader: {
  56805. name: string;
  56806. shader: string;
  56807. };
  56808. }
  56809. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  56810. /** @hidden */
  56811. export var volumetricLightScatteringPixelShader: {
  56812. name: string;
  56813. shader: string;
  56814. };
  56815. }
  56816. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  56817. /** @hidden */
  56818. export var volumetricLightScatteringPassPixelShader: {
  56819. name: string;
  56820. shader: string;
  56821. };
  56822. }
  56823. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  56824. import { Vector3 } from "babylonjs/Maths/math";
  56825. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56826. import { Mesh } from "babylonjs/Meshes/mesh";
  56827. import { Camera } from "babylonjs/Cameras/camera";
  56828. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  56829. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  56830. import { Scene } from "babylonjs/scene";
  56831. import "babylonjs/Meshes/Builders/planeBuilder";
  56832. import "babylonjs/Shaders/depth.vertex";
  56833. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  56834. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  56835. import { Engine } from "babylonjs/Engines/engine";
  56836. /**
  56837. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  56838. */
  56839. export class VolumetricLightScatteringPostProcess extends PostProcess {
  56840. private _volumetricLightScatteringPass;
  56841. private _volumetricLightScatteringRTT;
  56842. private _viewPort;
  56843. private _screenCoordinates;
  56844. private _cachedDefines;
  56845. /**
  56846. * If not undefined, the mesh position is computed from the attached node position
  56847. */
  56848. attachedNode: {
  56849. position: Vector3;
  56850. };
  56851. /**
  56852. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  56853. */
  56854. customMeshPosition: Vector3;
  56855. /**
  56856. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  56857. */
  56858. useCustomMeshPosition: boolean;
  56859. /**
  56860. * If the post-process should inverse the light scattering direction
  56861. */
  56862. invert: boolean;
  56863. /**
  56864. * The internal mesh used by the post-process
  56865. */
  56866. mesh: Mesh;
  56867. /**
  56868. * @hidden
  56869. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  56870. */
  56871. useDiffuseColor: boolean;
  56872. /**
  56873. * Array containing the excluded meshes not rendered in the internal pass
  56874. */
  56875. excludedMeshes: AbstractMesh[];
  56876. /**
  56877. * Controls the overall intensity of the post-process
  56878. */
  56879. exposure: number;
  56880. /**
  56881. * Dissipates each sample's contribution in range [0, 1]
  56882. */
  56883. decay: number;
  56884. /**
  56885. * Controls the overall intensity of each sample
  56886. */
  56887. weight: number;
  56888. /**
  56889. * Controls the density of each sample
  56890. */
  56891. density: number;
  56892. /**
  56893. * @constructor
  56894. * @param name The post-process name
  56895. * @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)
  56896. * @param camera The camera that the post-process will be attached to
  56897. * @param mesh The mesh used to create the light scattering
  56898. * @param samples The post-process quality, default 100
  56899. * @param samplingModeThe post-process filtering mode
  56900. * @param engine The babylon engine
  56901. * @param reusable If the post-process is reusable
  56902. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  56903. */
  56904. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  56905. /**
  56906. * Returns the string "VolumetricLightScatteringPostProcess"
  56907. * @returns "VolumetricLightScatteringPostProcess"
  56908. */
  56909. getClassName(): string;
  56910. private _isReady;
  56911. /**
  56912. * Sets the new light position for light scattering effect
  56913. * @param position The new custom light position
  56914. */
  56915. setCustomMeshPosition(position: Vector3): void;
  56916. /**
  56917. * Returns the light position for light scattering effect
  56918. * @return Vector3 The custom light position
  56919. */
  56920. getCustomMeshPosition(): Vector3;
  56921. /**
  56922. * Disposes the internal assets and detaches the post-process from the camera
  56923. */
  56924. dispose(camera: Camera): void;
  56925. /**
  56926. * Returns the render target texture used by the post-process
  56927. * @return the render target texture used by the post-process
  56928. */
  56929. getPass(): RenderTargetTexture;
  56930. private _meshExcluded;
  56931. private _createPass;
  56932. private _updateMeshScreenCoordinates;
  56933. /**
  56934. * Creates a default mesh for the Volumeric Light Scattering post-process
  56935. * @param name The mesh name
  56936. * @param scene The scene where to create the mesh
  56937. * @return the default mesh
  56938. */
  56939. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  56940. }
  56941. }
  56942. declare module "babylonjs/PostProcesses/index" {
  56943. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  56944. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  56945. export * from "babylonjs/PostProcesses/bloomEffect";
  56946. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  56947. export * from "babylonjs/PostProcesses/blurPostProcess";
  56948. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  56949. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  56950. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  56951. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  56952. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  56953. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  56954. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  56955. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  56956. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  56957. export * from "babylonjs/PostProcesses/filterPostProcess";
  56958. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  56959. export * from "babylonjs/PostProcesses/grainPostProcess";
  56960. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  56961. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  56962. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  56963. export * from "babylonjs/PostProcesses/passPostProcess";
  56964. export * from "babylonjs/PostProcesses/postProcess";
  56965. export * from "babylonjs/PostProcesses/postProcessManager";
  56966. export * from "babylonjs/PostProcesses/refractionPostProcess";
  56967. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  56968. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  56969. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  56970. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  56971. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  56972. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  56973. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  56974. }
  56975. declare module "babylonjs/Probes/index" {
  56976. export * from "babylonjs/Probes/reflectionProbe";
  56977. }
  56978. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  56979. import { Scene } from "babylonjs/scene";
  56980. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56981. import { Color3 } from "babylonjs/Maths/math";
  56982. import { SmartArray } from "babylonjs/Misc/smartArray";
  56983. import { ISceneComponent } from "babylonjs/sceneComponent";
  56984. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  56985. import "babylonjs/Meshes/Builders/boxBuilder";
  56986. import "babylonjs/Shaders/color.fragment";
  56987. import "babylonjs/Shaders/color.vertex";
  56988. module "babylonjs/scene" {
  56989. interface Scene {
  56990. /** @hidden (Backing field) */
  56991. _boundingBoxRenderer: BoundingBoxRenderer;
  56992. /** @hidden (Backing field) */
  56993. _forceShowBoundingBoxes: boolean;
  56994. /**
  56995. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  56996. */
  56997. forceShowBoundingBoxes: boolean;
  56998. /**
  56999. * Gets the bounding box renderer associated with the scene
  57000. * @returns a BoundingBoxRenderer
  57001. */
  57002. getBoundingBoxRenderer(): BoundingBoxRenderer;
  57003. }
  57004. }
  57005. module "babylonjs/Meshes/abstractMesh" {
  57006. interface AbstractMesh {
  57007. /** @hidden (Backing field) */
  57008. _showBoundingBox: boolean;
  57009. /**
  57010. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  57011. */
  57012. showBoundingBox: boolean;
  57013. }
  57014. }
  57015. /**
  57016. * Component responsible of rendering the bounding box of the meshes in a scene.
  57017. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  57018. */
  57019. export class BoundingBoxRenderer implements ISceneComponent {
  57020. /**
  57021. * The component name helpfull to identify the component in the list of scene components.
  57022. */
  57023. readonly name: string;
  57024. /**
  57025. * The scene the component belongs to.
  57026. */
  57027. scene: Scene;
  57028. /**
  57029. * Color of the bounding box lines placed in front of an object
  57030. */
  57031. frontColor: Color3;
  57032. /**
  57033. * Color of the bounding box lines placed behind an object
  57034. */
  57035. backColor: Color3;
  57036. /**
  57037. * Defines if the renderer should show the back lines or not
  57038. */
  57039. showBackLines: boolean;
  57040. /**
  57041. * @hidden
  57042. */
  57043. renderList: SmartArray<BoundingBox>;
  57044. private _colorShader;
  57045. private _vertexBuffers;
  57046. private _indexBuffer;
  57047. /**
  57048. * Instantiates a new bounding box renderer in a scene.
  57049. * @param scene the scene the renderer renders in
  57050. */
  57051. constructor(scene: Scene);
  57052. /**
  57053. * Registers the component in a given scene
  57054. */
  57055. register(): void;
  57056. private _evaluateSubMesh;
  57057. private _activeMesh;
  57058. private _prepareRessources;
  57059. private _createIndexBuffer;
  57060. /**
  57061. * Rebuilds the elements related to this component in case of
  57062. * context lost for instance.
  57063. */
  57064. rebuild(): void;
  57065. /**
  57066. * @hidden
  57067. */
  57068. reset(): void;
  57069. /**
  57070. * Render the bounding boxes of a specific rendering group
  57071. * @param renderingGroupId defines the rendering group to render
  57072. */
  57073. render(renderingGroupId: number): void;
  57074. /**
  57075. * In case of occlusion queries, we can render the occlusion bounding box through this method
  57076. * @param mesh Define the mesh to render the occlusion bounding box for
  57077. */
  57078. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  57079. /**
  57080. * Dispose and release the resources attached to this renderer.
  57081. */
  57082. dispose(): void;
  57083. }
  57084. }
  57085. declare module "babylonjs/Shaders/depth.fragment" {
  57086. /** @hidden */
  57087. export var depthPixelShader: {
  57088. name: string;
  57089. shader: string;
  57090. };
  57091. }
  57092. declare module "babylonjs/Rendering/depthRenderer" {
  57093. import { Nullable } from "babylonjs/types";
  57094. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57095. import { Scene } from "babylonjs/scene";
  57096. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  57097. import { Camera } from "babylonjs/Cameras/camera";
  57098. import "babylonjs/Shaders/depth.fragment";
  57099. import "babylonjs/Shaders/depth.vertex";
  57100. /**
  57101. * This represents a depth renderer in Babylon.
  57102. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  57103. */
  57104. export class DepthRenderer {
  57105. private _scene;
  57106. private _depthMap;
  57107. private _effect;
  57108. private _cachedDefines;
  57109. private _camera;
  57110. /**
  57111. * Specifiess that the depth renderer will only be used within
  57112. * the camera it is created for.
  57113. * This can help forcing its rendering during the camera processing.
  57114. */
  57115. useOnlyInActiveCamera: boolean;
  57116. /** @hidden */
  57117. static _SceneComponentInitialization: (scene: Scene) => void;
  57118. /**
  57119. * Instantiates a depth renderer
  57120. * @param scene The scene the renderer belongs to
  57121. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  57122. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  57123. */
  57124. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  57125. /**
  57126. * Creates the depth rendering effect and checks if the effect is ready.
  57127. * @param subMesh The submesh to be used to render the depth map of
  57128. * @param useInstances If multiple world instances should be used
  57129. * @returns if the depth renderer is ready to render the depth map
  57130. */
  57131. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57132. /**
  57133. * Gets the texture which the depth map will be written to.
  57134. * @returns The depth map texture
  57135. */
  57136. getDepthMap(): RenderTargetTexture;
  57137. /**
  57138. * Disposes of the depth renderer.
  57139. */
  57140. dispose(): void;
  57141. }
  57142. }
  57143. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  57144. import { Nullable } from "babylonjs/types";
  57145. import { Scene } from "babylonjs/scene";
  57146. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  57147. import { Camera } from "babylonjs/Cameras/camera";
  57148. import { ISceneComponent } from "babylonjs/sceneComponent";
  57149. module "babylonjs/scene" {
  57150. interface Scene {
  57151. /** @hidden (Backing field) */
  57152. _depthRenderer: {
  57153. [id: string]: DepthRenderer;
  57154. };
  57155. /**
  57156. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  57157. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  57158. * @returns the created depth renderer
  57159. */
  57160. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  57161. /**
  57162. * Disables a depth renderer for a given camera
  57163. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  57164. */
  57165. disableDepthRenderer(camera?: Nullable<Camera>): void;
  57166. }
  57167. }
  57168. /**
  57169. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  57170. * in several rendering techniques.
  57171. */
  57172. export class DepthRendererSceneComponent implements ISceneComponent {
  57173. /**
  57174. * The component name helpfull to identify the component in the list of scene components.
  57175. */
  57176. readonly name: string;
  57177. /**
  57178. * The scene the component belongs to.
  57179. */
  57180. scene: Scene;
  57181. /**
  57182. * Creates a new instance of the component for the given scene
  57183. * @param scene Defines the scene to register the component in
  57184. */
  57185. constructor(scene: Scene);
  57186. /**
  57187. * Registers the component in a given scene
  57188. */
  57189. register(): void;
  57190. /**
  57191. * Rebuilds the elements related to this component in case of
  57192. * context lost for instance.
  57193. */
  57194. rebuild(): void;
  57195. /**
  57196. * Disposes the component and the associated ressources
  57197. */
  57198. dispose(): void;
  57199. private _gatherRenderTargets;
  57200. private _gatherActiveCameraRenderTargets;
  57201. }
  57202. }
  57203. declare module "babylonjs/Shaders/outline.fragment" {
  57204. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57205. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  57206. /** @hidden */
  57207. export var outlinePixelShader: {
  57208. name: string;
  57209. shader: string;
  57210. };
  57211. }
  57212. declare module "babylonjs/Shaders/outline.vertex" {
  57213. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57214. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57215. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  57216. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57217. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57218. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  57219. /** @hidden */
  57220. export var outlineVertexShader: {
  57221. name: string;
  57222. shader: string;
  57223. };
  57224. }
  57225. declare module "babylonjs/Rendering/outlineRenderer" {
  57226. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57227. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  57228. import { Scene } from "babylonjs/scene";
  57229. import { ISceneComponent } from "babylonjs/sceneComponent";
  57230. import "babylonjs/Shaders/outline.fragment";
  57231. import "babylonjs/Shaders/outline.vertex";
  57232. module "babylonjs/scene" {
  57233. interface Scene {
  57234. /** @hidden */
  57235. _outlineRenderer: OutlineRenderer;
  57236. /**
  57237. * Gets the outline renderer associated with the scene
  57238. * @returns a OutlineRenderer
  57239. */
  57240. getOutlineRenderer(): OutlineRenderer;
  57241. }
  57242. }
  57243. module "babylonjs/Meshes/abstractMesh" {
  57244. interface AbstractMesh {
  57245. /** @hidden (Backing field) */
  57246. _renderOutline: boolean;
  57247. /**
  57248. * Gets or sets a boolean indicating if the outline must be rendered as well
  57249. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  57250. */
  57251. renderOutline: boolean;
  57252. /** @hidden (Backing field) */
  57253. _renderOverlay: boolean;
  57254. /**
  57255. * Gets or sets a boolean indicating if the overlay must be rendered as well
  57256. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  57257. */
  57258. renderOverlay: boolean;
  57259. }
  57260. }
  57261. /**
  57262. * This class is responsible to draw bothe outline/overlay of meshes.
  57263. * It should not be used directly but through the available method on mesh.
  57264. */
  57265. export class OutlineRenderer implements ISceneComponent {
  57266. /**
  57267. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  57268. */
  57269. private static _StencilReference;
  57270. /**
  57271. * The name of the component. Each component must have a unique name.
  57272. */
  57273. name: string;
  57274. /**
  57275. * The scene the component belongs to.
  57276. */
  57277. scene: Scene;
  57278. /**
  57279. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  57280. */
  57281. zOffset: number;
  57282. private _engine;
  57283. private _effect;
  57284. private _cachedDefines;
  57285. private _savedDepthWrite;
  57286. /**
  57287. * Instantiates a new outline renderer. (There could be only one per scene).
  57288. * @param scene Defines the scene it belongs to
  57289. */
  57290. constructor(scene: Scene);
  57291. /**
  57292. * Register the component to one instance of a scene.
  57293. */
  57294. register(): void;
  57295. /**
  57296. * Rebuilds the elements related to this component in case of
  57297. * context lost for instance.
  57298. */
  57299. rebuild(): void;
  57300. /**
  57301. * Disposes the component and the associated ressources.
  57302. */
  57303. dispose(): void;
  57304. /**
  57305. * Renders the outline in the canvas.
  57306. * @param subMesh Defines the sumesh to render
  57307. * @param batch Defines the batch of meshes in case of instances
  57308. * @param useOverlay Defines if the rendering is for the overlay or the outline
  57309. */
  57310. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  57311. /**
  57312. * Returns whether or not the outline renderer is ready for a given submesh.
  57313. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  57314. * @param subMesh Defines the submesh to check readyness for
  57315. * @param useInstances Defines wheter wee are trying to render instances or not
  57316. * @returns true if ready otherwise false
  57317. */
  57318. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  57319. private _beforeRenderingMesh;
  57320. private _afterRenderingMesh;
  57321. }
  57322. }
  57323. declare module "babylonjs/Rendering/index" {
  57324. export * from "babylonjs/Rendering/boundingBoxRenderer";
  57325. export * from "babylonjs/Rendering/depthRenderer";
  57326. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  57327. export * from "babylonjs/Rendering/edgesRenderer";
  57328. export * from "babylonjs/Rendering/geometryBufferRenderer";
  57329. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  57330. export * from "babylonjs/Rendering/outlineRenderer";
  57331. export * from "babylonjs/Rendering/renderingGroup";
  57332. export * from "babylonjs/Rendering/renderingManager";
  57333. export * from "babylonjs/Rendering/utilityLayerRenderer";
  57334. }
  57335. declare module "babylonjs/Sprites/index" {
  57336. export * from "babylonjs/Sprites/sprite";
  57337. export * from "babylonjs/Sprites/spriteManager";
  57338. export * from "babylonjs/Sprites/spriteSceneComponent";
  57339. }
  57340. declare module "babylonjs/Misc/assetsManager" {
  57341. import { Scene } from "babylonjs/scene";
  57342. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57343. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  57344. import { Skeleton } from "babylonjs/Bones/skeleton";
  57345. import { Observable } from "babylonjs/Misc/observable";
  57346. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57347. import { Texture } from "babylonjs/Materials/Textures/texture";
  57348. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  57349. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  57350. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  57351. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  57352. /**
  57353. * Defines the list of states available for a task inside a AssetsManager
  57354. */
  57355. export enum AssetTaskState {
  57356. /**
  57357. * Initialization
  57358. */
  57359. INIT = 0,
  57360. /**
  57361. * Running
  57362. */
  57363. RUNNING = 1,
  57364. /**
  57365. * Done
  57366. */
  57367. DONE = 2,
  57368. /**
  57369. * Error
  57370. */
  57371. ERROR = 3
  57372. }
  57373. /**
  57374. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  57375. */
  57376. export abstract class AbstractAssetTask {
  57377. /**
  57378. * Task name
  57379. */ name: string;
  57380. /**
  57381. * Callback called when the task is successful
  57382. */
  57383. onSuccess: (task: any) => void;
  57384. /**
  57385. * Callback called when the task is not successful
  57386. */
  57387. onError: (task: any, message?: string, exception?: any) => void;
  57388. /**
  57389. * Creates a new AssetsManager
  57390. * @param name defines the name of the task
  57391. */
  57392. constructor(
  57393. /**
  57394. * Task name
  57395. */ name: string);
  57396. private _isCompleted;
  57397. private _taskState;
  57398. private _errorObject;
  57399. /**
  57400. * Get if the task is completed
  57401. */
  57402. readonly isCompleted: boolean;
  57403. /**
  57404. * Gets the current state of the task
  57405. */
  57406. readonly taskState: AssetTaskState;
  57407. /**
  57408. * Gets the current error object (if task is in error)
  57409. */
  57410. readonly errorObject: {
  57411. message?: string;
  57412. exception?: any;
  57413. };
  57414. /**
  57415. * Internal only
  57416. * @hidden
  57417. */
  57418. _setErrorObject(message?: string, exception?: any): void;
  57419. /**
  57420. * Execute the current task
  57421. * @param scene defines the scene where you want your assets to be loaded
  57422. * @param onSuccess is a callback called when the task is successfully executed
  57423. * @param onError is a callback called if an error occurs
  57424. */
  57425. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57426. /**
  57427. * Execute the current task
  57428. * @param scene defines the scene where you want your assets to be loaded
  57429. * @param onSuccess is a callback called when the task is successfully executed
  57430. * @param onError is a callback called if an error occurs
  57431. */
  57432. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57433. /**
  57434. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  57435. * This can be used with failed tasks that have the reason for failure fixed.
  57436. */
  57437. reset(): void;
  57438. private onErrorCallback;
  57439. private onDoneCallback;
  57440. }
  57441. /**
  57442. * Define the interface used by progress events raised during assets loading
  57443. */
  57444. export interface IAssetsProgressEvent {
  57445. /**
  57446. * Defines the number of remaining tasks to process
  57447. */
  57448. remainingCount: number;
  57449. /**
  57450. * Defines the total number of tasks
  57451. */
  57452. totalCount: number;
  57453. /**
  57454. * Defines the task that was just processed
  57455. */
  57456. task: AbstractAssetTask;
  57457. }
  57458. /**
  57459. * Class used to share progress information about assets loading
  57460. */
  57461. export class AssetsProgressEvent implements IAssetsProgressEvent {
  57462. /**
  57463. * Defines the number of remaining tasks to process
  57464. */
  57465. remainingCount: number;
  57466. /**
  57467. * Defines the total number of tasks
  57468. */
  57469. totalCount: number;
  57470. /**
  57471. * Defines the task that was just processed
  57472. */
  57473. task: AbstractAssetTask;
  57474. /**
  57475. * Creates a AssetsProgressEvent
  57476. * @param remainingCount defines the number of remaining tasks to process
  57477. * @param totalCount defines the total number of tasks
  57478. * @param task defines the task that was just processed
  57479. */
  57480. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  57481. }
  57482. /**
  57483. * Define a task used by AssetsManager to load meshes
  57484. */
  57485. export class MeshAssetTask extends AbstractAssetTask {
  57486. /**
  57487. * Defines the name of the task
  57488. */
  57489. name: string;
  57490. /**
  57491. * Defines the list of mesh's names you want to load
  57492. */
  57493. meshesNames: any;
  57494. /**
  57495. * Defines the root url to use as a base to load your meshes and associated resources
  57496. */
  57497. rootUrl: string;
  57498. /**
  57499. * Defines the filename of the scene to load from
  57500. */
  57501. sceneFilename: string;
  57502. /**
  57503. * Gets the list of loaded meshes
  57504. */
  57505. loadedMeshes: Array<AbstractMesh>;
  57506. /**
  57507. * Gets the list of loaded particle systems
  57508. */
  57509. loadedParticleSystems: Array<IParticleSystem>;
  57510. /**
  57511. * Gets the list of loaded skeletons
  57512. */
  57513. loadedSkeletons: Array<Skeleton>;
  57514. /**
  57515. * Gets the list of loaded animation groups
  57516. */
  57517. loadedAnimationGroups: Array<AnimationGroup>;
  57518. /**
  57519. * Callback called when the task is successful
  57520. */
  57521. onSuccess: (task: MeshAssetTask) => void;
  57522. /**
  57523. * Callback called when the task is successful
  57524. */
  57525. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  57526. /**
  57527. * Creates a new MeshAssetTask
  57528. * @param name defines the name of the task
  57529. * @param meshesNames defines the list of mesh's names you want to load
  57530. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  57531. * @param sceneFilename defines the filename of the scene to load from
  57532. */
  57533. constructor(
  57534. /**
  57535. * Defines the name of the task
  57536. */
  57537. name: string,
  57538. /**
  57539. * Defines the list of mesh's names you want to load
  57540. */
  57541. meshesNames: any,
  57542. /**
  57543. * Defines the root url to use as a base to load your meshes and associated resources
  57544. */
  57545. rootUrl: string,
  57546. /**
  57547. * Defines the filename of the scene to load from
  57548. */
  57549. sceneFilename: string);
  57550. /**
  57551. * Execute the current task
  57552. * @param scene defines the scene where you want your assets to be loaded
  57553. * @param onSuccess is a callback called when the task is successfully executed
  57554. * @param onError is a callback called if an error occurs
  57555. */
  57556. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57557. }
  57558. /**
  57559. * Define a task used by AssetsManager to load text content
  57560. */
  57561. export class TextFileAssetTask extends AbstractAssetTask {
  57562. /**
  57563. * Defines the name of the task
  57564. */
  57565. name: string;
  57566. /**
  57567. * Defines the location of the file to load
  57568. */
  57569. url: string;
  57570. /**
  57571. * Gets the loaded text string
  57572. */
  57573. text: string;
  57574. /**
  57575. * Callback called when the task is successful
  57576. */
  57577. onSuccess: (task: TextFileAssetTask) => void;
  57578. /**
  57579. * Callback called when the task is successful
  57580. */
  57581. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  57582. /**
  57583. * Creates a new TextFileAssetTask object
  57584. * @param name defines the name of the task
  57585. * @param url defines the location of the file to load
  57586. */
  57587. constructor(
  57588. /**
  57589. * Defines the name of the task
  57590. */
  57591. name: string,
  57592. /**
  57593. * Defines the location of the file to load
  57594. */
  57595. url: string);
  57596. /**
  57597. * Execute the current task
  57598. * @param scene defines the scene where you want your assets to be loaded
  57599. * @param onSuccess is a callback called when the task is successfully executed
  57600. * @param onError is a callback called if an error occurs
  57601. */
  57602. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57603. }
  57604. /**
  57605. * Define a task used by AssetsManager to load binary data
  57606. */
  57607. export class BinaryFileAssetTask extends AbstractAssetTask {
  57608. /**
  57609. * Defines the name of the task
  57610. */
  57611. name: string;
  57612. /**
  57613. * Defines the location of the file to load
  57614. */
  57615. url: string;
  57616. /**
  57617. * Gets the lodaded data (as an array buffer)
  57618. */
  57619. data: ArrayBuffer;
  57620. /**
  57621. * Callback called when the task is successful
  57622. */
  57623. onSuccess: (task: BinaryFileAssetTask) => void;
  57624. /**
  57625. * Callback called when the task is successful
  57626. */
  57627. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  57628. /**
  57629. * Creates a new BinaryFileAssetTask object
  57630. * @param name defines the name of the new task
  57631. * @param url defines the location of the file to load
  57632. */
  57633. constructor(
  57634. /**
  57635. * Defines the name of the task
  57636. */
  57637. name: string,
  57638. /**
  57639. * Defines the location of the file to load
  57640. */
  57641. url: string);
  57642. /**
  57643. * Execute the current task
  57644. * @param scene defines the scene where you want your assets to be loaded
  57645. * @param onSuccess is a callback called when the task is successfully executed
  57646. * @param onError is a callback called if an error occurs
  57647. */
  57648. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57649. }
  57650. /**
  57651. * Define a task used by AssetsManager to load images
  57652. */
  57653. export class ImageAssetTask extends AbstractAssetTask {
  57654. /**
  57655. * Defines the name of the task
  57656. */
  57657. name: string;
  57658. /**
  57659. * Defines the location of the image to load
  57660. */
  57661. url: string;
  57662. /**
  57663. * Gets the loaded images
  57664. */
  57665. image: HTMLImageElement;
  57666. /**
  57667. * Callback called when the task is successful
  57668. */
  57669. onSuccess: (task: ImageAssetTask) => void;
  57670. /**
  57671. * Callback called when the task is successful
  57672. */
  57673. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  57674. /**
  57675. * Creates a new ImageAssetTask
  57676. * @param name defines the name of the task
  57677. * @param url defines the location of the image to load
  57678. */
  57679. constructor(
  57680. /**
  57681. * Defines the name of the task
  57682. */
  57683. name: string,
  57684. /**
  57685. * Defines the location of the image to load
  57686. */
  57687. url: string);
  57688. /**
  57689. * Execute the current task
  57690. * @param scene defines the scene where you want your assets to be loaded
  57691. * @param onSuccess is a callback called when the task is successfully executed
  57692. * @param onError is a callback called if an error occurs
  57693. */
  57694. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57695. }
  57696. /**
  57697. * Defines the interface used by texture loading tasks
  57698. */
  57699. export interface ITextureAssetTask<TEX extends BaseTexture> {
  57700. /**
  57701. * Gets the loaded texture
  57702. */
  57703. texture: TEX;
  57704. }
  57705. /**
  57706. * Define a task used by AssetsManager to load 2D textures
  57707. */
  57708. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  57709. /**
  57710. * Defines the name of the task
  57711. */
  57712. name: string;
  57713. /**
  57714. * Defines the location of the file to load
  57715. */
  57716. url: string;
  57717. /**
  57718. * Defines if mipmap should not be generated (default is false)
  57719. */
  57720. noMipmap?: boolean | undefined;
  57721. /**
  57722. * Defines if texture must be inverted on Y axis (default is false)
  57723. */
  57724. invertY?: boolean | undefined;
  57725. /**
  57726. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57727. */
  57728. samplingMode: number;
  57729. /**
  57730. * Gets the loaded texture
  57731. */
  57732. texture: Texture;
  57733. /**
  57734. * Callback called when the task is successful
  57735. */
  57736. onSuccess: (task: TextureAssetTask) => void;
  57737. /**
  57738. * Callback called when the task is successful
  57739. */
  57740. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  57741. /**
  57742. * Creates a new TextureAssetTask object
  57743. * @param name defines the name of the task
  57744. * @param url defines the location of the file to load
  57745. * @param noMipmap defines if mipmap should not be generated (default is false)
  57746. * @param invertY defines if texture must be inverted on Y axis (default is false)
  57747. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57748. */
  57749. constructor(
  57750. /**
  57751. * Defines the name of the task
  57752. */
  57753. name: string,
  57754. /**
  57755. * Defines the location of the file to load
  57756. */
  57757. url: string,
  57758. /**
  57759. * Defines if mipmap should not be generated (default is false)
  57760. */
  57761. noMipmap?: boolean | undefined,
  57762. /**
  57763. * Defines if texture must be inverted on Y axis (default is false)
  57764. */
  57765. invertY?: boolean | undefined,
  57766. /**
  57767. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  57768. */
  57769. samplingMode?: number);
  57770. /**
  57771. * Execute the current task
  57772. * @param scene defines the scene where you want your assets to be loaded
  57773. * @param onSuccess is a callback called when the task is successfully executed
  57774. * @param onError is a callback called if an error occurs
  57775. */
  57776. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57777. }
  57778. /**
  57779. * Define a task used by AssetsManager to load cube textures
  57780. */
  57781. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  57782. /**
  57783. * Defines the name of the task
  57784. */
  57785. name: string;
  57786. /**
  57787. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57788. */
  57789. url: string;
  57790. /**
  57791. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57792. */
  57793. extensions?: string[] | undefined;
  57794. /**
  57795. * Defines if mipmaps should not be generated (default is false)
  57796. */
  57797. noMipmap?: boolean | undefined;
  57798. /**
  57799. * Defines the explicit list of files (undefined by default)
  57800. */
  57801. files?: string[] | undefined;
  57802. /**
  57803. * Gets the loaded texture
  57804. */
  57805. texture: CubeTexture;
  57806. /**
  57807. * Callback called when the task is successful
  57808. */
  57809. onSuccess: (task: CubeTextureAssetTask) => void;
  57810. /**
  57811. * Callback called when the task is successful
  57812. */
  57813. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  57814. /**
  57815. * Creates a new CubeTextureAssetTask
  57816. * @param name defines the name of the task
  57817. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57818. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57819. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57820. * @param files defines the explicit list of files (undefined by default)
  57821. */
  57822. constructor(
  57823. /**
  57824. * Defines the name of the task
  57825. */
  57826. name: string,
  57827. /**
  57828. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  57829. */
  57830. url: string,
  57831. /**
  57832. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  57833. */
  57834. extensions?: string[] | undefined,
  57835. /**
  57836. * Defines if mipmaps should not be generated (default is false)
  57837. */
  57838. noMipmap?: boolean | undefined,
  57839. /**
  57840. * Defines the explicit list of files (undefined by default)
  57841. */
  57842. files?: string[] | undefined);
  57843. /**
  57844. * Execute the current task
  57845. * @param scene defines the scene where you want your assets to be loaded
  57846. * @param onSuccess is a callback called when the task is successfully executed
  57847. * @param onError is a callback called if an error occurs
  57848. */
  57849. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57850. }
  57851. /**
  57852. * Define a task used by AssetsManager to load HDR cube textures
  57853. */
  57854. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  57855. /**
  57856. * Defines the name of the task
  57857. */
  57858. name: string;
  57859. /**
  57860. * Defines the location of the file to load
  57861. */
  57862. url: string;
  57863. /**
  57864. * Defines the desired size (the more it increases the longer the generation will be)
  57865. */
  57866. size: number;
  57867. /**
  57868. * Defines if mipmaps should not be generated (default is false)
  57869. */
  57870. noMipmap: boolean;
  57871. /**
  57872. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57873. */
  57874. generateHarmonics: boolean;
  57875. /**
  57876. * 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)
  57877. */
  57878. gammaSpace: boolean;
  57879. /**
  57880. * Internal Use Only
  57881. */
  57882. reserved: boolean;
  57883. /**
  57884. * Gets the loaded texture
  57885. */
  57886. texture: HDRCubeTexture;
  57887. /**
  57888. * Callback called when the task is successful
  57889. */
  57890. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  57891. /**
  57892. * Callback called when the task is successful
  57893. */
  57894. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  57895. /**
  57896. * Creates a new HDRCubeTextureAssetTask object
  57897. * @param name defines the name of the task
  57898. * @param url defines the location of the file to load
  57899. * @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.
  57900. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57901. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57902. * @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)
  57903. * @param reserved Internal use only
  57904. */
  57905. constructor(
  57906. /**
  57907. * Defines the name of the task
  57908. */
  57909. name: string,
  57910. /**
  57911. * Defines the location of the file to load
  57912. */
  57913. url: string,
  57914. /**
  57915. * Defines the desired size (the more it increases the longer the generation will be)
  57916. */
  57917. size: number,
  57918. /**
  57919. * Defines if mipmaps should not be generated (default is false)
  57920. */
  57921. noMipmap?: boolean,
  57922. /**
  57923. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  57924. */
  57925. generateHarmonics?: boolean,
  57926. /**
  57927. * 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)
  57928. */
  57929. gammaSpace?: boolean,
  57930. /**
  57931. * Internal Use Only
  57932. */
  57933. reserved?: boolean);
  57934. /**
  57935. * Execute the current task
  57936. * @param scene defines the scene where you want your assets to be loaded
  57937. * @param onSuccess is a callback called when the task is successfully executed
  57938. * @param onError is a callback called if an error occurs
  57939. */
  57940. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  57941. }
  57942. /**
  57943. * Define a task used by AssetsManager to load Equirectangular cube textures
  57944. */
  57945. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  57946. /**
  57947. * Defines the name of the task
  57948. */
  57949. name: string;
  57950. /**
  57951. * Defines the location of the file to load
  57952. */
  57953. url: string;
  57954. /**
  57955. * Defines the desired size (the more it increases the longer the generation will be)
  57956. */
  57957. size: number;
  57958. /**
  57959. * Defines if mipmaps should not be generated (default is false)
  57960. */
  57961. noMipmap: boolean;
  57962. /**
  57963. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  57964. * but the standard material would require them in Gamma space) (default is true)
  57965. */
  57966. gammaSpace: boolean;
  57967. /**
  57968. * Gets the loaded texture
  57969. */
  57970. texture: EquiRectangularCubeTexture;
  57971. /**
  57972. * Callback called when the task is successful
  57973. */
  57974. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  57975. /**
  57976. * Callback called when the task is successful
  57977. */
  57978. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  57979. /**
  57980. * Creates a new EquiRectangularCubeTextureAssetTask object
  57981. * @param name defines the name of the task
  57982. * @param url defines the location of the file to load
  57983. * @param size defines the desired size (the more it increases the longer the generation will be)
  57984. * If the size is omitted this implies you are using a preprocessed cubemap.
  57985. * @param noMipmap defines if mipmaps should not be generated (default is false)
  57986. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  57987. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  57988. * (default is true)
  57989. */
  57990. constructor(
  57991. /**
  57992. * Defines the name of the task
  57993. */
  57994. name: string,
  57995. /**
  57996. * Defines the location of the file to load
  57997. */
  57998. url: string,
  57999. /**
  58000. * Defines the desired size (the more it increases the longer the generation will be)
  58001. */
  58002. size: number,
  58003. /**
  58004. * Defines if mipmaps should not be generated (default is false)
  58005. */
  58006. noMipmap?: boolean,
  58007. /**
  58008. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  58009. * but the standard material would require them in Gamma space) (default is true)
  58010. */
  58011. gammaSpace?: boolean);
  58012. /**
  58013. * Execute the current task
  58014. * @param scene defines the scene where you want your assets to be loaded
  58015. * @param onSuccess is a callback called when the task is successfully executed
  58016. * @param onError is a callback called if an error occurs
  58017. */
  58018. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  58019. }
  58020. /**
  58021. * This class can be used to easily import assets into a scene
  58022. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  58023. */
  58024. export class AssetsManager {
  58025. private _scene;
  58026. private _isLoading;
  58027. protected _tasks: AbstractAssetTask[];
  58028. protected _waitingTasksCount: number;
  58029. protected _totalTasksCount: number;
  58030. /**
  58031. * Callback called when all tasks are processed
  58032. */
  58033. onFinish: (tasks: AbstractAssetTask[]) => void;
  58034. /**
  58035. * Callback called when a task is successful
  58036. */
  58037. onTaskSuccess: (task: AbstractAssetTask) => void;
  58038. /**
  58039. * Callback called when a task had an error
  58040. */
  58041. onTaskError: (task: AbstractAssetTask) => void;
  58042. /**
  58043. * Callback called when a task is done (whatever the result is)
  58044. */
  58045. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  58046. /**
  58047. * Observable called when all tasks are processed
  58048. */
  58049. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  58050. /**
  58051. * Observable called when a task had an error
  58052. */
  58053. onTaskErrorObservable: Observable<AbstractAssetTask>;
  58054. /**
  58055. * Observable called when all tasks were executed
  58056. */
  58057. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  58058. /**
  58059. * Observable called when a task is done (whatever the result is)
  58060. */
  58061. onProgressObservable: Observable<IAssetsProgressEvent>;
  58062. /**
  58063. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  58064. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  58065. */
  58066. useDefaultLoadingScreen: boolean;
  58067. /**
  58068. * Creates a new AssetsManager
  58069. * @param scene defines the scene to work on
  58070. */
  58071. constructor(scene: Scene);
  58072. /**
  58073. * Add a MeshAssetTask to the list of active tasks
  58074. * @param taskName defines the name of the new task
  58075. * @param meshesNames defines the name of meshes to load
  58076. * @param rootUrl defines the root url to use to locate files
  58077. * @param sceneFilename defines the filename of the scene file
  58078. * @returns a new MeshAssetTask object
  58079. */
  58080. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  58081. /**
  58082. * Add a TextFileAssetTask to the list of active tasks
  58083. * @param taskName defines the name of the new task
  58084. * @param url defines the url of the file to load
  58085. * @returns a new TextFileAssetTask object
  58086. */
  58087. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  58088. /**
  58089. * Add a BinaryFileAssetTask to the list of active tasks
  58090. * @param taskName defines the name of the new task
  58091. * @param url defines the url of the file to load
  58092. * @returns a new BinaryFileAssetTask object
  58093. */
  58094. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  58095. /**
  58096. * Add a ImageAssetTask to the list of active tasks
  58097. * @param taskName defines the name of the new task
  58098. * @param url defines the url of the file to load
  58099. * @returns a new ImageAssetTask object
  58100. */
  58101. addImageTask(taskName: string, url: string): ImageAssetTask;
  58102. /**
  58103. * Add a TextureAssetTask to the list of active tasks
  58104. * @param taskName defines the name of the new task
  58105. * @param url defines the url of the file to load
  58106. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58107. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  58108. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  58109. * @returns a new TextureAssetTask object
  58110. */
  58111. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  58112. /**
  58113. * Add a CubeTextureAssetTask to the list of active tasks
  58114. * @param taskName defines the name of the new task
  58115. * @param url defines the url of the file to load
  58116. * @param extensions defines the extension to use to load the cube map (can be null)
  58117. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58118. * @param files defines the list of files to load (can be null)
  58119. * @returns a new CubeTextureAssetTask object
  58120. */
  58121. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  58122. /**
  58123. *
  58124. * Add a HDRCubeTextureAssetTask to the list of active tasks
  58125. * @param taskName defines the name of the new task
  58126. * @param url defines the url of the file to load
  58127. * @param size defines the size you want for the cubemap (can be null)
  58128. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58129. * @param generateHarmonics defines if you want to automatically generate (true by default)
  58130. * @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)
  58131. * @param reserved Internal use only
  58132. * @returns a new HDRCubeTextureAssetTask object
  58133. */
  58134. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  58135. /**
  58136. *
  58137. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  58138. * @param taskName defines the name of the new task
  58139. * @param url defines the url of the file to load
  58140. * @param size defines the size you want for the cubemap (can be null)
  58141. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  58142. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  58143. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  58144. * @returns a new EquiRectangularCubeTextureAssetTask object
  58145. */
  58146. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  58147. /**
  58148. * Remove a task from the assets manager.
  58149. * @param task the task to remove
  58150. */
  58151. removeTask(task: AbstractAssetTask): void;
  58152. private _decreaseWaitingTasksCount;
  58153. private _runTask;
  58154. /**
  58155. * Reset the AssetsManager and remove all tasks
  58156. * @return the current instance of the AssetsManager
  58157. */
  58158. reset(): AssetsManager;
  58159. /**
  58160. * Start the loading process
  58161. * @return the current instance of the AssetsManager
  58162. */
  58163. load(): AssetsManager;
  58164. /**
  58165. * Start the loading process as an async operation
  58166. * @return a promise returning the list of failed tasks
  58167. */
  58168. loadAsync(): Promise<void>;
  58169. }
  58170. }
  58171. declare module "babylonjs/Misc/deferred" {
  58172. /**
  58173. * Wrapper class for promise with external resolve and reject.
  58174. */
  58175. export class Deferred<T> {
  58176. /**
  58177. * The promise associated with this deferred object.
  58178. */
  58179. readonly promise: Promise<T>;
  58180. private _resolve;
  58181. private _reject;
  58182. /**
  58183. * The resolve method of the promise associated with this deferred object.
  58184. */
  58185. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  58186. /**
  58187. * The reject method of the promise associated with this deferred object.
  58188. */
  58189. readonly reject: (reason?: any) => void;
  58190. /**
  58191. * Constructor for this deferred object.
  58192. */
  58193. constructor();
  58194. }
  58195. }
  58196. declare module "babylonjs/Misc/meshExploder" {
  58197. import { Mesh } from "babylonjs/Meshes/mesh";
  58198. /**
  58199. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  58200. */
  58201. export class MeshExploder {
  58202. private _centerMesh;
  58203. private _meshes;
  58204. private _meshesOrigins;
  58205. private _toCenterVectors;
  58206. private _scaledDirection;
  58207. private _newPosition;
  58208. private _centerPosition;
  58209. /**
  58210. * Explodes meshes from a center mesh.
  58211. * @param meshes The meshes to explode.
  58212. * @param centerMesh The mesh to be center of explosion.
  58213. */
  58214. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  58215. private _setCenterMesh;
  58216. /**
  58217. * Get class name
  58218. * @returns "MeshExploder"
  58219. */
  58220. getClassName(): string;
  58221. /**
  58222. * "Exploded meshes"
  58223. * @returns Array of meshes with the centerMesh at index 0.
  58224. */
  58225. getMeshes(): Array<Mesh>;
  58226. /**
  58227. * Explodes meshes giving a specific direction
  58228. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  58229. */
  58230. explode(direction?: number): void;
  58231. }
  58232. }
  58233. declare module "babylonjs/Misc/filesInput" {
  58234. import { Engine } from "babylonjs/Engines/engine";
  58235. import { Scene } from "babylonjs/scene";
  58236. import { SceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  58237. /**
  58238. * Class used to help managing file picking and drag'n'drop
  58239. */
  58240. export class FilesInput {
  58241. /**
  58242. * List of files ready to be loaded
  58243. */
  58244. static readonly FilesToLoad: {
  58245. [key: string]: File;
  58246. };
  58247. /**
  58248. * Callback called when a file is processed
  58249. */
  58250. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  58251. private _engine;
  58252. private _currentScene;
  58253. private _sceneLoadedCallback;
  58254. private _progressCallback;
  58255. private _additionalRenderLoopLogicCallback;
  58256. private _textureLoadingCallback;
  58257. private _startingProcessingFilesCallback;
  58258. private _onReloadCallback;
  58259. private _errorCallback;
  58260. private _elementToMonitor;
  58261. private _sceneFileToLoad;
  58262. private _filesToLoad;
  58263. /**
  58264. * Creates a new FilesInput
  58265. * @param engine defines the rendering engine
  58266. * @param scene defines the hosting scene
  58267. * @param sceneLoadedCallback callback called when scene is loaded
  58268. * @param progressCallback callback called to track progress
  58269. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  58270. * @param textureLoadingCallback callback called when a texture is loading
  58271. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  58272. * @param onReloadCallback callback called when a reload is requested
  58273. * @param errorCallback callback call if an error occurs
  58274. */
  58275. 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);
  58276. private _dragEnterHandler;
  58277. private _dragOverHandler;
  58278. private _dropHandler;
  58279. /**
  58280. * Calls this function to listen to drag'n'drop events on a specific DOM element
  58281. * @param elementToMonitor defines the DOM element to track
  58282. */
  58283. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  58284. /**
  58285. * Release all associated resources
  58286. */
  58287. dispose(): void;
  58288. private renderFunction;
  58289. private drag;
  58290. private drop;
  58291. private _traverseFolder;
  58292. private _processFiles;
  58293. /**
  58294. * Load files from a drop event
  58295. * @param event defines the drop event to use as source
  58296. */
  58297. loadFiles(event: any): void;
  58298. private _processReload;
  58299. /**
  58300. * Reload the current scene from the loaded files
  58301. */
  58302. reload(): void;
  58303. }
  58304. }
  58305. declare module "babylonjs/Misc/HighDynamicRange/index" {
  58306. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  58307. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  58308. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  58309. }
  58310. declare module "babylonjs/Misc/sceneOptimizer" {
  58311. import { Scene, IDisposable } from "babylonjs/scene";
  58312. import { Observable } from "babylonjs/Misc/observable";
  58313. /**
  58314. * Defines the root class used to create scene optimization to use with SceneOptimizer
  58315. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58316. */
  58317. export class SceneOptimization {
  58318. /**
  58319. * Defines the priority of this optimization (0 by default which means first in the list)
  58320. */
  58321. priority: number;
  58322. /**
  58323. * Gets a string describing the action executed by the current optimization
  58324. * @returns description string
  58325. */
  58326. getDescription(): string;
  58327. /**
  58328. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58329. * @param scene defines the current scene where to apply this optimization
  58330. * @param optimizer defines the current optimizer
  58331. * @returns true if everything that can be done was applied
  58332. */
  58333. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58334. /**
  58335. * Creates the SceneOptimization object
  58336. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58337. * @param desc defines the description associated with the optimization
  58338. */
  58339. constructor(
  58340. /**
  58341. * Defines the priority of this optimization (0 by default which means first in the list)
  58342. */
  58343. priority?: number);
  58344. }
  58345. /**
  58346. * Defines an optimization used to reduce the size of render target textures
  58347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58348. */
  58349. export class TextureOptimization extends SceneOptimization {
  58350. /**
  58351. * Defines the priority of this optimization (0 by default which means first in the list)
  58352. */
  58353. priority: number;
  58354. /**
  58355. * 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
  58356. */
  58357. maximumSize: number;
  58358. /**
  58359. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58360. */
  58361. step: number;
  58362. /**
  58363. * Gets a string describing the action executed by the current optimization
  58364. * @returns description string
  58365. */
  58366. getDescription(): string;
  58367. /**
  58368. * Creates the TextureOptimization object
  58369. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58370. * @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
  58371. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58372. */
  58373. constructor(
  58374. /**
  58375. * Defines the priority of this optimization (0 by default which means first in the list)
  58376. */
  58377. priority?: number,
  58378. /**
  58379. * 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
  58380. */
  58381. maximumSize?: number,
  58382. /**
  58383. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  58384. */
  58385. step?: number);
  58386. /**
  58387. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58388. * @param scene defines the current scene where to apply this optimization
  58389. * @param optimizer defines the current optimizer
  58390. * @returns true if everything that can be done was applied
  58391. */
  58392. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58393. }
  58394. /**
  58395. * Defines an optimization used to increase or decrease the rendering resolution
  58396. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58397. */
  58398. export class HardwareScalingOptimization extends SceneOptimization {
  58399. /**
  58400. * Defines the priority of this optimization (0 by default which means first in the list)
  58401. */
  58402. priority: number;
  58403. /**
  58404. * Defines the maximum scale to use (2 by default)
  58405. */
  58406. maximumScale: number;
  58407. /**
  58408. * Defines the step to use between two passes (0.5 by default)
  58409. */
  58410. step: number;
  58411. private _currentScale;
  58412. private _directionOffset;
  58413. /**
  58414. * Gets a string describing the action executed by the current optimization
  58415. * @return description string
  58416. */
  58417. getDescription(): string;
  58418. /**
  58419. * Creates the HardwareScalingOptimization object
  58420. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58421. * @param maximumScale defines the maximum scale to use (2 by default)
  58422. * @param step defines the step to use between two passes (0.5 by default)
  58423. */
  58424. constructor(
  58425. /**
  58426. * Defines the priority of this optimization (0 by default which means first in the list)
  58427. */
  58428. priority?: number,
  58429. /**
  58430. * Defines the maximum scale to use (2 by default)
  58431. */
  58432. maximumScale?: number,
  58433. /**
  58434. * Defines the step to use between two passes (0.5 by default)
  58435. */
  58436. step?: number);
  58437. /**
  58438. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58439. * @param scene defines the current scene where to apply this optimization
  58440. * @param optimizer defines the current optimizer
  58441. * @returns true if everything that can be done was applied
  58442. */
  58443. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58444. }
  58445. /**
  58446. * Defines an optimization used to remove shadows
  58447. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58448. */
  58449. export class ShadowsOptimization extends SceneOptimization {
  58450. /**
  58451. * Gets a string describing the action executed by the current optimization
  58452. * @return description string
  58453. */
  58454. getDescription(): string;
  58455. /**
  58456. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58457. * @param scene defines the current scene where to apply this optimization
  58458. * @param optimizer defines the current optimizer
  58459. * @returns true if everything that can be done was applied
  58460. */
  58461. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58462. }
  58463. /**
  58464. * Defines an optimization used to turn post-processes off
  58465. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58466. */
  58467. export class PostProcessesOptimization extends SceneOptimization {
  58468. /**
  58469. * Gets a string describing the action executed by the current optimization
  58470. * @return description string
  58471. */
  58472. getDescription(): string;
  58473. /**
  58474. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58475. * @param scene defines the current scene where to apply this optimization
  58476. * @param optimizer defines the current optimizer
  58477. * @returns true if everything that can be done was applied
  58478. */
  58479. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58480. }
  58481. /**
  58482. * Defines an optimization used to turn lens flares off
  58483. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58484. */
  58485. export class LensFlaresOptimization extends SceneOptimization {
  58486. /**
  58487. * Gets a string describing the action executed by the current optimization
  58488. * @return description string
  58489. */
  58490. getDescription(): string;
  58491. /**
  58492. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58493. * @param scene defines the current scene where to apply this optimization
  58494. * @param optimizer defines the current optimizer
  58495. * @returns true if everything that can be done was applied
  58496. */
  58497. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58498. }
  58499. /**
  58500. * Defines an optimization based on user defined callback.
  58501. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58502. */
  58503. export class CustomOptimization extends SceneOptimization {
  58504. /**
  58505. * Callback called to apply the custom optimization.
  58506. */
  58507. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  58508. /**
  58509. * Callback called to get custom description
  58510. */
  58511. onGetDescription: () => string;
  58512. /**
  58513. * Gets a string describing the action executed by the current optimization
  58514. * @returns description string
  58515. */
  58516. getDescription(): string;
  58517. /**
  58518. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58519. * @param scene defines the current scene where to apply this optimization
  58520. * @param optimizer defines the current optimizer
  58521. * @returns true if everything that can be done was applied
  58522. */
  58523. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58524. }
  58525. /**
  58526. * Defines an optimization used to turn particles off
  58527. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58528. */
  58529. export class ParticlesOptimization extends SceneOptimization {
  58530. /**
  58531. * Gets a string describing the action executed by the current optimization
  58532. * @return description string
  58533. */
  58534. getDescription(): string;
  58535. /**
  58536. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58537. * @param scene defines the current scene where to apply this optimization
  58538. * @param optimizer defines the current optimizer
  58539. * @returns true if everything that can be done was applied
  58540. */
  58541. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58542. }
  58543. /**
  58544. * Defines an optimization used to turn render targets off
  58545. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58546. */
  58547. export class RenderTargetsOptimization extends SceneOptimization {
  58548. /**
  58549. * Gets a string describing the action executed by the current optimization
  58550. * @return description string
  58551. */
  58552. getDescription(): string;
  58553. /**
  58554. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58555. * @param scene defines the current scene where to apply this optimization
  58556. * @param optimizer defines the current optimizer
  58557. * @returns true if everything that can be done was applied
  58558. */
  58559. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  58560. }
  58561. /**
  58562. * Defines an optimization used to merge meshes with compatible materials
  58563. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58564. */
  58565. export class MergeMeshesOptimization extends SceneOptimization {
  58566. private static _UpdateSelectionTree;
  58567. /**
  58568. * Gets or sets a boolean which defines if optimization octree has to be updated
  58569. */
  58570. /**
  58571. * Gets or sets a boolean which defines if optimization octree has to be updated
  58572. */
  58573. static UpdateSelectionTree: boolean;
  58574. /**
  58575. * Gets a string describing the action executed by the current optimization
  58576. * @return description string
  58577. */
  58578. getDescription(): string;
  58579. private _canBeMerged;
  58580. /**
  58581. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  58582. * @param scene defines the current scene where to apply this optimization
  58583. * @param optimizer defines the current optimizer
  58584. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  58585. * @returns true if everything that can be done was applied
  58586. */
  58587. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  58588. }
  58589. /**
  58590. * Defines a list of options used by SceneOptimizer
  58591. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58592. */
  58593. export class SceneOptimizerOptions {
  58594. /**
  58595. * Defines the target frame rate to reach (60 by default)
  58596. */
  58597. targetFrameRate: number;
  58598. /**
  58599. * Defines the interval between two checkes (2000ms by default)
  58600. */
  58601. trackerDuration: number;
  58602. /**
  58603. * Gets the list of optimizations to apply
  58604. */
  58605. optimizations: SceneOptimization[];
  58606. /**
  58607. * Creates a new list of options used by SceneOptimizer
  58608. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  58609. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  58610. */
  58611. constructor(
  58612. /**
  58613. * Defines the target frame rate to reach (60 by default)
  58614. */
  58615. targetFrameRate?: number,
  58616. /**
  58617. * Defines the interval between two checkes (2000ms by default)
  58618. */
  58619. trackerDuration?: number);
  58620. /**
  58621. * Add a new optimization
  58622. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  58623. * @returns the current SceneOptimizerOptions
  58624. */
  58625. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  58626. /**
  58627. * Add a new custom optimization
  58628. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  58629. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  58630. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  58631. * @returns the current SceneOptimizerOptions
  58632. */
  58633. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  58634. /**
  58635. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  58636. * @param targetFrameRate defines the target frame rate (60 by default)
  58637. * @returns a SceneOptimizerOptions object
  58638. */
  58639. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58640. /**
  58641. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  58642. * @param targetFrameRate defines the target frame rate (60 by default)
  58643. * @returns a SceneOptimizerOptions object
  58644. */
  58645. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58646. /**
  58647. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  58648. * @param targetFrameRate defines the target frame rate (60 by default)
  58649. * @returns a SceneOptimizerOptions object
  58650. */
  58651. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  58652. }
  58653. /**
  58654. * Class used to run optimizations in order to reach a target frame rate
  58655. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  58656. */
  58657. export class SceneOptimizer implements IDisposable {
  58658. private _isRunning;
  58659. private _options;
  58660. private _scene;
  58661. private _currentPriorityLevel;
  58662. private _targetFrameRate;
  58663. private _trackerDuration;
  58664. private _currentFrameRate;
  58665. private _sceneDisposeObserver;
  58666. private _improvementMode;
  58667. /**
  58668. * Defines an observable called when the optimizer reaches the target frame rate
  58669. */
  58670. onSuccessObservable: Observable<SceneOptimizer>;
  58671. /**
  58672. * Defines an observable called when the optimizer enables an optimization
  58673. */
  58674. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  58675. /**
  58676. * Defines an observable called when the optimizer is not able to reach the target frame rate
  58677. */
  58678. onFailureObservable: Observable<SceneOptimizer>;
  58679. /**
  58680. * Gets a boolean indicating if the optimizer is in improvement mode
  58681. */
  58682. readonly isInImprovementMode: boolean;
  58683. /**
  58684. * Gets the current priority level (0 at start)
  58685. */
  58686. readonly currentPriorityLevel: number;
  58687. /**
  58688. * Gets the current frame rate checked by the SceneOptimizer
  58689. */
  58690. readonly currentFrameRate: number;
  58691. /**
  58692. * Gets or sets the current target frame rate (60 by default)
  58693. */
  58694. /**
  58695. * Gets or sets the current target frame rate (60 by default)
  58696. */
  58697. targetFrameRate: number;
  58698. /**
  58699. * Gets or sets the current interval between two checks (every 2000ms by default)
  58700. */
  58701. /**
  58702. * Gets or sets the current interval between two checks (every 2000ms by default)
  58703. */
  58704. trackerDuration: number;
  58705. /**
  58706. * Gets the list of active optimizations
  58707. */
  58708. readonly optimizations: SceneOptimization[];
  58709. /**
  58710. * Creates a new SceneOptimizer
  58711. * @param scene defines the scene to work on
  58712. * @param options defines the options to use with the SceneOptimizer
  58713. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  58714. * @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)
  58715. */
  58716. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  58717. /**
  58718. * Stops the current optimizer
  58719. */
  58720. stop(): void;
  58721. /**
  58722. * Reset the optimizer to initial step (current priority level = 0)
  58723. */
  58724. reset(): void;
  58725. /**
  58726. * Start the optimizer. By default it will try to reach a specific framerate
  58727. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  58728. */
  58729. start(): void;
  58730. private _checkCurrentState;
  58731. /**
  58732. * Release all resources
  58733. */
  58734. dispose(): void;
  58735. /**
  58736. * Helper function to create a SceneOptimizer with one single line of code
  58737. * @param scene defines the scene to work on
  58738. * @param options defines the options to use with the SceneOptimizer
  58739. * @param onSuccess defines a callback to call on success
  58740. * @param onFailure defines a callback to call on failure
  58741. * @returns the new SceneOptimizer object
  58742. */
  58743. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  58744. }
  58745. }
  58746. declare module "babylonjs/Misc/sceneSerializer" {
  58747. import { Scene } from "babylonjs/scene";
  58748. /**
  58749. * Class used to serialize a scene into a string
  58750. */
  58751. export class SceneSerializer {
  58752. /**
  58753. * Clear cache used by a previous serialization
  58754. */
  58755. static ClearCache(): void;
  58756. /**
  58757. * Serialize a scene into a JSON compatible object
  58758. * @param scene defines the scene to serialize
  58759. * @returns a JSON compatible object
  58760. */
  58761. static Serialize(scene: Scene): any;
  58762. /**
  58763. * Serialize a mesh into a JSON compatible object
  58764. * @param toSerialize defines the mesh to serialize
  58765. * @param withParents defines if parents must be serialized as well
  58766. * @param withChildren defines if children must be serialized as well
  58767. * @returns a JSON compatible object
  58768. */
  58769. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  58770. }
  58771. }
  58772. declare module "babylonjs/Misc/textureTools" {
  58773. import { Texture } from "babylonjs/Materials/Textures/texture";
  58774. /**
  58775. * Class used to host texture specific utilities
  58776. */
  58777. export class TextureTools {
  58778. /**
  58779. * Uses the GPU to create a copy texture rescaled at a given size
  58780. * @param texture Texture to copy from
  58781. * @param width defines the desired width
  58782. * @param height defines the desired height
  58783. * @param useBilinearMode defines if bilinear mode has to be used
  58784. * @return the generated texture
  58785. */
  58786. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  58787. }
  58788. }
  58789. declare module "babylonjs/Misc/videoRecorder" {
  58790. import { Nullable } from "babylonjs/types";
  58791. import { Engine } from "babylonjs/Engines/engine";
  58792. /**
  58793. * This represents the different options avilable for the video capture.
  58794. */
  58795. export interface VideoRecorderOptions {
  58796. /** Defines the mime type of the video */
  58797. mimeType: string;
  58798. /** Defines the video the video should be recorded at */
  58799. fps: number;
  58800. /** Defines the chunk size for the recording data */
  58801. recordChunckSize: number;
  58802. /** The audio tracks to attach to the record */
  58803. audioTracks?: MediaStreamTrack[];
  58804. }
  58805. /**
  58806. * This can helps recording videos from BabylonJS.
  58807. * This is based on the available WebRTC functionalities of the browser.
  58808. *
  58809. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  58810. */
  58811. export class VideoRecorder {
  58812. private static readonly _defaultOptions;
  58813. /**
  58814. * Returns wehther or not the VideoRecorder is available in your browser.
  58815. * @param engine Defines the Babylon Engine to check the support for
  58816. * @returns true if supported otherwise false
  58817. */
  58818. static IsSupported(engine: Engine): boolean;
  58819. private readonly _options;
  58820. private _canvas;
  58821. private _mediaRecorder;
  58822. private _recordedChunks;
  58823. private _fileName;
  58824. private _resolve;
  58825. private _reject;
  58826. /**
  58827. * True wether a recording is already in progress.
  58828. */
  58829. readonly isRecording: boolean;
  58830. /**
  58831. * Create a new VideoCapture object which can help converting what you see in Babylon to
  58832. * a video file.
  58833. * @param engine Defines the BabylonJS Engine you wish to record
  58834. * @param options Defines options that can be used to customized the capture
  58835. */
  58836. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  58837. /**
  58838. * Stops the current recording before the default capture timeout passed in the startRecording
  58839. * functions.
  58840. */
  58841. stopRecording(): void;
  58842. /**
  58843. * Starts recording the canvas for a max duration specified in parameters.
  58844. * @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.
  58845. * @param maxDuration Defines the maximum recording time in seconds.
  58846. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  58847. * @return a promise callback at the end of the recording with the video data in Blob.
  58848. */
  58849. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  58850. /**
  58851. * Releases internal resources used during the recording.
  58852. */
  58853. dispose(): void;
  58854. private _handleDataAvailable;
  58855. private _handleError;
  58856. private _handleStop;
  58857. }
  58858. }
  58859. declare module "babylonjs/Misc/screenshotTools" {
  58860. import { Camera } from "babylonjs/Cameras/camera";
  58861. import { Engine } from "babylonjs/Engines/engine";
  58862. /**
  58863. * Class containing a set of static utilities functions for screenshots
  58864. */
  58865. export class ScreenshotTools {
  58866. /**
  58867. * Captures a screenshot of the current rendering
  58868. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58869. * @param engine defines the rendering engine
  58870. * @param camera defines the source camera
  58871. * @param size This parameter can be set to a single number or to an object with the
  58872. * following (optional) properties: precision, width, height. If a single number is passed,
  58873. * it will be used for both width and height. If an object is passed, the screenshot size
  58874. * will be derived from the parameters. The precision property is a multiplier allowing
  58875. * rendering at a higher or lower resolution
  58876. * @param successCallback defines the callback receives a single parameter which contains the
  58877. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58878. * src parameter of an <img> to display it
  58879. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  58880. * Check your browser for supported MIME types
  58881. */
  58882. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  58883. /**
  58884. * Generates an image screenshot from the specified camera.
  58885. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  58886. * @param engine The engine to use for rendering
  58887. * @param camera The camera to use for rendering
  58888. * @param size This parameter can be set to a single number or to an object with the
  58889. * following (optional) properties: precision, width, height. If a single number is passed,
  58890. * it will be used for both width and height. If an object is passed, the screenshot size
  58891. * will be derived from the parameters. The precision property is a multiplier allowing
  58892. * rendering at a higher or lower resolution
  58893. * @param successCallback The callback receives a single parameter which contains the
  58894. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  58895. * src parameter of an <img> to display it
  58896. * @param mimeType The MIME type of the screenshot image (default: image/png).
  58897. * Check your browser for supported MIME types
  58898. * @param samples Texture samples (default: 1)
  58899. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  58900. * @param fileName A name for for the downloaded file.
  58901. */
  58902. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  58903. }
  58904. }
  58905. declare module "babylonjs/Misc/index" {
  58906. export * from "babylonjs/Misc/andOrNotEvaluator";
  58907. export * from "babylonjs/Misc/assetsManager";
  58908. export * from "babylonjs/Misc/dds";
  58909. export * from "babylonjs/Misc/decorators";
  58910. export * from "babylonjs/Misc/deferred";
  58911. export * from "babylonjs/Misc/environmentTextureTools";
  58912. export * from "babylonjs/Misc/meshExploder";
  58913. export * from "babylonjs/Misc/filesInput";
  58914. export * from "babylonjs/Misc/HighDynamicRange/index";
  58915. export * from "babylonjs/Misc/khronosTextureContainer";
  58916. export * from "babylonjs/Misc/observable";
  58917. export * from "babylonjs/Misc/performanceMonitor";
  58918. export * from "babylonjs/Misc/promise";
  58919. export * from "babylonjs/Misc/sceneOptimizer";
  58920. export * from "babylonjs/Misc/sceneSerializer";
  58921. export * from "babylonjs/Misc/smartArray";
  58922. export * from "babylonjs/Misc/stringDictionary";
  58923. export * from "babylonjs/Misc/tags";
  58924. export * from "babylonjs/Misc/textureTools";
  58925. export * from "babylonjs/Misc/tga";
  58926. export * from "babylonjs/Misc/tools";
  58927. export * from "babylonjs/Misc/videoRecorder";
  58928. export * from "babylonjs/Misc/virtualJoystick";
  58929. export * from "babylonjs/Misc/workerPool";
  58930. export * from "babylonjs/Misc/logger";
  58931. export * from "babylonjs/Misc/typeStore";
  58932. export * from "babylonjs/Misc/filesInputStore";
  58933. export * from "babylonjs/Misc/deepCopier";
  58934. export * from "babylonjs/Misc/pivotTools";
  58935. export * from "babylonjs/Misc/precisionDate";
  58936. export * from "babylonjs/Misc/screenshotTools";
  58937. export * from "babylonjs/Misc/typeStore";
  58938. export * from "babylonjs/Misc/webRequest";
  58939. export * from "babylonjs/Misc/iInspectable";
  58940. }
  58941. declare module "babylonjs/index" {
  58942. export * from "babylonjs/abstractScene";
  58943. export * from "babylonjs/Actions/index";
  58944. export * from "babylonjs/Animations/index";
  58945. export * from "babylonjs/assetContainer";
  58946. export * from "babylonjs/Audio/index";
  58947. export * from "babylonjs/Behaviors/index";
  58948. export * from "babylonjs/Bones/index";
  58949. export * from "babylonjs/Cameras/index";
  58950. export * from "babylonjs/Collisions/index";
  58951. export * from "babylonjs/Culling/index";
  58952. export * from "babylonjs/Debug/index";
  58953. export * from "babylonjs/Engines/index";
  58954. export * from "babylonjs/Events/index";
  58955. export * from "babylonjs/Gamepads/index";
  58956. export * from "babylonjs/Gizmos/index";
  58957. export * from "babylonjs/Helpers/index";
  58958. export * from "babylonjs/Instrumentation/index";
  58959. export * from "babylonjs/Layers/index";
  58960. export * from "babylonjs/LensFlares/index";
  58961. export * from "babylonjs/Lights/index";
  58962. export * from "babylonjs/Loading/index";
  58963. export * from "babylonjs/Materials/index";
  58964. export * from "babylonjs/Maths/index";
  58965. export * from "babylonjs/Meshes/index";
  58966. export * from "babylonjs/Morph/index";
  58967. export * from "babylonjs/node";
  58968. export * from "babylonjs/Offline/index";
  58969. export * from "babylonjs/Particles/index";
  58970. export * from "babylonjs/Physics/index";
  58971. export * from "babylonjs/PostProcesses/index";
  58972. export * from "babylonjs/Probes/index";
  58973. export * from "babylonjs/Rendering/index";
  58974. export * from "babylonjs/scene";
  58975. export * from "babylonjs/sceneComponent";
  58976. export * from "babylonjs/Sprites/index";
  58977. export * from "babylonjs/States/index";
  58978. export * from "babylonjs/Misc/index";
  58979. export * from "babylonjs/types";
  58980. }
  58981. declare module "babylonjs/Animations/pathCursor" {
  58982. import { Path2, Vector3 } from "babylonjs/Maths/math";
  58983. /**
  58984. * A cursor which tracks a point on a path
  58985. */
  58986. export class PathCursor {
  58987. private path;
  58988. /**
  58989. * Stores path cursor callbacks for when an onchange event is triggered
  58990. */
  58991. private _onchange;
  58992. /**
  58993. * The value of the path cursor
  58994. */
  58995. value: number;
  58996. /**
  58997. * The animation array of the path cursor
  58998. */
  58999. animations: Animation[];
  59000. /**
  59001. * Initializes the path cursor
  59002. * @param path The path to track
  59003. */
  59004. constructor(path: Path2);
  59005. /**
  59006. * Gets the cursor point on the path
  59007. * @returns A point on the path cursor at the cursor location
  59008. */
  59009. getPoint(): Vector3;
  59010. /**
  59011. * Moves the cursor ahead by the step amount
  59012. * @param step The amount to move the cursor forward
  59013. * @returns This path cursor
  59014. */
  59015. moveAhead(step?: number): PathCursor;
  59016. /**
  59017. * Moves the cursor behind by the step amount
  59018. * @param step The amount to move the cursor back
  59019. * @returns This path cursor
  59020. */
  59021. moveBack(step?: number): PathCursor;
  59022. /**
  59023. * Moves the cursor by the step amount
  59024. * If the step amount is greater than one, an exception is thrown
  59025. * @param step The amount to move the cursor
  59026. * @returns This path cursor
  59027. */
  59028. move(step: number): PathCursor;
  59029. /**
  59030. * Ensures that the value is limited between zero and one
  59031. * @returns This path cursor
  59032. */
  59033. private ensureLimits;
  59034. /**
  59035. * Runs onchange callbacks on change (used by the animation engine)
  59036. * @returns This path cursor
  59037. */
  59038. private raiseOnChange;
  59039. /**
  59040. * Executes a function on change
  59041. * @param f A path cursor onchange callback
  59042. * @returns This path cursor
  59043. */
  59044. onchange(f: (cursor: PathCursor) => void): PathCursor;
  59045. }
  59046. }
  59047. declare module "babylonjs/Legacy/legacy" {
  59048. import * as Babylon from "babylonjs/index";
  59049. export * from "babylonjs/index";
  59050. }
  59051. declare module "babylonjs/Shaders/blur.fragment" {
  59052. /** @hidden */
  59053. export var blurPixelShader: {
  59054. name: string;
  59055. shader: string;
  59056. };
  59057. }
  59058. declare module "babylonjs/Shaders/ShadersInclude/bones300Declaration" {
  59059. /** @hidden */
  59060. export var bones300Declaration: {
  59061. name: string;
  59062. shader: string;
  59063. };
  59064. }
  59065. declare module "babylonjs/Shaders/ShadersInclude/instances300Declaration" {
  59066. /** @hidden */
  59067. export var instances300Declaration: {
  59068. name: string;
  59069. shader: string;
  59070. };
  59071. }
  59072. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  59073. /** @hidden */
  59074. export var pointCloudVertexDeclaration: {
  59075. name: string;
  59076. shader: string;
  59077. };
  59078. }
  59079. // Mixins
  59080. interface Window {
  59081. mozIndexedDB: IDBFactory;
  59082. webkitIndexedDB: IDBFactory;
  59083. msIndexedDB: IDBFactory;
  59084. webkitURL: typeof URL;
  59085. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  59086. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  59087. WebGLRenderingContext: WebGLRenderingContext;
  59088. MSGesture: MSGesture;
  59089. CANNON: any;
  59090. AudioContext: AudioContext;
  59091. webkitAudioContext: AudioContext;
  59092. PointerEvent: any;
  59093. Math: Math;
  59094. Uint8Array: Uint8ArrayConstructor;
  59095. Float32Array: Float32ArrayConstructor;
  59096. mozURL: typeof URL;
  59097. msURL: typeof URL;
  59098. VRFrameData: any; // WebVR, from specs 1.1
  59099. DracoDecoderModule: any;
  59100. setImmediate(handler: (...args: any[]) => void): number;
  59101. }
  59102. interface HTMLCanvasElement {
  59103. requestPointerLock(): void;
  59104. msRequestPointerLock?(): void;
  59105. mozRequestPointerLock?(): void;
  59106. webkitRequestPointerLock?(): void;
  59107. /** Track wether a record is in progress */
  59108. isRecording: boolean;
  59109. /** Capture Stream method defined by some browsers */
  59110. captureStream(fps?: number): MediaStream;
  59111. }
  59112. interface CanvasRenderingContext2D {
  59113. msImageSmoothingEnabled: boolean;
  59114. }
  59115. interface MouseEvent {
  59116. mozMovementX: number;
  59117. mozMovementY: number;
  59118. webkitMovementX: number;
  59119. webkitMovementY: number;
  59120. msMovementX: number;
  59121. msMovementY: number;
  59122. }
  59123. interface Navigator {
  59124. mozGetVRDevices: (any: any) => any;
  59125. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59126. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59127. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  59128. webkitGetGamepads(): Gamepad[];
  59129. msGetGamepads(): Gamepad[];
  59130. webkitGamepads(): Gamepad[];
  59131. }
  59132. interface HTMLVideoElement {
  59133. mozSrcObject: any;
  59134. }
  59135. interface Math {
  59136. fround(x: number): number;
  59137. imul(a: number, b: number): number;
  59138. }
  59139. interface WebGLProgram {
  59140. context?: WebGLRenderingContext;
  59141. vertexShader?: WebGLShader;
  59142. fragmentShader?: WebGLShader;
  59143. isParallelCompiled: boolean;
  59144. onCompiled?: () => void;
  59145. }
  59146. interface WebGLRenderingContext {
  59147. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  59148. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  59149. vertexAttribDivisor(index: number, divisor: number): void;
  59150. createVertexArray(): any;
  59151. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  59152. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  59153. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  59154. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  59155. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  59156. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  59157. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  59158. // Queries
  59159. createQuery(): WebGLQuery;
  59160. deleteQuery(query: WebGLQuery): void;
  59161. beginQuery(target: number, query: WebGLQuery): void;
  59162. endQuery(target: number): void;
  59163. getQueryParameter(query: WebGLQuery, pname: number): any;
  59164. getQuery(target: number, pname: number): any;
  59165. MAX_SAMPLES: number;
  59166. RGBA8: number;
  59167. READ_FRAMEBUFFER: number;
  59168. DRAW_FRAMEBUFFER: number;
  59169. UNIFORM_BUFFER: number;
  59170. HALF_FLOAT_OES: number;
  59171. RGBA16F: number;
  59172. RGBA32F: number;
  59173. R32F: number;
  59174. RG32F: number;
  59175. RGB32F: number;
  59176. R16F: number;
  59177. RG16F: number;
  59178. RGB16F: number;
  59179. RED: number;
  59180. RG: number;
  59181. R8: number;
  59182. RG8: number;
  59183. UNSIGNED_INT_24_8: number;
  59184. DEPTH24_STENCIL8: number;
  59185. /* Multiple Render Targets */
  59186. drawBuffers(buffers: number[]): void;
  59187. readBuffer(src: number): void;
  59188. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  59189. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  59190. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  59191. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  59192. // Occlusion Query
  59193. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  59194. ANY_SAMPLES_PASSED: number;
  59195. QUERY_RESULT_AVAILABLE: number;
  59196. QUERY_RESULT: number;
  59197. }
  59198. interface WebGLBuffer {
  59199. references: number;
  59200. capacity: number;
  59201. is32Bits: boolean;
  59202. }
  59203. interface WebGLProgram {
  59204. transformFeedback?: WebGLTransformFeedback | null;
  59205. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  59206. }
  59207. interface EXT_disjoint_timer_query {
  59208. QUERY_COUNTER_BITS_EXT: number;
  59209. TIME_ELAPSED_EXT: number;
  59210. TIMESTAMP_EXT: number;
  59211. GPU_DISJOINT_EXT: number;
  59212. QUERY_RESULT_EXT: number;
  59213. QUERY_RESULT_AVAILABLE_EXT: number;
  59214. queryCounterEXT(query: WebGLQuery, target: number): void;
  59215. createQueryEXT(): WebGLQuery;
  59216. beginQueryEXT(target: number, query: WebGLQuery): void;
  59217. endQueryEXT(target: number): void;
  59218. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  59219. deleteQueryEXT(query: WebGLQuery): void;
  59220. }
  59221. interface WebGLUniformLocation {
  59222. _currentState: any;
  59223. }
  59224. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  59225. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  59226. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  59227. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59228. interface WebGLRenderingContext {
  59229. readonly RASTERIZER_DISCARD: number;
  59230. readonly DEPTH_COMPONENT24: number;
  59231. readonly TEXTURE_3D: number;
  59232. readonly TEXTURE_2D_ARRAY: number;
  59233. readonly TEXTURE_COMPARE_FUNC: number;
  59234. readonly TEXTURE_COMPARE_MODE: number;
  59235. readonly COMPARE_REF_TO_TEXTURE: number;
  59236. readonly TEXTURE_WRAP_R: number;
  59237. readonly HALF_FLOAT: number;
  59238. readonly RGB8: number;
  59239. readonly RED_INTEGER: number;
  59240. readonly RG_INTEGER: number;
  59241. readonly RGB_INTEGER: number;
  59242. readonly RGBA_INTEGER: number;
  59243. readonly R8_SNORM: number;
  59244. readonly RG8_SNORM: number;
  59245. readonly RGB8_SNORM: number;
  59246. readonly RGBA8_SNORM: number;
  59247. readonly R8I: number;
  59248. readonly RG8I: number;
  59249. readonly RGB8I: number;
  59250. readonly RGBA8I: number;
  59251. readonly R8UI: number;
  59252. readonly RG8UI: number;
  59253. readonly RGB8UI: number;
  59254. readonly RGBA8UI: number;
  59255. readonly R16I: number;
  59256. readonly RG16I: number;
  59257. readonly RGB16I: number;
  59258. readonly RGBA16I: number;
  59259. readonly R16UI: number;
  59260. readonly RG16UI: number;
  59261. readonly RGB16UI: number;
  59262. readonly RGBA16UI: number;
  59263. readonly R32I: number;
  59264. readonly RG32I: number;
  59265. readonly RGB32I: number;
  59266. readonly RGBA32I: number;
  59267. readonly R32UI: number;
  59268. readonly RG32UI: number;
  59269. readonly RGB32UI: number;
  59270. readonly RGBA32UI: number;
  59271. readonly RGB10_A2UI: number;
  59272. readonly R11F_G11F_B10F: number;
  59273. readonly RGB9_E5: number;
  59274. readonly RGB10_A2: number;
  59275. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  59276. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  59277. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  59278. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  59279. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  59280. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  59281. 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;
  59282. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  59283. readonly TRANSFORM_FEEDBACK: number;
  59284. readonly INTERLEAVED_ATTRIBS: number;
  59285. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  59286. createTransformFeedback(): WebGLTransformFeedback;
  59287. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  59288. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  59289. beginTransformFeedback(primitiveMode: number): void;
  59290. endTransformFeedback(): void;
  59291. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  59292. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59293. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59294. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  59295. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  59296. }
  59297. interface ImageBitmap {
  59298. readonly width: number;
  59299. readonly height: number;
  59300. close(): void;
  59301. }
  59302. interface WebGLQuery extends WebGLObject {
  59303. }
  59304. declare var WebGLQuery: {
  59305. prototype: WebGLQuery;
  59306. new(): WebGLQuery;
  59307. };
  59308. interface WebGLSampler extends WebGLObject {
  59309. }
  59310. declare var WebGLSampler: {
  59311. prototype: WebGLSampler;
  59312. new(): WebGLSampler;
  59313. };
  59314. interface WebGLSync extends WebGLObject {
  59315. }
  59316. declare var WebGLSync: {
  59317. prototype: WebGLSync;
  59318. new(): WebGLSync;
  59319. };
  59320. interface WebGLTransformFeedback extends WebGLObject {
  59321. }
  59322. declare var WebGLTransformFeedback: {
  59323. prototype: WebGLTransformFeedback;
  59324. new(): WebGLTransformFeedback;
  59325. };
  59326. interface WebGLVertexArrayObject extends WebGLObject {
  59327. }
  59328. declare var WebGLVertexArrayObject: {
  59329. prototype: WebGLVertexArrayObject;
  59330. new(): WebGLVertexArrayObject;
  59331. };
  59332. // Type definitions for WebVR API
  59333. // Project: https://w3c.github.io/webvr/
  59334. // Definitions by: six a <https://github.com/lostfictions>
  59335. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  59336. interface VRDisplay extends EventTarget {
  59337. /**
  59338. * Dictionary of capabilities describing the VRDisplay.
  59339. */
  59340. readonly capabilities: VRDisplayCapabilities;
  59341. /**
  59342. * z-depth defining the far plane of the eye view frustum
  59343. * enables mapping of values in the render target depth
  59344. * attachment to scene coordinates. Initially set to 10000.0.
  59345. */
  59346. depthFar: number;
  59347. /**
  59348. * z-depth defining the near plane of the eye view frustum
  59349. * enables mapping of values in the render target depth
  59350. * attachment to scene coordinates. Initially set to 0.01.
  59351. */
  59352. depthNear: number;
  59353. /**
  59354. * An identifier for this distinct VRDisplay. Used as an
  59355. * association point in the Gamepad API.
  59356. */
  59357. readonly displayId: number;
  59358. /**
  59359. * A display name, a user-readable name identifying it.
  59360. */
  59361. readonly displayName: string;
  59362. readonly isConnected: boolean;
  59363. readonly isPresenting: boolean;
  59364. /**
  59365. * If this VRDisplay supports room-scale experiences, the optional
  59366. * stage attribute contains details on the room-scale parameters.
  59367. */
  59368. readonly stageParameters: VRStageParameters | null;
  59369. /**
  59370. * Passing the value returned by `requestAnimationFrame` to
  59371. * `cancelAnimationFrame` will unregister the callback.
  59372. * @param handle Define the hanle of the request to cancel
  59373. */
  59374. cancelAnimationFrame(handle: number): void;
  59375. /**
  59376. * Stops presenting to the VRDisplay.
  59377. * @returns a promise to know when it stopped
  59378. */
  59379. exitPresent(): Promise<void>;
  59380. /**
  59381. * Return the current VREyeParameters for the given eye.
  59382. * @param whichEye Define the eye we want the parameter for
  59383. * @returns the eye parameters
  59384. */
  59385. getEyeParameters(whichEye: string): VREyeParameters;
  59386. /**
  59387. * Populates the passed VRFrameData with the information required to render
  59388. * the current frame.
  59389. * @param frameData Define the data structure to populate
  59390. * @returns true if ok otherwise false
  59391. */
  59392. getFrameData(frameData: VRFrameData): boolean;
  59393. /**
  59394. * Get the layers currently being presented.
  59395. * @returns the list of VR layers
  59396. */
  59397. getLayers(): VRLayer[];
  59398. /**
  59399. * Return a VRPose containing the future predicted pose of the VRDisplay
  59400. * when the current frame will be presented. The value returned will not
  59401. * change until JavaScript has returned control to the browser.
  59402. *
  59403. * The VRPose will contain the position, orientation, velocity,
  59404. * and acceleration of each of these properties.
  59405. * @returns the pose object
  59406. */
  59407. getPose(): VRPose;
  59408. /**
  59409. * Return the current instantaneous pose of the VRDisplay, with no
  59410. * prediction applied.
  59411. * @returns the current instantaneous pose
  59412. */
  59413. getImmediatePose(): VRPose;
  59414. /**
  59415. * The callback passed to `requestAnimationFrame` will be called
  59416. * any time a new frame should be rendered. When the VRDisplay is
  59417. * presenting the callback will be called at the native refresh
  59418. * rate of the HMD. When not presenting this function acts
  59419. * identically to how window.requestAnimationFrame acts. Content should
  59420. * make no assumptions of frame rate or vsync behavior as the HMD runs
  59421. * asynchronously from other displays and at differing refresh rates.
  59422. * @param callback Define the eaction to run next frame
  59423. * @returns the request handle it
  59424. */
  59425. requestAnimationFrame(callback: FrameRequestCallback): number;
  59426. /**
  59427. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  59428. * Repeat calls while already presenting will update the VRLayers being displayed.
  59429. * @param layers Define the list of layer to present
  59430. * @returns a promise to know when the request has been fulfilled
  59431. */
  59432. requestPresent(layers: VRLayer[]): Promise<void>;
  59433. /**
  59434. * Reset the pose for this display, treating its current position and
  59435. * orientation as the "origin/zero" values. VRPose.position,
  59436. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  59437. * updated when calling resetPose(). This should be called in only
  59438. * sitting-space experiences.
  59439. */
  59440. resetPose(): void;
  59441. /**
  59442. * The VRLayer provided to the VRDisplay will be captured and presented
  59443. * in the HMD. Calling this function has the same effect on the source
  59444. * canvas as any other operation that uses its source image, and canvases
  59445. * created without preserveDrawingBuffer set to true will be cleared.
  59446. * @param pose Define the pose to submit
  59447. */
  59448. submitFrame(pose?: VRPose): void;
  59449. }
  59450. declare var VRDisplay: {
  59451. prototype: VRDisplay;
  59452. new(): VRDisplay;
  59453. };
  59454. interface VRLayer {
  59455. leftBounds?: number[] | Float32Array | null;
  59456. rightBounds?: number[] | Float32Array | null;
  59457. source?: HTMLCanvasElement | null;
  59458. }
  59459. interface VRDisplayCapabilities {
  59460. readonly canPresent: boolean;
  59461. readonly hasExternalDisplay: boolean;
  59462. readonly hasOrientation: boolean;
  59463. readonly hasPosition: boolean;
  59464. readonly maxLayers: number;
  59465. }
  59466. interface VREyeParameters {
  59467. /** @deprecated */
  59468. readonly fieldOfView: VRFieldOfView;
  59469. readonly offset: Float32Array;
  59470. readonly renderHeight: number;
  59471. readonly renderWidth: number;
  59472. }
  59473. interface VRFieldOfView {
  59474. readonly downDegrees: number;
  59475. readonly leftDegrees: number;
  59476. readonly rightDegrees: number;
  59477. readonly upDegrees: number;
  59478. }
  59479. interface VRFrameData {
  59480. readonly leftProjectionMatrix: Float32Array;
  59481. readonly leftViewMatrix: Float32Array;
  59482. readonly pose: VRPose;
  59483. readonly rightProjectionMatrix: Float32Array;
  59484. readonly rightViewMatrix: Float32Array;
  59485. readonly timestamp: number;
  59486. }
  59487. interface VRPose {
  59488. readonly angularAcceleration: Float32Array | null;
  59489. readonly angularVelocity: Float32Array | null;
  59490. readonly linearAcceleration: Float32Array | null;
  59491. readonly linearVelocity: Float32Array | null;
  59492. readonly orientation: Float32Array | null;
  59493. readonly position: Float32Array | null;
  59494. readonly timestamp: number;
  59495. }
  59496. interface VRStageParameters {
  59497. sittingToStandingTransform?: Float32Array;
  59498. sizeX?: number;
  59499. sizeY?: number;
  59500. }
  59501. interface Navigator {
  59502. getVRDisplays(): Promise<VRDisplay[]>;
  59503. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  59504. }
  59505. interface Window {
  59506. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  59507. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  59508. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  59509. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59510. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  59511. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  59512. }
  59513. interface Gamepad {
  59514. readonly displayId: number;
  59515. }
  59516. interface XRDevice {
  59517. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  59518. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  59519. }
  59520. interface XRSession {
  59521. getInputSources(): Array<any>;
  59522. baseLayer: XRWebGLLayer;
  59523. requestFrameOfReference(type: string): Promise<void>;
  59524. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  59525. end(): Promise<void>;
  59526. requestAnimationFrame: Function;
  59527. addEventListener: Function;
  59528. }
  59529. interface XRSessionCreationOptions {
  59530. outputContext?: WebGLRenderingContext | null;
  59531. immersive?: boolean;
  59532. environmentIntegration?: boolean;
  59533. }
  59534. interface XRLayer {
  59535. getViewport: Function;
  59536. framebufferWidth: number;
  59537. framebufferHeight: number;
  59538. }
  59539. interface XRView {
  59540. projectionMatrix: Float32Array;
  59541. }
  59542. interface XRFrame {
  59543. getDevicePose: Function;
  59544. getInputPose: Function;
  59545. views: Array<XRView>;
  59546. baseLayer: XRLayer;
  59547. }
  59548. interface XRFrameOfReference {
  59549. }
  59550. interface XRWebGLLayer extends XRLayer {
  59551. framebuffer: WebGLFramebuffer;
  59552. }
  59553. declare var XRWebGLLayer: {
  59554. prototype: XRWebGLLayer;
  59555. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  59556. };
  59557. declare module "babylonjs" {
  59558. export * from "babylonjs/Legacy/legacy";
  59559. }
  59560. declare module BABYLON {
  59561. /** Alias type for value that can be null */
  59562. export type Nullable<T> = T | null;
  59563. /**
  59564. * Alias type for number that are floats
  59565. * @ignorenaming
  59566. */
  59567. export type float = number;
  59568. /**
  59569. * Alias type for number that are doubles.
  59570. * @ignorenaming
  59571. */
  59572. export type double = number;
  59573. /**
  59574. * Alias type for number that are integer
  59575. * @ignorenaming
  59576. */
  59577. export type int = number;
  59578. /** Alias type for number array or Float32Array */
  59579. export type FloatArray = number[] | Float32Array;
  59580. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  59581. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  59582. /**
  59583. * Alias for types that can be used by a Buffer or VertexBuffer.
  59584. */
  59585. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  59586. /**
  59587. * Alias type for primitive types
  59588. * @ignorenaming
  59589. */
  59590. type Primitive = undefined | null | boolean | string | number | Function;
  59591. /**
  59592. * Type modifier to make all the properties of an object Readonly
  59593. */
  59594. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  59595. /**
  59596. * Type modifier to make all the properties of an object Readonly recursively
  59597. */
  59598. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  59599. /** @hidden */
  59600. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  59601. }
  59602. /** @hidden */
  59603. /** @hidden */
  59604. type DeepImmutableObject<T> = {
  59605. readonly [K in keyof T]: DeepImmutable<T[K]>;
  59606. };
  59607. }
  59608. declare module BABYLON {
  59609. /**
  59610. * Class containing a set of static utilities functions for arrays.
  59611. */
  59612. export class ArrayTools {
  59613. /**
  59614. * Returns an array of the given size filled with element built from the given constructor and the paramters
  59615. * @param size the number of element to construct and put in the array
  59616. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  59617. * @returns a new array filled with new objects
  59618. */
  59619. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  59620. }
  59621. }
  59622. declare module BABYLON {
  59623. /**
  59624. * Scalar computation library
  59625. */
  59626. export class Scalar {
  59627. /**
  59628. * Two pi constants convenient for computation.
  59629. */
  59630. static TwoPi: number;
  59631. /**
  59632. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59633. * @param a number
  59634. * @param b number
  59635. * @param epsilon (default = 1.401298E-45)
  59636. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  59637. */
  59638. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  59639. /**
  59640. * Returns a string : the upper case translation of the number i to hexadecimal.
  59641. * @param i number
  59642. * @returns the upper case translation of the number i to hexadecimal.
  59643. */
  59644. static ToHex(i: number): string;
  59645. /**
  59646. * Returns -1 if value is negative and +1 is value is positive.
  59647. * @param value the value
  59648. * @returns the value itself if it's equal to zero.
  59649. */
  59650. static Sign(value: number): number;
  59651. /**
  59652. * Returns the value itself if it's between min and max.
  59653. * Returns min if the value is lower than min.
  59654. * Returns max if the value is greater than max.
  59655. * @param value the value to clmap
  59656. * @param min the min value to clamp to (default: 0)
  59657. * @param max the max value to clamp to (default: 1)
  59658. * @returns the clamped value
  59659. */
  59660. static Clamp(value: number, min?: number, max?: number): number;
  59661. /**
  59662. * the log2 of value.
  59663. * @param value the value to compute log2 of
  59664. * @returns the log2 of value.
  59665. */
  59666. static Log2(value: number): number;
  59667. /**
  59668. * Loops the value, so that it is never larger than length and never smaller than 0.
  59669. *
  59670. * This is similar to the modulo operator but it works with floating point numbers.
  59671. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  59672. * With t = 5 and length = 2.5, the result would be 0.0.
  59673. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  59674. * @param value the value
  59675. * @param length the length
  59676. * @returns the looped value
  59677. */
  59678. static Repeat(value: number, length: number): number;
  59679. /**
  59680. * Normalize the value between 0.0 and 1.0 using min and max values
  59681. * @param value value to normalize
  59682. * @param min max to normalize between
  59683. * @param max min to normalize between
  59684. * @returns the normalized value
  59685. */
  59686. static Normalize(value: number, min: number, max: number): number;
  59687. /**
  59688. * Denormalize the value from 0.0 and 1.0 using min and max values
  59689. * @param normalized value to denormalize
  59690. * @param min max to denormalize between
  59691. * @param max min to denormalize between
  59692. * @returns the denormalized value
  59693. */
  59694. static Denormalize(normalized: number, min: number, max: number): number;
  59695. /**
  59696. * Calculates the shortest difference between two given angles given in degrees.
  59697. * @param current current angle in degrees
  59698. * @param target target angle in degrees
  59699. * @returns the delta
  59700. */
  59701. static DeltaAngle(current: number, target: number): number;
  59702. /**
  59703. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  59704. * @param tx value
  59705. * @param length length
  59706. * @returns The returned value will move back and forth between 0 and length
  59707. */
  59708. static PingPong(tx: number, length: number): number;
  59709. /**
  59710. * Interpolates between min and max with smoothing at the limits.
  59711. *
  59712. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  59713. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  59714. * @param from from
  59715. * @param to to
  59716. * @param tx value
  59717. * @returns the smooth stepped value
  59718. */
  59719. static SmoothStep(from: number, to: number, tx: number): number;
  59720. /**
  59721. * Moves a value current towards target.
  59722. *
  59723. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  59724. * Negative values of maxDelta pushes the value away from target.
  59725. * @param current current value
  59726. * @param target target value
  59727. * @param maxDelta max distance to move
  59728. * @returns resulting value
  59729. */
  59730. static MoveTowards(current: number, target: number, maxDelta: number): number;
  59731. /**
  59732. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59733. *
  59734. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  59735. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  59736. * @param current current value
  59737. * @param target target value
  59738. * @param maxDelta max distance to move
  59739. * @returns resulting angle
  59740. */
  59741. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  59742. /**
  59743. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  59744. * @param start start value
  59745. * @param end target value
  59746. * @param amount amount to lerp between
  59747. * @returns the lerped value
  59748. */
  59749. static Lerp(start: number, end: number, amount: number): number;
  59750. /**
  59751. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  59752. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  59753. * @param start start value
  59754. * @param end target value
  59755. * @param amount amount to lerp between
  59756. * @returns the lerped value
  59757. */
  59758. static LerpAngle(start: number, end: number, amount: number): number;
  59759. /**
  59760. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  59761. * @param a start value
  59762. * @param b target value
  59763. * @param value value between a and b
  59764. * @returns the inverseLerp value
  59765. */
  59766. static InverseLerp(a: number, b: number, value: number): number;
  59767. /**
  59768. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  59769. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  59770. * @param value1 spline value
  59771. * @param tangent1 spline value
  59772. * @param value2 spline value
  59773. * @param tangent2 spline value
  59774. * @param amount input value
  59775. * @returns hermite result
  59776. */
  59777. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  59778. /**
  59779. * Returns a random float number between and min and max values
  59780. * @param min min value of random
  59781. * @param max max value of random
  59782. * @returns random value
  59783. */
  59784. static RandomRange(min: number, max: number): number;
  59785. /**
  59786. * This function returns percentage of a number in a given range.
  59787. *
  59788. * RangeToPercent(40,20,60) will return 0.5 (50%)
  59789. * RangeToPercent(34,0,100) will return 0.34 (34%)
  59790. * @param number to convert to percentage
  59791. * @param min min range
  59792. * @param max max range
  59793. * @returns the percentage
  59794. */
  59795. static RangeToPercent(number: number, min: number, max: number): number;
  59796. /**
  59797. * This function returns number that corresponds to the percentage in a given range.
  59798. *
  59799. * PercentToRange(0.34,0,100) will return 34.
  59800. * @param percent to convert to number
  59801. * @param min min range
  59802. * @param max max range
  59803. * @returns the number
  59804. */
  59805. static PercentToRange(percent: number, min: number, max: number): number;
  59806. /**
  59807. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  59808. * @param angle The angle to normalize in radian.
  59809. * @return The converted angle.
  59810. */
  59811. static NormalizeRadians(angle: number): number;
  59812. }
  59813. }
  59814. declare module BABYLON {
  59815. /**
  59816. * Constant used to convert a value to gamma space
  59817. * @ignorenaming
  59818. */
  59819. export const ToGammaSpace: number;
  59820. /**
  59821. * Constant used to convert a value to linear space
  59822. * @ignorenaming
  59823. */
  59824. export const ToLinearSpace = 2.2;
  59825. /**
  59826. * Constant used to define the minimal number value in Babylon.js
  59827. * @ignorenaming
  59828. */
  59829. let Epsilon: number;
  59830. /**
  59831. * Class used to hold a RBG color
  59832. */
  59833. export class Color3 {
  59834. /**
  59835. * Defines the red component (between 0 and 1, default is 0)
  59836. */
  59837. r: number;
  59838. /**
  59839. * Defines the green component (between 0 and 1, default is 0)
  59840. */
  59841. g: number;
  59842. /**
  59843. * Defines the blue component (between 0 and 1, default is 0)
  59844. */
  59845. b: number;
  59846. /**
  59847. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  59848. * @param r defines the red component (between 0 and 1, default is 0)
  59849. * @param g defines the green component (between 0 and 1, default is 0)
  59850. * @param b defines the blue component (between 0 and 1, default is 0)
  59851. */
  59852. constructor(
  59853. /**
  59854. * Defines the red component (between 0 and 1, default is 0)
  59855. */
  59856. r?: number,
  59857. /**
  59858. * Defines the green component (between 0 and 1, default is 0)
  59859. */
  59860. g?: number,
  59861. /**
  59862. * Defines the blue component (between 0 and 1, default is 0)
  59863. */
  59864. b?: number);
  59865. /**
  59866. * Creates a string with the Color3 current values
  59867. * @returns the string representation of the Color3 object
  59868. */
  59869. toString(): string;
  59870. /**
  59871. * Returns the string "Color3"
  59872. * @returns "Color3"
  59873. */
  59874. getClassName(): string;
  59875. /**
  59876. * Compute the Color3 hash code
  59877. * @returns an unique number that can be used to hash Color3 objects
  59878. */
  59879. getHashCode(): number;
  59880. /**
  59881. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  59882. * @param array defines the array where to store the r,g,b components
  59883. * @param index defines an optional index in the target array to define where to start storing values
  59884. * @returns the current Color3 object
  59885. */
  59886. toArray(array: FloatArray, index?: number): Color3;
  59887. /**
  59888. * Returns a new Color4 object from the current Color3 and the given alpha
  59889. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  59890. * @returns a new Color4 object
  59891. */
  59892. toColor4(alpha?: number): Color4;
  59893. /**
  59894. * Returns a new array populated with 3 numeric elements : red, green and blue values
  59895. * @returns the new array
  59896. */
  59897. asArray(): number[];
  59898. /**
  59899. * Returns the luminance value
  59900. * @returns a float value
  59901. */
  59902. toLuminance(): number;
  59903. /**
  59904. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  59905. * @param otherColor defines the second operand
  59906. * @returns the new Color3 object
  59907. */
  59908. multiply(otherColor: DeepImmutable<Color3>): Color3;
  59909. /**
  59910. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  59911. * @param otherColor defines the second operand
  59912. * @param result defines the Color3 object where to store the result
  59913. * @returns the current Color3
  59914. */
  59915. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59916. /**
  59917. * Determines equality between Color3 objects
  59918. * @param otherColor defines the second operand
  59919. * @returns true if the rgb values are equal to the given ones
  59920. */
  59921. equals(otherColor: DeepImmutable<Color3>): boolean;
  59922. /**
  59923. * Determines equality between the current Color3 object and a set of r,b,g values
  59924. * @param r defines the red component to check
  59925. * @param g defines the green component to check
  59926. * @param b defines the blue component to check
  59927. * @returns true if the rgb values are equal to the given ones
  59928. */
  59929. equalsFloats(r: number, g: number, b: number): boolean;
  59930. /**
  59931. * Multiplies in place each rgb value by scale
  59932. * @param scale defines the scaling factor
  59933. * @returns the updated Color3
  59934. */
  59935. scale(scale: number): Color3;
  59936. /**
  59937. * Multiplies the rgb values by scale and stores the result into "result"
  59938. * @param scale defines the scaling factor
  59939. * @param result defines the Color3 object where to store the result
  59940. * @returns the unmodified current Color3
  59941. */
  59942. scaleToRef(scale: number, result: Color3): Color3;
  59943. /**
  59944. * Scale the current Color3 values by a factor and add the result to a given Color3
  59945. * @param scale defines the scale factor
  59946. * @param result defines color to store the result into
  59947. * @returns the unmodified current Color3
  59948. */
  59949. scaleAndAddToRef(scale: number, result: Color3): Color3;
  59950. /**
  59951. * Clamps the rgb values by the min and max values and stores the result into "result"
  59952. * @param min defines minimum clamping value (default is 0)
  59953. * @param max defines maximum clamping value (default is 1)
  59954. * @param result defines color to store the result into
  59955. * @returns the original Color3
  59956. */
  59957. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  59958. /**
  59959. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  59960. * @param otherColor defines the second operand
  59961. * @returns the new Color3
  59962. */
  59963. add(otherColor: DeepImmutable<Color3>): Color3;
  59964. /**
  59965. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  59966. * @param otherColor defines the second operand
  59967. * @param result defines Color3 object to store the result into
  59968. * @returns the unmodified current Color3
  59969. */
  59970. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59971. /**
  59972. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  59973. * @param otherColor defines the second operand
  59974. * @returns the new Color3
  59975. */
  59976. subtract(otherColor: DeepImmutable<Color3>): Color3;
  59977. /**
  59978. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  59979. * @param otherColor defines the second operand
  59980. * @param result defines Color3 object to store the result into
  59981. * @returns the unmodified current Color3
  59982. */
  59983. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  59984. /**
  59985. * Copy the current object
  59986. * @returns a new Color3 copied the current one
  59987. */
  59988. clone(): Color3;
  59989. /**
  59990. * Copies the rgb values from the source in the current Color3
  59991. * @param source defines the source Color3 object
  59992. * @returns the updated Color3 object
  59993. */
  59994. copyFrom(source: DeepImmutable<Color3>): Color3;
  59995. /**
  59996. * Updates the Color3 rgb values from the given floats
  59997. * @param r defines the red component to read from
  59998. * @param g defines the green component to read from
  59999. * @param b defines the blue component to read from
  60000. * @returns the current Color3 object
  60001. */
  60002. copyFromFloats(r: number, g: number, b: number): Color3;
  60003. /**
  60004. * Updates the Color3 rgb values from the given floats
  60005. * @param r defines the red component to read from
  60006. * @param g defines the green component to read from
  60007. * @param b defines the blue component to read from
  60008. * @returns the current Color3 object
  60009. */
  60010. set(r: number, g: number, b: number): Color3;
  60011. /**
  60012. * Compute the Color3 hexadecimal code as a string
  60013. * @returns a string containing the hexadecimal representation of the Color3 object
  60014. */
  60015. toHexString(): string;
  60016. /**
  60017. * Computes a new Color3 converted from the current one to linear space
  60018. * @returns a new Color3 object
  60019. */
  60020. toLinearSpace(): Color3;
  60021. /**
  60022. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  60023. * @param convertedColor defines the Color3 object where to store the linear space version
  60024. * @returns the unmodified Color3
  60025. */
  60026. toLinearSpaceToRef(convertedColor: Color3): Color3;
  60027. /**
  60028. * Computes a new Color3 converted from the current one to gamma space
  60029. * @returns a new Color3 object
  60030. */
  60031. toGammaSpace(): Color3;
  60032. /**
  60033. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  60034. * @param convertedColor defines the Color3 object where to store the gamma space version
  60035. * @returns the unmodified Color3
  60036. */
  60037. toGammaSpaceToRef(convertedColor: Color3): Color3;
  60038. private static _BlackReadOnly;
  60039. /**
  60040. * Creates a new Color3 from the string containing valid hexadecimal values
  60041. * @param hex defines a string containing valid hexadecimal values
  60042. * @returns a new Color3 object
  60043. */
  60044. static FromHexString(hex: string): Color3;
  60045. /**
  60046. * Creates a new Color3 from the starting index of the given array
  60047. * @param array defines the source array
  60048. * @param offset defines an offset in the source array
  60049. * @returns a new Color3 object
  60050. */
  60051. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  60052. /**
  60053. * Creates a new Color3 from integer values (< 256)
  60054. * @param r defines the red component to read from (value between 0 and 255)
  60055. * @param g defines the green component to read from (value between 0 and 255)
  60056. * @param b defines the blue component to read from (value between 0 and 255)
  60057. * @returns a new Color3 object
  60058. */
  60059. static FromInts(r: number, g: number, b: number): Color3;
  60060. /**
  60061. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60062. * @param start defines the start Color3 value
  60063. * @param end defines the end Color3 value
  60064. * @param amount defines the gradient value between start and end
  60065. * @returns a new Color3 object
  60066. */
  60067. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  60068. /**
  60069. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  60070. * @param left defines the start value
  60071. * @param right defines the end value
  60072. * @param amount defines the gradient factor
  60073. * @param result defines the Color3 object where to store the result
  60074. */
  60075. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  60076. /**
  60077. * Returns a Color3 value containing a red color
  60078. * @returns a new Color3 object
  60079. */
  60080. static Red(): Color3;
  60081. /**
  60082. * Returns a Color3 value containing a green color
  60083. * @returns a new Color3 object
  60084. */
  60085. static Green(): Color3;
  60086. /**
  60087. * Returns a Color3 value containing a blue color
  60088. * @returns a new Color3 object
  60089. */
  60090. static Blue(): Color3;
  60091. /**
  60092. * Returns a Color3 value containing a black color
  60093. * @returns a new Color3 object
  60094. */
  60095. static Black(): Color3;
  60096. /**
  60097. * Gets a Color3 value containing a black color that must not be updated
  60098. */
  60099. static readonly BlackReadOnly: DeepImmutable<Color3>;
  60100. /**
  60101. * Returns a Color3 value containing a white color
  60102. * @returns a new Color3 object
  60103. */
  60104. static White(): Color3;
  60105. /**
  60106. * Returns a Color3 value containing a purple color
  60107. * @returns a new Color3 object
  60108. */
  60109. static Purple(): Color3;
  60110. /**
  60111. * Returns a Color3 value containing a magenta color
  60112. * @returns a new Color3 object
  60113. */
  60114. static Magenta(): Color3;
  60115. /**
  60116. * Returns a Color3 value containing a yellow color
  60117. * @returns a new Color3 object
  60118. */
  60119. static Yellow(): Color3;
  60120. /**
  60121. * Returns a Color3 value containing a gray color
  60122. * @returns a new Color3 object
  60123. */
  60124. static Gray(): Color3;
  60125. /**
  60126. * Returns a Color3 value containing a teal color
  60127. * @returns a new Color3 object
  60128. */
  60129. static Teal(): Color3;
  60130. /**
  60131. * Returns a Color3 value containing a random color
  60132. * @returns a new Color3 object
  60133. */
  60134. static Random(): Color3;
  60135. }
  60136. /**
  60137. * Class used to hold a RBGA color
  60138. */
  60139. export class Color4 {
  60140. /**
  60141. * Defines the red component (between 0 and 1, default is 0)
  60142. */
  60143. r: number;
  60144. /**
  60145. * Defines the green component (between 0 and 1, default is 0)
  60146. */
  60147. g: number;
  60148. /**
  60149. * Defines the blue component (between 0 and 1, default is 0)
  60150. */
  60151. b: number;
  60152. /**
  60153. * Defines the alpha component (between 0 and 1, default is 1)
  60154. */
  60155. a: number;
  60156. /**
  60157. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  60158. * @param r defines the red component (between 0 and 1, default is 0)
  60159. * @param g defines the green component (between 0 and 1, default is 0)
  60160. * @param b defines the blue component (between 0 and 1, default is 0)
  60161. * @param a defines the alpha component (between 0 and 1, default is 1)
  60162. */
  60163. constructor(
  60164. /**
  60165. * Defines the red component (between 0 and 1, default is 0)
  60166. */
  60167. r?: number,
  60168. /**
  60169. * Defines the green component (between 0 and 1, default is 0)
  60170. */
  60171. g?: number,
  60172. /**
  60173. * Defines the blue component (between 0 and 1, default is 0)
  60174. */
  60175. b?: number,
  60176. /**
  60177. * Defines the alpha component (between 0 and 1, default is 1)
  60178. */
  60179. a?: number);
  60180. /**
  60181. * Adds in place the given Color4 values to the current Color4 object
  60182. * @param right defines the second operand
  60183. * @returns the current updated Color4 object
  60184. */
  60185. addInPlace(right: DeepImmutable<Color4>): Color4;
  60186. /**
  60187. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  60188. * @returns the new array
  60189. */
  60190. asArray(): number[];
  60191. /**
  60192. * Stores from the starting index in the given array the Color4 successive values
  60193. * @param array defines the array where to store the r,g,b components
  60194. * @param index defines an optional index in the target array to define where to start storing values
  60195. * @returns the current Color4 object
  60196. */
  60197. toArray(array: number[], index?: number): Color4;
  60198. /**
  60199. * Determines equality between Color4 objects
  60200. * @param otherColor defines the second operand
  60201. * @returns true if the rgba values are equal to the given ones
  60202. */
  60203. equals(otherColor: DeepImmutable<Color4>): boolean;
  60204. /**
  60205. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  60206. * @param right defines the second operand
  60207. * @returns a new Color4 object
  60208. */
  60209. add(right: DeepImmutable<Color4>): Color4;
  60210. /**
  60211. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  60212. * @param right defines the second operand
  60213. * @returns a new Color4 object
  60214. */
  60215. subtract(right: DeepImmutable<Color4>): Color4;
  60216. /**
  60217. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  60218. * @param right defines the second operand
  60219. * @param result defines the Color4 object where to store the result
  60220. * @returns the current Color4 object
  60221. */
  60222. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  60223. /**
  60224. * Creates a new Color4 with the current Color4 values multiplied by scale
  60225. * @param scale defines the scaling factor to apply
  60226. * @returns a new Color4 object
  60227. */
  60228. scale(scale: number): Color4;
  60229. /**
  60230. * Multiplies the current Color4 values by scale and stores the result in "result"
  60231. * @param scale defines the scaling factor to apply
  60232. * @param result defines the Color4 object where to store the result
  60233. * @returns the current unmodified Color4
  60234. */
  60235. scaleToRef(scale: number, result: Color4): Color4;
  60236. /**
  60237. * Scale the current Color4 values by a factor and add the result to a given Color4
  60238. * @param scale defines the scale factor
  60239. * @param result defines the Color4 object where to store the result
  60240. * @returns the unmodified current Color4
  60241. */
  60242. scaleAndAddToRef(scale: number, result: Color4): Color4;
  60243. /**
  60244. * Clamps the rgb values by the min and max values and stores the result into "result"
  60245. * @param min defines minimum clamping value (default is 0)
  60246. * @param max defines maximum clamping value (default is 1)
  60247. * @param result defines color to store the result into.
  60248. * @returns the cuurent Color4
  60249. */
  60250. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  60251. /**
  60252. * Multipy an Color4 value by another and return a new Color4 object
  60253. * @param color defines the Color4 value to multiply by
  60254. * @returns a new Color4 object
  60255. */
  60256. multiply(color: Color4): Color4;
  60257. /**
  60258. * Multipy a Color4 value by another and push the result in a reference value
  60259. * @param color defines the Color4 value to multiply by
  60260. * @param result defines the Color4 to fill the result in
  60261. * @returns the result Color4
  60262. */
  60263. multiplyToRef(color: Color4, result: Color4): Color4;
  60264. /**
  60265. * Creates a string with the Color4 current values
  60266. * @returns the string representation of the Color4 object
  60267. */
  60268. toString(): string;
  60269. /**
  60270. * Returns the string "Color4"
  60271. * @returns "Color4"
  60272. */
  60273. getClassName(): string;
  60274. /**
  60275. * Compute the Color4 hash code
  60276. * @returns an unique number that can be used to hash Color4 objects
  60277. */
  60278. getHashCode(): number;
  60279. /**
  60280. * Creates a new Color4 copied from the current one
  60281. * @returns a new Color4 object
  60282. */
  60283. clone(): Color4;
  60284. /**
  60285. * Copies the given Color4 values into the current one
  60286. * @param source defines the source Color4 object
  60287. * @returns the current updated Color4 object
  60288. */
  60289. copyFrom(source: Color4): Color4;
  60290. /**
  60291. * Copies the given float values into the current one
  60292. * @param r defines the red component to read from
  60293. * @param g defines the green component to read from
  60294. * @param b defines the blue component to read from
  60295. * @param a defines the alpha component to read from
  60296. * @returns the current updated Color4 object
  60297. */
  60298. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  60299. /**
  60300. * Copies the given float values into the current one
  60301. * @param r defines the red component to read from
  60302. * @param g defines the green component to read from
  60303. * @param b defines the blue component to read from
  60304. * @param a defines the alpha component to read from
  60305. * @returns the current updated Color4 object
  60306. */
  60307. set(r: number, g: number, b: number, a: number): Color4;
  60308. /**
  60309. * Compute the Color4 hexadecimal code as a string
  60310. * @returns a string containing the hexadecimal representation of the Color4 object
  60311. */
  60312. toHexString(): string;
  60313. /**
  60314. * Computes a new Color4 converted from the current one to linear space
  60315. * @returns a new Color4 object
  60316. */
  60317. toLinearSpace(): Color4;
  60318. /**
  60319. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  60320. * @param convertedColor defines the Color4 object where to store the linear space version
  60321. * @returns the unmodified Color4
  60322. */
  60323. toLinearSpaceToRef(convertedColor: Color4): Color4;
  60324. /**
  60325. * Computes a new Color4 converted from the current one to gamma space
  60326. * @returns a new Color4 object
  60327. */
  60328. toGammaSpace(): Color4;
  60329. /**
  60330. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  60331. * @param convertedColor defines the Color4 object where to store the gamma space version
  60332. * @returns the unmodified Color4
  60333. */
  60334. toGammaSpaceToRef(convertedColor: Color4): Color4;
  60335. /**
  60336. * Creates a new Color4 from the string containing valid hexadecimal values
  60337. * @param hex defines a string containing valid hexadecimal values
  60338. * @returns a new Color4 object
  60339. */
  60340. static FromHexString(hex: string): Color4;
  60341. /**
  60342. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60343. * @param left defines the start value
  60344. * @param right defines the end value
  60345. * @param amount defines the gradient factor
  60346. * @returns a new Color4 object
  60347. */
  60348. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  60349. /**
  60350. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  60351. * @param left defines the start value
  60352. * @param right defines the end value
  60353. * @param amount defines the gradient factor
  60354. * @param result defines the Color4 object where to store data
  60355. */
  60356. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  60357. /**
  60358. * Creates a new Color4 from a Color3 and an alpha value
  60359. * @param color3 defines the source Color3 to read from
  60360. * @param alpha defines the alpha component (1.0 by default)
  60361. * @returns a new Color4 object
  60362. */
  60363. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  60364. /**
  60365. * Creates a new Color4 from the starting index element of the given array
  60366. * @param array defines the source array to read from
  60367. * @param offset defines the offset in the source array
  60368. * @returns a new Color4 object
  60369. */
  60370. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  60371. /**
  60372. * Creates a new Color3 from integer values (< 256)
  60373. * @param r defines the red component to read from (value between 0 and 255)
  60374. * @param g defines the green component to read from (value between 0 and 255)
  60375. * @param b defines the blue component to read from (value between 0 and 255)
  60376. * @param a defines the alpha component to read from (value between 0 and 255)
  60377. * @returns a new Color3 object
  60378. */
  60379. static FromInts(r: number, g: number, b: number, a: number): Color4;
  60380. /**
  60381. * Check the content of a given array and convert it to an array containing RGBA data
  60382. * If the original array was already containing count * 4 values then it is returned directly
  60383. * @param colors defines the array to check
  60384. * @param count defines the number of RGBA data to expect
  60385. * @returns an array containing count * 4 values (RGBA)
  60386. */
  60387. static CheckColors4(colors: number[], count: number): number[];
  60388. }
  60389. /**
  60390. * Class representing a vector containing 2 coordinates
  60391. */
  60392. export class Vector2 {
  60393. /** defines the first coordinate */
  60394. x: number;
  60395. /** defines the second coordinate */
  60396. y: number;
  60397. /**
  60398. * Creates a new Vector2 from the given x and y coordinates
  60399. * @param x defines the first coordinate
  60400. * @param y defines the second coordinate
  60401. */
  60402. constructor(
  60403. /** defines the first coordinate */
  60404. x?: number,
  60405. /** defines the second coordinate */
  60406. y?: number);
  60407. /**
  60408. * Gets a string with the Vector2 coordinates
  60409. * @returns a string with the Vector2 coordinates
  60410. */
  60411. toString(): string;
  60412. /**
  60413. * Gets class name
  60414. * @returns the string "Vector2"
  60415. */
  60416. getClassName(): string;
  60417. /**
  60418. * Gets current vector hash code
  60419. * @returns the Vector2 hash code as a number
  60420. */
  60421. getHashCode(): number;
  60422. /**
  60423. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  60424. * @param array defines the source array
  60425. * @param index defines the offset in source array
  60426. * @returns the current Vector2
  60427. */
  60428. toArray(array: FloatArray, index?: number): Vector2;
  60429. /**
  60430. * Copy the current vector to an array
  60431. * @returns a new array with 2 elements: the Vector2 coordinates.
  60432. */
  60433. asArray(): number[];
  60434. /**
  60435. * Sets the Vector2 coordinates with the given Vector2 coordinates
  60436. * @param source defines the source Vector2
  60437. * @returns the current updated Vector2
  60438. */
  60439. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  60440. /**
  60441. * Sets the Vector2 coordinates with the given floats
  60442. * @param x defines the first coordinate
  60443. * @param y defines the second coordinate
  60444. * @returns the current updated Vector2
  60445. */
  60446. copyFromFloats(x: number, y: number): Vector2;
  60447. /**
  60448. * Sets the Vector2 coordinates with the given floats
  60449. * @param x defines the first coordinate
  60450. * @param y defines the second coordinate
  60451. * @returns the current updated Vector2
  60452. */
  60453. set(x: number, y: number): Vector2;
  60454. /**
  60455. * Add another vector with the current one
  60456. * @param otherVector defines the other vector
  60457. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  60458. */
  60459. add(otherVector: DeepImmutable<Vector2>): Vector2;
  60460. /**
  60461. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  60462. * @param otherVector defines the other vector
  60463. * @param result defines the target vector
  60464. * @returns the unmodified current Vector2
  60465. */
  60466. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60467. /**
  60468. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  60469. * @param otherVector defines the other vector
  60470. * @returns the current updated Vector2
  60471. */
  60472. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60473. /**
  60474. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  60475. * @param otherVector defines the other vector
  60476. * @returns a new Vector2
  60477. */
  60478. addVector3(otherVector: Vector3): Vector2;
  60479. /**
  60480. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  60481. * @param otherVector defines the other vector
  60482. * @returns a new Vector2
  60483. */
  60484. subtract(otherVector: Vector2): Vector2;
  60485. /**
  60486. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  60487. * @param otherVector defines the other vector
  60488. * @param result defines the target vector
  60489. * @returns the unmodified current Vector2
  60490. */
  60491. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60492. /**
  60493. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  60494. * @param otherVector defines the other vector
  60495. * @returns the current updated Vector2
  60496. */
  60497. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60498. /**
  60499. * Multiplies in place the current Vector2 coordinates by the given ones
  60500. * @param otherVector defines the other vector
  60501. * @returns the current updated Vector2
  60502. */
  60503. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60504. /**
  60505. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  60506. * @param otherVector defines the other vector
  60507. * @returns a new Vector2
  60508. */
  60509. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  60510. /**
  60511. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  60512. * @param otherVector defines the other vector
  60513. * @param result defines the target vector
  60514. * @returns the unmodified current Vector2
  60515. */
  60516. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60517. /**
  60518. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  60519. * @param x defines the first coordinate
  60520. * @param y defines the second coordinate
  60521. * @returns a new Vector2
  60522. */
  60523. multiplyByFloats(x: number, y: number): Vector2;
  60524. /**
  60525. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  60526. * @param otherVector defines the other vector
  60527. * @returns a new Vector2
  60528. */
  60529. divide(otherVector: Vector2): Vector2;
  60530. /**
  60531. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  60532. * @param otherVector defines the other vector
  60533. * @param result defines the target vector
  60534. * @returns the unmodified current Vector2
  60535. */
  60536. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  60537. /**
  60538. * Divides the current Vector2 coordinates by the given ones
  60539. * @param otherVector defines the other vector
  60540. * @returns the current updated Vector2
  60541. */
  60542. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  60543. /**
  60544. * Gets a new Vector2 with current Vector2 negated coordinates
  60545. * @returns a new Vector2
  60546. */
  60547. negate(): Vector2;
  60548. /**
  60549. * Multiply the Vector2 coordinates by scale
  60550. * @param scale defines the scaling factor
  60551. * @returns the current updated Vector2
  60552. */
  60553. scaleInPlace(scale: number): Vector2;
  60554. /**
  60555. * Returns a new Vector2 scaled by "scale" from the current Vector2
  60556. * @param scale defines the scaling factor
  60557. * @returns a new Vector2
  60558. */
  60559. scale(scale: number): Vector2;
  60560. /**
  60561. * Scale the current Vector2 values by a factor to a given Vector2
  60562. * @param scale defines the scale factor
  60563. * @param result defines the Vector2 object where to store the result
  60564. * @returns the unmodified current Vector2
  60565. */
  60566. scaleToRef(scale: number, result: Vector2): Vector2;
  60567. /**
  60568. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  60569. * @param scale defines the scale factor
  60570. * @param result defines the Vector2 object where to store the result
  60571. * @returns the unmodified current Vector2
  60572. */
  60573. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  60574. /**
  60575. * Gets a boolean if two vectors are equals
  60576. * @param otherVector defines the other vector
  60577. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  60578. */
  60579. equals(otherVector: DeepImmutable<Vector2>): boolean;
  60580. /**
  60581. * Gets a boolean if two vectors are equals (using an epsilon value)
  60582. * @param otherVector defines the other vector
  60583. * @param epsilon defines the minimal distance to consider equality
  60584. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  60585. */
  60586. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  60587. /**
  60588. * Gets a new Vector2 from current Vector2 floored values
  60589. * @returns a new Vector2
  60590. */
  60591. floor(): Vector2;
  60592. /**
  60593. * Gets a new Vector2 from current Vector2 floored values
  60594. * @returns a new Vector2
  60595. */
  60596. fract(): Vector2;
  60597. /**
  60598. * Gets the length of the vector
  60599. * @returns the vector length (float)
  60600. */
  60601. length(): number;
  60602. /**
  60603. * Gets the vector squared length
  60604. * @returns the vector squared length (float)
  60605. */
  60606. lengthSquared(): number;
  60607. /**
  60608. * Normalize the vector
  60609. * @returns the current updated Vector2
  60610. */
  60611. normalize(): Vector2;
  60612. /**
  60613. * Gets a new Vector2 copied from the Vector2
  60614. * @returns a new Vector2
  60615. */
  60616. clone(): Vector2;
  60617. /**
  60618. * Gets a new Vector2(0, 0)
  60619. * @returns a new Vector2
  60620. */
  60621. static Zero(): Vector2;
  60622. /**
  60623. * Gets a new Vector2(1, 1)
  60624. * @returns a new Vector2
  60625. */
  60626. static One(): Vector2;
  60627. /**
  60628. * Gets a new Vector2 set from the given index element of the given array
  60629. * @param array defines the data source
  60630. * @param offset defines the offset in the data source
  60631. * @returns a new Vector2
  60632. */
  60633. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  60634. /**
  60635. * Sets "result" from the given index element of the given array
  60636. * @param array defines the data source
  60637. * @param offset defines the offset in the data source
  60638. * @param result defines the target vector
  60639. */
  60640. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  60641. /**
  60642. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  60643. * @param value1 defines 1st point of control
  60644. * @param value2 defines 2nd point of control
  60645. * @param value3 defines 3rd point of control
  60646. * @param value4 defines 4th point of control
  60647. * @param amount defines the interpolation factor
  60648. * @returns a new Vector2
  60649. */
  60650. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  60651. /**
  60652. * 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".
  60653. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  60654. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  60655. * @param value defines the value to clamp
  60656. * @param min defines the lower limit
  60657. * @param max defines the upper limit
  60658. * @returns a new Vector2
  60659. */
  60660. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  60661. /**
  60662. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  60663. * @param value1 defines the 1st control point
  60664. * @param tangent1 defines the outgoing tangent
  60665. * @param value2 defines the 2nd control point
  60666. * @param tangent2 defines the incoming tangent
  60667. * @param amount defines the interpolation factor
  60668. * @returns a new Vector2
  60669. */
  60670. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  60671. /**
  60672. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  60673. * @param start defines the start vector
  60674. * @param end defines the end vector
  60675. * @param amount defines the interpolation factor
  60676. * @returns a new Vector2
  60677. */
  60678. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  60679. /**
  60680. * Gets the dot product of the vector "left" and the vector "right"
  60681. * @param left defines first vector
  60682. * @param right defines second vector
  60683. * @returns the dot product (float)
  60684. */
  60685. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  60686. /**
  60687. * Returns a new Vector2 equal to the normalized given vector
  60688. * @param vector defines the vector to normalize
  60689. * @returns a new Vector2
  60690. */
  60691. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  60692. /**
  60693. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  60694. * @param left defines 1st vector
  60695. * @param right defines 2nd vector
  60696. * @returns a new Vector2
  60697. */
  60698. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60699. /**
  60700. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  60701. * @param left defines 1st vector
  60702. * @param right defines 2nd vector
  60703. * @returns a new Vector2
  60704. */
  60705. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  60706. /**
  60707. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  60708. * @param vector defines the vector to transform
  60709. * @param transformation defines the matrix to apply
  60710. * @returns a new Vector2
  60711. */
  60712. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  60713. /**
  60714. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  60715. * @param vector defines the vector to transform
  60716. * @param transformation defines the matrix to apply
  60717. * @param result defines the target vector
  60718. */
  60719. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  60720. /**
  60721. * Determines if a given vector is included in a triangle
  60722. * @param p defines the vector to test
  60723. * @param p0 defines 1st triangle point
  60724. * @param p1 defines 2nd triangle point
  60725. * @param p2 defines 3rd triangle point
  60726. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  60727. */
  60728. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  60729. /**
  60730. * Gets the distance between the vectors "value1" and "value2"
  60731. * @param value1 defines first vector
  60732. * @param value2 defines second vector
  60733. * @returns the distance between vectors
  60734. */
  60735. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60736. /**
  60737. * Returns the squared distance between the vectors "value1" and "value2"
  60738. * @param value1 defines first vector
  60739. * @param value2 defines second vector
  60740. * @returns the squared distance between vectors
  60741. */
  60742. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  60743. /**
  60744. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  60745. * @param value1 defines first vector
  60746. * @param value2 defines second vector
  60747. * @returns a new Vector2
  60748. */
  60749. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  60750. /**
  60751. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  60752. * @param p defines the middle point
  60753. * @param segA defines one point of the segment
  60754. * @param segB defines the other point of the segment
  60755. * @returns the shortest distance
  60756. */
  60757. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  60758. }
  60759. /**
  60760. * Classed used to store (x,y,z) vector representation
  60761. * A Vector3 is the main object used in 3D geometry
  60762. * It can represent etiher the coordinates of a point the space, either a direction
  60763. * Reminder: js uses a left handed forward facing system
  60764. */
  60765. export class Vector3 {
  60766. /**
  60767. * Defines the first coordinates (on X axis)
  60768. */
  60769. x: number;
  60770. /**
  60771. * Defines the second coordinates (on Y axis)
  60772. */
  60773. y: number;
  60774. /**
  60775. * Defines the third coordinates (on Z axis)
  60776. */
  60777. z: number;
  60778. private static _UpReadOnly;
  60779. /**
  60780. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  60781. * @param x defines the first coordinates (on X axis)
  60782. * @param y defines the second coordinates (on Y axis)
  60783. * @param z defines the third coordinates (on Z axis)
  60784. */
  60785. constructor(
  60786. /**
  60787. * Defines the first coordinates (on X axis)
  60788. */
  60789. x?: number,
  60790. /**
  60791. * Defines the second coordinates (on Y axis)
  60792. */
  60793. y?: number,
  60794. /**
  60795. * Defines the third coordinates (on Z axis)
  60796. */
  60797. z?: number);
  60798. /**
  60799. * Creates a string representation of the Vector3
  60800. * @returns a string with the Vector3 coordinates.
  60801. */
  60802. toString(): string;
  60803. /**
  60804. * Gets the class name
  60805. * @returns the string "Vector3"
  60806. */
  60807. getClassName(): string;
  60808. /**
  60809. * Creates the Vector3 hash code
  60810. * @returns a number which tends to be unique between Vector3 instances
  60811. */
  60812. getHashCode(): number;
  60813. /**
  60814. * Creates an array containing three elements : the coordinates of the Vector3
  60815. * @returns a new array of numbers
  60816. */
  60817. asArray(): number[];
  60818. /**
  60819. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  60820. * @param array defines the destination array
  60821. * @param index defines the offset in the destination array
  60822. * @returns the current Vector3
  60823. */
  60824. toArray(array: FloatArray, index?: number): Vector3;
  60825. /**
  60826. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  60827. * @returns a new Quaternion object, computed from the Vector3 coordinates
  60828. */
  60829. toQuaternion(): Quaternion;
  60830. /**
  60831. * Adds the given vector to the current Vector3
  60832. * @param otherVector defines the second operand
  60833. * @returns the current updated Vector3
  60834. */
  60835. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60836. /**
  60837. * Adds the given coordinates to the current Vector3
  60838. * @param x defines the x coordinate of the operand
  60839. * @param y defines the y coordinate of the operand
  60840. * @param z defines the z coordinate of the operand
  60841. * @returns the current updated Vector3
  60842. */
  60843. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  60844. /**
  60845. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  60846. * @param otherVector defines the second operand
  60847. * @returns the resulting Vector3
  60848. */
  60849. add(otherVector: DeepImmutable<Vector3>): Vector3;
  60850. /**
  60851. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  60852. * @param otherVector defines the second operand
  60853. * @param result defines the Vector3 object where to store the result
  60854. * @returns the current Vector3
  60855. */
  60856. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60857. /**
  60858. * Subtract the given vector from the current Vector3
  60859. * @param otherVector defines the second operand
  60860. * @returns the current updated Vector3
  60861. */
  60862. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60863. /**
  60864. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  60865. * @param otherVector defines the second operand
  60866. * @returns the resulting Vector3
  60867. */
  60868. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  60869. /**
  60870. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  60871. * @param otherVector defines the second operand
  60872. * @param result defines the Vector3 object where to store the result
  60873. * @returns the current Vector3
  60874. */
  60875. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60876. /**
  60877. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  60878. * @param x defines the x coordinate of the operand
  60879. * @param y defines the y coordinate of the operand
  60880. * @param z defines the z coordinate of the operand
  60881. * @returns the resulting Vector3
  60882. */
  60883. subtractFromFloats(x: number, y: number, z: number): Vector3;
  60884. /**
  60885. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  60886. * @param x defines the x coordinate of the operand
  60887. * @param y defines the y coordinate of the operand
  60888. * @param z defines the z coordinate of the operand
  60889. * @param result defines the Vector3 object where to store the result
  60890. * @returns the current Vector3
  60891. */
  60892. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  60893. /**
  60894. * Gets a new Vector3 set with the current Vector3 negated coordinates
  60895. * @returns a new Vector3
  60896. */
  60897. negate(): Vector3;
  60898. /**
  60899. * Multiplies the Vector3 coordinates by the float "scale"
  60900. * @param scale defines the multiplier factor
  60901. * @returns the current updated Vector3
  60902. */
  60903. scaleInPlace(scale: number): Vector3;
  60904. /**
  60905. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  60906. * @param scale defines the multiplier factor
  60907. * @returns a new Vector3
  60908. */
  60909. scale(scale: number): Vector3;
  60910. /**
  60911. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  60912. * @param scale defines the multiplier factor
  60913. * @param result defines the Vector3 object where to store the result
  60914. * @returns the current Vector3
  60915. */
  60916. scaleToRef(scale: number, result: Vector3): Vector3;
  60917. /**
  60918. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  60919. * @param scale defines the scale factor
  60920. * @param result defines the Vector3 object where to store the result
  60921. * @returns the unmodified current Vector3
  60922. */
  60923. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  60924. /**
  60925. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  60926. * @param otherVector defines the second operand
  60927. * @returns true if both vectors are equals
  60928. */
  60929. equals(otherVector: DeepImmutable<Vector3>): boolean;
  60930. /**
  60931. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  60932. * @param otherVector defines the second operand
  60933. * @param epsilon defines the minimal distance to define values as equals
  60934. * @returns true if both vectors are distant less than epsilon
  60935. */
  60936. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  60937. /**
  60938. * Returns true if the current Vector3 coordinates equals the given floats
  60939. * @param x defines the x coordinate of the operand
  60940. * @param y defines the y coordinate of the operand
  60941. * @param z defines the z coordinate of the operand
  60942. * @returns true if both vectors are equals
  60943. */
  60944. equalsToFloats(x: number, y: number, z: number): boolean;
  60945. /**
  60946. * Multiplies the current Vector3 coordinates by the given ones
  60947. * @param otherVector defines the second operand
  60948. * @returns the current updated Vector3
  60949. */
  60950. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  60951. /**
  60952. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  60953. * @param otherVector defines the second operand
  60954. * @returns the new Vector3
  60955. */
  60956. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  60957. /**
  60958. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  60959. * @param otherVector defines the second operand
  60960. * @param result defines the Vector3 object where to store the result
  60961. * @returns the current Vector3
  60962. */
  60963. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60964. /**
  60965. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  60966. * @param x defines the x coordinate of the operand
  60967. * @param y defines the y coordinate of the operand
  60968. * @param z defines the z coordinate of the operand
  60969. * @returns the new Vector3
  60970. */
  60971. multiplyByFloats(x: number, y: number, z: number): Vector3;
  60972. /**
  60973. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  60974. * @param otherVector defines the second operand
  60975. * @returns the new Vector3
  60976. */
  60977. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  60978. /**
  60979. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  60980. * @param otherVector defines the second operand
  60981. * @param result defines the Vector3 object where to store the result
  60982. * @returns the current Vector3
  60983. */
  60984. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  60985. /**
  60986. * Divides the current Vector3 coordinates by the given ones.
  60987. * @param otherVector defines the second operand
  60988. * @returns the current updated Vector3
  60989. */
  60990. divideInPlace(otherVector: Vector3): Vector3;
  60991. /**
  60992. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  60993. * @param other defines the second operand
  60994. * @returns the current updated Vector3
  60995. */
  60996. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  60997. /**
  60998. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  60999. * @param other defines the second operand
  61000. * @returns the current updated Vector3
  61001. */
  61002. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  61003. /**
  61004. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  61005. * @param x defines the x coordinate of the operand
  61006. * @param y defines the y coordinate of the operand
  61007. * @param z defines the z coordinate of the operand
  61008. * @returns the current updated Vector3
  61009. */
  61010. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61011. /**
  61012. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  61013. * @param x defines the x coordinate of the operand
  61014. * @param y defines the y coordinate of the operand
  61015. * @param z defines the z coordinate of the operand
  61016. * @returns the current updated Vector3
  61017. */
  61018. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  61019. /**
  61020. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  61021. * Check if is non uniform within a certain amount of decimal places to account for this
  61022. * @param epsilon the amount the values can differ
  61023. * @returns if the the vector is non uniform to a certain number of decimal places
  61024. */
  61025. isNonUniformWithinEpsilon(epsilon: number): boolean;
  61026. /**
  61027. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  61028. */
  61029. readonly isNonUniform: boolean;
  61030. /**
  61031. * Gets a new Vector3 from current Vector3 floored values
  61032. * @returns a new Vector3
  61033. */
  61034. floor(): Vector3;
  61035. /**
  61036. * Gets a new Vector3 from current Vector3 floored values
  61037. * @returns a new Vector3
  61038. */
  61039. fract(): Vector3;
  61040. /**
  61041. * Gets the length of the Vector3
  61042. * @returns the length of the Vecto3
  61043. */
  61044. length(): number;
  61045. /**
  61046. * Gets the squared length of the Vector3
  61047. * @returns squared length of the Vector3
  61048. */
  61049. lengthSquared(): number;
  61050. /**
  61051. * Normalize the current Vector3.
  61052. * Please note that this is an in place operation.
  61053. * @returns the current updated Vector3
  61054. */
  61055. normalize(): Vector3;
  61056. /**
  61057. * Reorders the x y z properties of the vector in place
  61058. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  61059. * @returns the current updated vector
  61060. */
  61061. reorderInPlace(order: string): this;
  61062. /**
  61063. * Rotates the vector around 0,0,0 by a quaternion
  61064. * @param quaternion the rotation quaternion
  61065. * @param result vector to store the result
  61066. * @returns the resulting vector
  61067. */
  61068. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  61069. /**
  61070. * Rotates a vector around a given point
  61071. * @param quaternion the rotation quaternion
  61072. * @param point the point to rotate around
  61073. * @param result vector to store the result
  61074. * @returns the resulting vector
  61075. */
  61076. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  61077. /**
  61078. * Normalize the current Vector3 with the given input length.
  61079. * Please note that this is an in place operation.
  61080. * @param len the length of the vector
  61081. * @returns the current updated Vector3
  61082. */
  61083. normalizeFromLength(len: number): Vector3;
  61084. /**
  61085. * Normalize the current Vector3 to a new vector
  61086. * @returns the new Vector3
  61087. */
  61088. normalizeToNew(): Vector3;
  61089. /**
  61090. * Normalize the current Vector3 to the reference
  61091. * @param reference define the Vector3 to update
  61092. * @returns the updated Vector3
  61093. */
  61094. normalizeToRef(reference: DeepImmutable<Vector3>): Vector3;
  61095. /**
  61096. * Creates a new Vector3 copied from the current Vector3
  61097. * @returns the new Vector3
  61098. */
  61099. clone(): Vector3;
  61100. /**
  61101. * Copies the given vector coordinates to the current Vector3 ones
  61102. * @param source defines the source Vector3
  61103. * @returns the current updated Vector3
  61104. */
  61105. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  61106. /**
  61107. * Copies the given floats to the current Vector3 coordinates
  61108. * @param x defines the x coordinate of the operand
  61109. * @param y defines the y coordinate of the operand
  61110. * @param z defines the z coordinate of the operand
  61111. * @returns the current updated Vector3
  61112. */
  61113. copyFromFloats(x: number, y: number, z: number): Vector3;
  61114. /**
  61115. * Copies the given floats to the current Vector3 coordinates
  61116. * @param x defines the x coordinate of the operand
  61117. * @param y defines the y coordinate of the operand
  61118. * @param z defines the z coordinate of the operand
  61119. * @returns the current updated Vector3
  61120. */
  61121. set(x: number, y: number, z: number): Vector3;
  61122. /**
  61123. * Copies the given float to the current Vector3 coordinates
  61124. * @param v defines the x, y and z coordinates of the operand
  61125. * @returns the current updated Vector3
  61126. */
  61127. setAll(v: number): Vector3;
  61128. /**
  61129. * Get the clip factor between two vectors
  61130. * @param vector0 defines the first operand
  61131. * @param vector1 defines the second operand
  61132. * @param axis defines the axis to use
  61133. * @param size defines the size along the axis
  61134. * @returns the clip factor
  61135. */
  61136. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  61137. /**
  61138. * Get angle between two vectors
  61139. * @param vector0 angle between vector0 and vector1
  61140. * @param vector1 angle between vector0 and vector1
  61141. * @param normal direction of the normal
  61142. * @return the angle between vector0 and vector1
  61143. */
  61144. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  61145. /**
  61146. * Returns a new Vector3 set from the index "offset" of the given array
  61147. * @param array defines the source array
  61148. * @param offset defines the offset in the source array
  61149. * @returns the new Vector3
  61150. */
  61151. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  61152. /**
  61153. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  61154. * This function is deprecated. Use FromArray instead
  61155. * @param array defines the source array
  61156. * @param offset defines the offset in the source array
  61157. * @returns the new Vector3
  61158. */
  61159. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  61160. /**
  61161. * Sets the given vector "result" with the element values from the index "offset" of the given array
  61162. * @param array defines the source array
  61163. * @param offset defines the offset in the source array
  61164. * @param result defines the Vector3 where to store the result
  61165. */
  61166. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  61167. /**
  61168. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  61169. * This function is deprecated. Use FromArrayToRef instead.
  61170. * @param array defines the source array
  61171. * @param offset defines the offset in the source array
  61172. * @param result defines the Vector3 where to store the result
  61173. */
  61174. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  61175. /**
  61176. * Sets the given vector "result" with the given floats.
  61177. * @param x defines the x coordinate of the source
  61178. * @param y defines the y coordinate of the source
  61179. * @param z defines the z coordinate of the source
  61180. * @param result defines the Vector3 where to store the result
  61181. */
  61182. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  61183. /**
  61184. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  61185. * @returns a new empty Vector3
  61186. */
  61187. static Zero(): Vector3;
  61188. /**
  61189. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  61190. * @returns a new unit Vector3
  61191. */
  61192. static One(): Vector3;
  61193. /**
  61194. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  61195. * @returns a new up Vector3
  61196. */
  61197. static Up(): Vector3;
  61198. /**
  61199. * Gets a up Vector3 that must not be updated
  61200. */
  61201. static readonly UpReadOnly: DeepImmutable<Vector3>;
  61202. /**
  61203. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  61204. * @returns a new down Vector3
  61205. */
  61206. static Down(): Vector3;
  61207. /**
  61208. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  61209. * @returns a new forward Vector3
  61210. */
  61211. static Forward(): Vector3;
  61212. /**
  61213. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  61214. * @returns a new forward Vector3
  61215. */
  61216. static Backward(): Vector3;
  61217. /**
  61218. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  61219. * @returns a new right Vector3
  61220. */
  61221. static Right(): Vector3;
  61222. /**
  61223. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  61224. * @returns a new left Vector3
  61225. */
  61226. static Left(): Vector3;
  61227. /**
  61228. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  61229. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61230. * @param vector defines the Vector3 to transform
  61231. * @param transformation defines the transformation matrix
  61232. * @returns the transformed Vector3
  61233. */
  61234. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61235. /**
  61236. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  61237. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  61238. * @param vector defines the Vector3 to transform
  61239. * @param transformation defines the transformation matrix
  61240. * @param result defines the Vector3 where to store the result
  61241. */
  61242. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61243. /**
  61244. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  61245. * This method computes tranformed coordinates only, not transformed direction vectors
  61246. * @param x define the x coordinate of the source vector
  61247. * @param y define the y coordinate of the source vector
  61248. * @param z define the z coordinate of the source vector
  61249. * @param transformation defines the transformation matrix
  61250. * @param result defines the Vector3 where to store the result
  61251. */
  61252. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61253. /**
  61254. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  61255. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61256. * @param vector defines the Vector3 to transform
  61257. * @param transformation defines the transformation matrix
  61258. * @returns the new Vector3
  61259. */
  61260. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  61261. /**
  61262. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  61263. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61264. * @param vector defines the Vector3 to transform
  61265. * @param transformation defines the transformation matrix
  61266. * @param result defines the Vector3 where to store the result
  61267. */
  61268. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61269. /**
  61270. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  61271. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  61272. * @param x define the x coordinate of the source vector
  61273. * @param y define the y coordinate of the source vector
  61274. * @param z define the z coordinate of the source vector
  61275. * @param transformation defines the transformation matrix
  61276. * @param result defines the Vector3 where to store the result
  61277. */
  61278. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  61279. /**
  61280. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  61281. * @param value1 defines the first control point
  61282. * @param value2 defines the second control point
  61283. * @param value3 defines the third control point
  61284. * @param value4 defines the fourth control point
  61285. * @param amount defines the amount on the spline to use
  61286. * @returns the new Vector3
  61287. */
  61288. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  61289. /**
  61290. * 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"
  61291. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61292. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61293. * @param value defines the current value
  61294. * @param min defines the lower range value
  61295. * @param max defines the upper range value
  61296. * @returns the new Vector3
  61297. */
  61298. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  61299. /**
  61300. * 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"
  61301. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  61302. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  61303. * @param value defines the current value
  61304. * @param min defines the lower range value
  61305. * @param max defines the upper range value
  61306. * @param result defines the Vector3 where to store the result
  61307. */
  61308. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  61309. /**
  61310. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  61311. * @param value1 defines the first control point
  61312. * @param tangent1 defines the first tangent vector
  61313. * @param value2 defines the second control point
  61314. * @param tangent2 defines the second tangent vector
  61315. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  61316. * @returns the new Vector3
  61317. */
  61318. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  61319. /**
  61320. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  61321. * @param start defines the start value
  61322. * @param end defines the end value
  61323. * @param amount max defines amount between both (between 0 and 1)
  61324. * @returns the new Vector3
  61325. */
  61326. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  61327. /**
  61328. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  61329. * @param start defines the start value
  61330. * @param end defines the end value
  61331. * @param amount max defines amount between both (between 0 and 1)
  61332. * @param result defines the Vector3 where to store the result
  61333. */
  61334. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  61335. /**
  61336. * Returns the dot product (float) between the vectors "left" and "right"
  61337. * @param left defines the left operand
  61338. * @param right defines the right operand
  61339. * @returns the dot product
  61340. */
  61341. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  61342. /**
  61343. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  61344. * The cross product is then orthogonal to both "left" and "right"
  61345. * @param left defines the left operand
  61346. * @param right defines the right operand
  61347. * @returns the cross product
  61348. */
  61349. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61350. /**
  61351. * Sets the given vector "result" with the cross product of "left" and "right"
  61352. * The cross product is then orthogonal to both "left" and "right"
  61353. * @param left defines the left operand
  61354. * @param right defines the right operand
  61355. * @param result defines the Vector3 where to store the result
  61356. */
  61357. static CrossToRef(left: Vector3, right: Vector3, result: Vector3): void;
  61358. /**
  61359. * Returns a new Vector3 as the normalization of the given vector
  61360. * @param vector defines the Vector3 to normalize
  61361. * @returns the new Vector3
  61362. */
  61363. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  61364. /**
  61365. * Sets the given vector "result" with the normalization of the given first vector
  61366. * @param vector defines the Vector3 to normalize
  61367. * @param result defines the Vector3 where to store the result
  61368. */
  61369. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  61370. /**
  61371. * Project a Vector3 onto screen space
  61372. * @param vector defines the Vector3 to project
  61373. * @param world defines the world matrix to use
  61374. * @param transform defines the transform (view x projection) matrix to use
  61375. * @param viewport defines the screen viewport to use
  61376. * @returns the new Vector3
  61377. */
  61378. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  61379. /** @hidden */
  61380. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  61381. /**
  61382. * Unproject from screen space to object space
  61383. * @param source defines the screen space Vector3 to use
  61384. * @param viewportWidth defines the current width of the viewport
  61385. * @param viewportHeight defines the current height of the viewport
  61386. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61387. * @param transform defines the transform (view x projection) matrix to use
  61388. * @returns the new Vector3
  61389. */
  61390. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  61391. /**
  61392. * Unproject from screen space to object space
  61393. * @param source defines the screen space Vector3 to use
  61394. * @param viewportWidth defines the current width of the viewport
  61395. * @param viewportHeight defines the current height of the viewport
  61396. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61397. * @param view defines the view matrix to use
  61398. * @param projection defines the projection matrix to use
  61399. * @returns the new Vector3
  61400. */
  61401. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  61402. /**
  61403. * Unproject from screen space to object space
  61404. * @param source defines the screen space Vector3 to use
  61405. * @param viewportWidth defines the current width of the viewport
  61406. * @param viewportHeight defines the current height of the viewport
  61407. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61408. * @param view defines the view matrix to use
  61409. * @param projection defines the projection matrix to use
  61410. * @param result defines the Vector3 where to store the result
  61411. */
  61412. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61413. /**
  61414. * Unproject from screen space to object space
  61415. * @param sourceX defines the screen space x coordinate to use
  61416. * @param sourceY defines the screen space y coordinate to use
  61417. * @param sourceZ defines the screen space z coordinate to use
  61418. * @param viewportWidth defines the current width of the viewport
  61419. * @param viewportHeight defines the current height of the viewport
  61420. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  61421. * @param view defines the view matrix to use
  61422. * @param projection defines the projection matrix to use
  61423. * @param result defines the Vector3 where to store the result
  61424. */
  61425. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  61426. /**
  61427. * Gets the minimal coordinate values between two Vector3
  61428. * @param left defines the first operand
  61429. * @param right defines the second operand
  61430. * @returns the new Vector3
  61431. */
  61432. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61433. /**
  61434. * Gets the maximal coordinate values between two Vector3
  61435. * @param left defines the first operand
  61436. * @param right defines the second operand
  61437. * @returns the new Vector3
  61438. */
  61439. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  61440. /**
  61441. * Returns the distance between the vectors "value1" and "value2"
  61442. * @param value1 defines the first operand
  61443. * @param value2 defines the second operand
  61444. * @returns the distance
  61445. */
  61446. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61447. /**
  61448. * Returns the squared distance between the vectors "value1" and "value2"
  61449. * @param value1 defines the first operand
  61450. * @param value2 defines the second operand
  61451. * @returns the squared distance
  61452. */
  61453. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  61454. /**
  61455. * Returns a new Vector3 located at the center between "value1" and "value2"
  61456. * @param value1 defines the first operand
  61457. * @param value2 defines the second operand
  61458. * @returns the new Vector3
  61459. */
  61460. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  61461. /**
  61462. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  61463. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  61464. * to something in order to rotate it from its local system to the given target system
  61465. * Note: axis1, axis2 and axis3 are normalized during this operation
  61466. * @param axis1 defines the first axis
  61467. * @param axis2 defines the second axis
  61468. * @param axis3 defines the third axis
  61469. * @returns a new Vector3
  61470. */
  61471. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  61472. /**
  61473. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  61474. * @param axis1 defines the first axis
  61475. * @param axis2 defines the second axis
  61476. * @param axis3 defines the third axis
  61477. * @param ref defines the Vector3 where to store the result
  61478. */
  61479. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  61480. }
  61481. /**
  61482. * Vector4 class created for EulerAngle class conversion to Quaternion
  61483. */
  61484. export class Vector4 {
  61485. /** x value of the vector */
  61486. x: number;
  61487. /** y value of the vector */
  61488. y: number;
  61489. /** z value of the vector */
  61490. z: number;
  61491. /** w value of the vector */
  61492. w: number;
  61493. /**
  61494. * Creates a Vector4 object from the given floats.
  61495. * @param x x value of the vector
  61496. * @param y y value of the vector
  61497. * @param z z value of the vector
  61498. * @param w w value of the vector
  61499. */
  61500. constructor(
  61501. /** x value of the vector */
  61502. x: number,
  61503. /** y value of the vector */
  61504. y: number,
  61505. /** z value of the vector */
  61506. z: number,
  61507. /** w value of the vector */
  61508. w: number);
  61509. /**
  61510. * Returns the string with the Vector4 coordinates.
  61511. * @returns a string containing all the vector values
  61512. */
  61513. toString(): string;
  61514. /**
  61515. * Returns the string "Vector4".
  61516. * @returns "Vector4"
  61517. */
  61518. getClassName(): string;
  61519. /**
  61520. * Returns the Vector4 hash code.
  61521. * @returns a unique hash code
  61522. */
  61523. getHashCode(): number;
  61524. /**
  61525. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  61526. * @returns the resulting array
  61527. */
  61528. asArray(): number[];
  61529. /**
  61530. * Populates the given array from the given index with the Vector4 coordinates.
  61531. * @param array array to populate
  61532. * @param index index of the array to start at (default: 0)
  61533. * @returns the Vector4.
  61534. */
  61535. toArray(array: FloatArray, index?: number): Vector4;
  61536. /**
  61537. * Adds the given vector to the current Vector4.
  61538. * @param otherVector the vector to add
  61539. * @returns the updated Vector4.
  61540. */
  61541. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61542. /**
  61543. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  61544. * @param otherVector the vector to add
  61545. * @returns the resulting vector
  61546. */
  61547. add(otherVector: DeepImmutable<Vector4>): Vector4;
  61548. /**
  61549. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  61550. * @param otherVector the vector to add
  61551. * @param result the vector to store the result
  61552. * @returns the current Vector4.
  61553. */
  61554. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61555. /**
  61556. * Subtract in place the given vector from the current Vector4.
  61557. * @param otherVector the vector to subtract
  61558. * @returns the updated Vector4.
  61559. */
  61560. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61561. /**
  61562. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  61563. * @param otherVector the vector to add
  61564. * @returns the new vector with the result
  61565. */
  61566. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  61567. /**
  61568. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  61569. * @param otherVector the vector to subtract
  61570. * @param result the vector to store the result
  61571. * @returns the current Vector4.
  61572. */
  61573. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61574. /**
  61575. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61576. */
  61577. /**
  61578. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61579. * @param x value to subtract
  61580. * @param y value to subtract
  61581. * @param z value to subtract
  61582. * @param w value to subtract
  61583. * @returns new vector containing the result
  61584. */
  61585. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61586. /**
  61587. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  61588. * @param x value to subtract
  61589. * @param y value to subtract
  61590. * @param z value to subtract
  61591. * @param w value to subtract
  61592. * @param result the vector to store the result in
  61593. * @returns the current Vector4.
  61594. */
  61595. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  61596. /**
  61597. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  61598. * @returns a new vector with the negated values
  61599. */
  61600. negate(): Vector4;
  61601. /**
  61602. * Multiplies the current Vector4 coordinates by scale (float).
  61603. * @param scale the number to scale with
  61604. * @returns the updated Vector4.
  61605. */
  61606. scaleInPlace(scale: number): Vector4;
  61607. /**
  61608. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  61609. * @param scale the number to scale with
  61610. * @returns a new vector with the result
  61611. */
  61612. scale(scale: number): Vector4;
  61613. /**
  61614. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  61615. * @param scale the number to scale with
  61616. * @param result a vector to store the result in
  61617. * @returns the current Vector4.
  61618. */
  61619. scaleToRef(scale: number, result: Vector4): Vector4;
  61620. /**
  61621. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  61622. * @param scale defines the scale factor
  61623. * @param result defines the Vector4 object where to store the result
  61624. * @returns the unmodified current Vector4
  61625. */
  61626. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  61627. /**
  61628. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  61629. * @param otherVector the vector to compare against
  61630. * @returns true if they are equal
  61631. */
  61632. equals(otherVector: DeepImmutable<Vector4>): boolean;
  61633. /**
  61634. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  61635. * @param otherVector vector to compare against
  61636. * @param epsilon (Default: very small number)
  61637. * @returns true if they are equal
  61638. */
  61639. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  61640. /**
  61641. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  61642. * @param x x value to compare against
  61643. * @param y y value to compare against
  61644. * @param z z value to compare against
  61645. * @param w w value to compare against
  61646. * @returns true if equal
  61647. */
  61648. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  61649. /**
  61650. * Multiplies in place the current Vector4 by the given one.
  61651. * @param otherVector vector to multiple with
  61652. * @returns the updated Vector4.
  61653. */
  61654. multiplyInPlace(otherVector: Vector4): Vector4;
  61655. /**
  61656. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  61657. * @param otherVector vector to multiple with
  61658. * @returns resulting new vector
  61659. */
  61660. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  61661. /**
  61662. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  61663. * @param otherVector vector to multiple with
  61664. * @param result vector to store the result
  61665. * @returns the current Vector4.
  61666. */
  61667. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61668. /**
  61669. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  61670. * @param x x value multiply with
  61671. * @param y y value multiply with
  61672. * @param z z value multiply with
  61673. * @param w w value multiply with
  61674. * @returns resulting new vector
  61675. */
  61676. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  61677. /**
  61678. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  61679. * @param otherVector vector to devide with
  61680. * @returns resulting new vector
  61681. */
  61682. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  61683. /**
  61684. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  61685. * @param otherVector vector to devide with
  61686. * @param result vector to store the result
  61687. * @returns the current Vector4.
  61688. */
  61689. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  61690. /**
  61691. * Divides the current Vector3 coordinates by the given ones.
  61692. * @param otherVector vector to devide with
  61693. * @returns the updated Vector3.
  61694. */
  61695. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  61696. /**
  61697. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  61698. * @param other defines the second operand
  61699. * @returns the current updated Vector4
  61700. */
  61701. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61702. /**
  61703. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  61704. * @param other defines the second operand
  61705. * @returns the current updated Vector4
  61706. */
  61707. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  61708. /**
  61709. * Gets a new Vector4 from current Vector4 floored values
  61710. * @returns a new Vector4
  61711. */
  61712. floor(): Vector4;
  61713. /**
  61714. * Gets a new Vector4 from current Vector3 floored values
  61715. * @returns a new Vector4
  61716. */
  61717. fract(): Vector4;
  61718. /**
  61719. * Returns the Vector4 length (float).
  61720. * @returns the length
  61721. */
  61722. length(): number;
  61723. /**
  61724. * Returns the Vector4 squared length (float).
  61725. * @returns the length squared
  61726. */
  61727. lengthSquared(): number;
  61728. /**
  61729. * Normalizes in place the Vector4.
  61730. * @returns the updated Vector4.
  61731. */
  61732. normalize(): Vector4;
  61733. /**
  61734. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  61735. * @returns this converted to a new vector3
  61736. */
  61737. toVector3(): Vector3;
  61738. /**
  61739. * Returns a new Vector4 copied from the current one.
  61740. * @returns the new cloned vector
  61741. */
  61742. clone(): Vector4;
  61743. /**
  61744. * Updates the current Vector4 with the given one coordinates.
  61745. * @param source the source vector to copy from
  61746. * @returns the updated Vector4.
  61747. */
  61748. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  61749. /**
  61750. * Updates the current Vector4 coordinates with the given floats.
  61751. * @param x float to copy from
  61752. * @param y float to copy from
  61753. * @param z float to copy from
  61754. * @param w float to copy from
  61755. * @returns the updated Vector4.
  61756. */
  61757. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  61758. /**
  61759. * Updates the current Vector4 coordinates with the given floats.
  61760. * @param x float to set from
  61761. * @param y float to set from
  61762. * @param z float to set from
  61763. * @param w float to set from
  61764. * @returns the updated Vector4.
  61765. */
  61766. set(x: number, y: number, z: number, w: number): Vector4;
  61767. /**
  61768. * Copies the given float to the current Vector3 coordinates
  61769. * @param v defines the x, y, z and w coordinates of the operand
  61770. * @returns the current updated Vector3
  61771. */
  61772. setAll(v: number): Vector4;
  61773. /**
  61774. * Returns a new Vector4 set from the starting index of the given array.
  61775. * @param array the array to pull values from
  61776. * @param offset the offset into the array to start at
  61777. * @returns the new vector
  61778. */
  61779. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  61780. /**
  61781. * Updates the given vector "result" from the starting index of the given array.
  61782. * @param array the array to pull values from
  61783. * @param offset the offset into the array to start at
  61784. * @param result the vector to store the result in
  61785. */
  61786. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  61787. /**
  61788. * Updates the given vector "result" from the starting index of the given Float32Array.
  61789. * @param array the array to pull values from
  61790. * @param offset the offset into the array to start at
  61791. * @param result the vector to store the result in
  61792. */
  61793. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  61794. /**
  61795. * Updates the given vector "result" coordinates from the given floats.
  61796. * @param x float to set from
  61797. * @param y float to set from
  61798. * @param z float to set from
  61799. * @param w float to set from
  61800. * @param result the vector to the floats in
  61801. */
  61802. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  61803. /**
  61804. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  61805. * @returns the new vector
  61806. */
  61807. static Zero(): Vector4;
  61808. /**
  61809. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  61810. * @returns the new vector
  61811. */
  61812. static One(): Vector4;
  61813. /**
  61814. * Returns a new normalized Vector4 from the given one.
  61815. * @param vector the vector to normalize
  61816. * @returns the vector
  61817. */
  61818. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  61819. /**
  61820. * Updates the given vector "result" from the normalization of the given one.
  61821. * @param vector the vector to normalize
  61822. * @param result the vector to store the result in
  61823. */
  61824. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  61825. /**
  61826. * Returns a vector with the minimum values from the left and right vectors
  61827. * @param left left vector to minimize
  61828. * @param right right vector to minimize
  61829. * @returns a new vector with the minimum of the left and right vector values
  61830. */
  61831. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61832. /**
  61833. * Returns a vector with the maximum values from the left and right vectors
  61834. * @param left left vector to maximize
  61835. * @param right right vector to maximize
  61836. * @returns a new vector with the maximum of the left and right vector values
  61837. */
  61838. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  61839. /**
  61840. * Returns the distance (float) between the vectors "value1" and "value2".
  61841. * @param value1 value to calulate the distance between
  61842. * @param value2 value to calulate the distance between
  61843. * @return the distance between the two vectors
  61844. */
  61845. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61846. /**
  61847. * Returns the squared distance (float) between the vectors "value1" and "value2".
  61848. * @param value1 value to calulate the distance between
  61849. * @param value2 value to calulate the distance between
  61850. * @return the distance between the two vectors squared
  61851. */
  61852. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  61853. /**
  61854. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  61855. * @param value1 value to calulate the center between
  61856. * @param value2 value to calulate the center between
  61857. * @return the center between the two vectors
  61858. */
  61859. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  61860. /**
  61861. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  61862. * This methods computes transformed normalized direction vectors only.
  61863. * @param vector the vector to transform
  61864. * @param transformation the transformation matrix to apply
  61865. * @returns the new vector
  61866. */
  61867. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  61868. /**
  61869. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  61870. * This methods computes transformed normalized direction vectors only.
  61871. * @param vector the vector to transform
  61872. * @param transformation the transformation matrix to apply
  61873. * @param result the vector to store the result in
  61874. */
  61875. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61876. /**
  61877. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  61878. * This methods computes transformed normalized direction vectors only.
  61879. * @param x value to transform
  61880. * @param y value to transform
  61881. * @param z value to transform
  61882. * @param w value to transform
  61883. * @param transformation the transformation matrix to apply
  61884. * @param result the vector to store the results in
  61885. */
  61886. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  61887. /**
  61888. * Creates a new Vector4 from a Vector3
  61889. * @param source defines the source data
  61890. * @param w defines the 4th component (default is 0)
  61891. * @returns a new Vector4
  61892. */
  61893. static FromVector3(source: Vector3, w?: number): Vector4;
  61894. }
  61895. /**
  61896. * Interface for the size containing width and height
  61897. */
  61898. export interface ISize {
  61899. /**
  61900. * Width
  61901. */
  61902. width: number;
  61903. /**
  61904. * Heighht
  61905. */
  61906. height: number;
  61907. }
  61908. /**
  61909. * Size containing widht and height
  61910. */
  61911. export class Size implements ISize {
  61912. /**
  61913. * Width
  61914. */
  61915. width: number;
  61916. /**
  61917. * Height
  61918. */
  61919. height: number;
  61920. /**
  61921. * Creates a Size object from the given width and height (floats).
  61922. * @param width width of the new size
  61923. * @param height height of the new size
  61924. */
  61925. constructor(width: number, height: number);
  61926. /**
  61927. * Returns a string with the Size width and height
  61928. * @returns a string with the Size width and height
  61929. */
  61930. toString(): string;
  61931. /**
  61932. * "Size"
  61933. * @returns the string "Size"
  61934. */
  61935. getClassName(): string;
  61936. /**
  61937. * Returns the Size hash code.
  61938. * @returns a hash code for a unique width and height
  61939. */
  61940. getHashCode(): number;
  61941. /**
  61942. * Updates the current size from the given one.
  61943. * @param src the given size
  61944. */
  61945. copyFrom(src: Size): void;
  61946. /**
  61947. * Updates in place the current Size from the given floats.
  61948. * @param width width of the new size
  61949. * @param height height of the new size
  61950. * @returns the updated Size.
  61951. */
  61952. copyFromFloats(width: number, height: number): Size;
  61953. /**
  61954. * Updates in place the current Size from the given floats.
  61955. * @param width width to set
  61956. * @param height height to set
  61957. * @returns the updated Size.
  61958. */
  61959. set(width: number, height: number): Size;
  61960. /**
  61961. * Multiplies the width and height by numbers
  61962. * @param w factor to multiple the width by
  61963. * @param h factor to multiple the height by
  61964. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  61965. */
  61966. multiplyByFloats(w: number, h: number): Size;
  61967. /**
  61968. * Clones the size
  61969. * @returns a new Size copied from the given one.
  61970. */
  61971. clone(): Size;
  61972. /**
  61973. * True if the current Size and the given one width and height are strictly equal.
  61974. * @param other the other size to compare against
  61975. * @returns True if the current Size and the given one width and height are strictly equal.
  61976. */
  61977. equals(other: Size): boolean;
  61978. /**
  61979. * The surface of the Size : width * height (float).
  61980. */
  61981. readonly surface: number;
  61982. /**
  61983. * Create a new size of zero
  61984. * @returns a new Size set to (0.0, 0.0)
  61985. */
  61986. static Zero(): Size;
  61987. /**
  61988. * Sums the width and height of two sizes
  61989. * @param otherSize size to add to this size
  61990. * @returns a new Size set as the addition result of the current Size and the given one.
  61991. */
  61992. add(otherSize: Size): Size;
  61993. /**
  61994. * Subtracts the width and height of two
  61995. * @param otherSize size to subtract to this size
  61996. * @returns a new Size set as the subtraction result of the given one from the current Size.
  61997. */
  61998. subtract(otherSize: Size): Size;
  61999. /**
  62000. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  62001. * @param start starting size to lerp between
  62002. * @param end end size to lerp between
  62003. * @param amount amount to lerp between the start and end values
  62004. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  62005. */
  62006. static Lerp(start: Size, end: Size, amount: number): Size;
  62007. }
  62008. /**
  62009. * Class used to store quaternion data
  62010. * @see https://en.wikipedia.org/wiki/Quaternion
  62011. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  62012. */
  62013. export class Quaternion {
  62014. /** defines the first component (0 by default) */
  62015. x: number;
  62016. /** defines the second component (0 by default) */
  62017. y: number;
  62018. /** defines the third component (0 by default) */
  62019. z: number;
  62020. /** defines the fourth component (1.0 by default) */
  62021. w: number;
  62022. /**
  62023. * Creates a new Quaternion from the given floats
  62024. * @param x defines the first component (0 by default)
  62025. * @param y defines the second component (0 by default)
  62026. * @param z defines the third component (0 by default)
  62027. * @param w defines the fourth component (1.0 by default)
  62028. */
  62029. constructor(
  62030. /** defines the first component (0 by default) */
  62031. x?: number,
  62032. /** defines the second component (0 by default) */
  62033. y?: number,
  62034. /** defines the third component (0 by default) */
  62035. z?: number,
  62036. /** defines the fourth component (1.0 by default) */
  62037. w?: number);
  62038. /**
  62039. * Gets a string representation for the current quaternion
  62040. * @returns a string with the Quaternion coordinates
  62041. */
  62042. toString(): string;
  62043. /**
  62044. * Gets the class name of the quaternion
  62045. * @returns the string "Quaternion"
  62046. */
  62047. getClassName(): string;
  62048. /**
  62049. * Gets a hash code for this quaternion
  62050. * @returns the quaternion hash code
  62051. */
  62052. getHashCode(): number;
  62053. /**
  62054. * Copy the quaternion to an array
  62055. * @returns a new array populated with 4 elements from the quaternion coordinates
  62056. */
  62057. asArray(): number[];
  62058. /**
  62059. * Check if two quaternions are equals
  62060. * @param otherQuaternion defines the second operand
  62061. * @return true if the current quaternion and the given one coordinates are strictly equals
  62062. */
  62063. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  62064. /**
  62065. * Clone the current quaternion
  62066. * @returns a new quaternion copied from the current one
  62067. */
  62068. clone(): Quaternion;
  62069. /**
  62070. * Copy a quaternion to the current one
  62071. * @param other defines the other quaternion
  62072. * @returns the updated current quaternion
  62073. */
  62074. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  62075. /**
  62076. * Updates the current quaternion with the given float coordinates
  62077. * @param x defines the x coordinate
  62078. * @param y defines the y coordinate
  62079. * @param z defines the z coordinate
  62080. * @param w defines the w coordinate
  62081. * @returns the updated current quaternion
  62082. */
  62083. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  62084. /**
  62085. * Updates the current quaternion from the given float coordinates
  62086. * @param x defines the x coordinate
  62087. * @param y defines the y coordinate
  62088. * @param z defines the z coordinate
  62089. * @param w defines the w coordinate
  62090. * @returns the updated current quaternion
  62091. */
  62092. set(x: number, y: number, z: number, w: number): Quaternion;
  62093. /**
  62094. * Adds two quaternions
  62095. * @param other defines the second operand
  62096. * @returns a new quaternion as the addition result of the given one and the current quaternion
  62097. */
  62098. add(other: DeepImmutable<Quaternion>): Quaternion;
  62099. /**
  62100. * Add a quaternion to the current one
  62101. * @param other defines the quaternion to add
  62102. * @returns the current quaternion
  62103. */
  62104. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  62105. /**
  62106. * Subtract two quaternions
  62107. * @param other defines the second operand
  62108. * @returns a new quaternion as the subtraction result of the given one from the current one
  62109. */
  62110. subtract(other: Quaternion): Quaternion;
  62111. /**
  62112. * Multiplies the current quaternion by a scale factor
  62113. * @param value defines the scale factor
  62114. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  62115. */
  62116. scale(value: number): Quaternion;
  62117. /**
  62118. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  62119. * @param scale defines the scale factor
  62120. * @param result defines the Quaternion object where to store the result
  62121. * @returns the unmodified current quaternion
  62122. */
  62123. scaleToRef(scale: number, result: Quaternion): Quaternion;
  62124. /**
  62125. * Multiplies in place the current quaternion by a scale factor
  62126. * @param value defines the scale factor
  62127. * @returns the current modified quaternion
  62128. */
  62129. scaleInPlace(value: number): Quaternion;
  62130. /**
  62131. * Scale the current quaternion values by a factor and add the result to a given quaternion
  62132. * @param scale defines the scale factor
  62133. * @param result defines the Quaternion object where to store the result
  62134. * @returns the unmodified current quaternion
  62135. */
  62136. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  62137. /**
  62138. * Multiplies two quaternions
  62139. * @param q1 defines the second operand
  62140. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  62141. */
  62142. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  62143. /**
  62144. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  62145. * @param q1 defines the second operand
  62146. * @param result defines the target quaternion
  62147. * @returns the current quaternion
  62148. */
  62149. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  62150. /**
  62151. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  62152. * @param q1 defines the second operand
  62153. * @returns the currentupdated quaternion
  62154. */
  62155. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  62156. /**
  62157. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  62158. * @param ref defines the target quaternion
  62159. * @returns the current quaternion
  62160. */
  62161. conjugateToRef(ref: Quaternion): Quaternion;
  62162. /**
  62163. * Conjugates in place (1-q) the current quaternion
  62164. * @returns the current updated quaternion
  62165. */
  62166. conjugateInPlace(): Quaternion;
  62167. /**
  62168. * Conjugates in place (1-q) the current quaternion
  62169. * @returns a new quaternion
  62170. */
  62171. conjugate(): Quaternion;
  62172. /**
  62173. * Gets length of current quaternion
  62174. * @returns the quaternion length (float)
  62175. */
  62176. length(): number;
  62177. /**
  62178. * Normalize in place the current quaternion
  62179. * @returns the current updated quaternion
  62180. */
  62181. normalize(): Quaternion;
  62182. /**
  62183. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  62184. * @param order is a reserved parameter and is ignore for now
  62185. * @returns a new Vector3 containing the Euler angles
  62186. */
  62187. toEulerAngles(order?: string): Vector3;
  62188. /**
  62189. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  62190. * @param result defines the vector which will be filled with the Euler angles
  62191. * @param order is a reserved parameter and is ignore for now
  62192. * @returns the current unchanged quaternion
  62193. */
  62194. toEulerAnglesToRef(result: Vector3): Quaternion;
  62195. /**
  62196. * Updates the given rotation matrix with the current quaternion values
  62197. * @param result defines the target matrix
  62198. * @returns the current unchanged quaternion
  62199. */
  62200. toRotationMatrix(result: Matrix): Quaternion;
  62201. /**
  62202. * Updates the current quaternion from the given rotation matrix values
  62203. * @param matrix defines the source matrix
  62204. * @returns the current updated quaternion
  62205. */
  62206. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62207. /**
  62208. * Creates a new quaternion from a rotation matrix
  62209. * @param matrix defines the source matrix
  62210. * @returns a new quaternion created from the given rotation matrix values
  62211. */
  62212. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  62213. /**
  62214. * Updates the given quaternion with the given rotation matrix values
  62215. * @param matrix defines the source matrix
  62216. * @param result defines the target quaternion
  62217. */
  62218. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  62219. /**
  62220. * Returns the dot product (float) between the quaternions "left" and "right"
  62221. * @param left defines the left operand
  62222. * @param right defines the right operand
  62223. * @returns the dot product
  62224. */
  62225. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  62226. /**
  62227. * Checks if the two quaternions are close to each other
  62228. * @param quat0 defines the first quaternion to check
  62229. * @param quat1 defines the second quaternion to check
  62230. * @returns true if the two quaternions are close to each other
  62231. */
  62232. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  62233. /**
  62234. * Creates an empty quaternion
  62235. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  62236. */
  62237. static Zero(): Quaternion;
  62238. /**
  62239. * Inverse a given quaternion
  62240. * @param q defines the source quaternion
  62241. * @returns a new quaternion as the inverted current quaternion
  62242. */
  62243. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  62244. /**
  62245. * Inverse a given quaternion
  62246. * @param q defines the source quaternion
  62247. * @param result the quaternion the result will be stored in
  62248. * @returns the result quaternion
  62249. */
  62250. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  62251. /**
  62252. * Creates an identity quaternion
  62253. * @returns the identity quaternion
  62254. */
  62255. static Identity(): Quaternion;
  62256. /**
  62257. * Gets a boolean indicating if the given quaternion is identity
  62258. * @param quaternion defines the quaternion to check
  62259. * @returns true if the quaternion is identity
  62260. */
  62261. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  62262. /**
  62263. * Creates a quaternion from a rotation around an axis
  62264. * @param axis defines the axis to use
  62265. * @param angle defines the angle to use
  62266. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  62267. */
  62268. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  62269. /**
  62270. * Creates a rotation around an axis and stores it into the given quaternion
  62271. * @param axis defines the axis to use
  62272. * @param angle defines the angle to use
  62273. * @param result defines the target quaternion
  62274. * @returns the target quaternion
  62275. */
  62276. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  62277. /**
  62278. * Creates a new quaternion from data stored into an array
  62279. * @param array defines the data source
  62280. * @param offset defines the offset in the source array where the data starts
  62281. * @returns a new quaternion
  62282. */
  62283. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  62284. /**
  62285. * Create a quaternion from Euler rotation angles
  62286. * @param x Pitch
  62287. * @param y Yaw
  62288. * @param z Roll
  62289. * @returns the new Quaternion
  62290. */
  62291. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  62292. /**
  62293. * Updates a quaternion from Euler rotation angles
  62294. * @param x Pitch
  62295. * @param y Yaw
  62296. * @param z Roll
  62297. * @param result the quaternion to store the result
  62298. * @returns the updated quaternion
  62299. */
  62300. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  62301. /**
  62302. * Create a quaternion from Euler rotation vector
  62303. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62304. * @returns the new Quaternion
  62305. */
  62306. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  62307. /**
  62308. * Updates a quaternion from Euler rotation vector
  62309. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  62310. * @param result the quaternion to store the result
  62311. * @returns the updated quaternion
  62312. */
  62313. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  62314. /**
  62315. * Creates a new quaternion from the given Euler float angles (y, x, z)
  62316. * @param yaw defines the rotation around Y axis
  62317. * @param pitch defines the rotation around X axis
  62318. * @param roll defines the rotation around Z axis
  62319. * @returns the new quaternion
  62320. */
  62321. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  62322. /**
  62323. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  62324. * @param yaw defines the rotation around Y axis
  62325. * @param pitch defines the rotation around X axis
  62326. * @param roll defines the rotation around Z axis
  62327. * @param result defines the target quaternion
  62328. */
  62329. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  62330. /**
  62331. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  62332. * @param alpha defines the rotation around first axis
  62333. * @param beta defines the rotation around second axis
  62334. * @param gamma defines the rotation around third axis
  62335. * @returns the new quaternion
  62336. */
  62337. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  62338. /**
  62339. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  62340. * @param alpha defines the rotation around first axis
  62341. * @param beta defines the rotation around second axis
  62342. * @param gamma defines the rotation around third axis
  62343. * @param result defines the target quaternion
  62344. */
  62345. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  62346. /**
  62347. * 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)
  62348. * @param axis1 defines the first axis
  62349. * @param axis2 defines the second axis
  62350. * @param axis3 defines the third axis
  62351. * @returns the new quaternion
  62352. */
  62353. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  62354. /**
  62355. * 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
  62356. * @param axis1 defines the first axis
  62357. * @param axis2 defines the second axis
  62358. * @param axis3 defines the third axis
  62359. * @param ref defines the target quaternion
  62360. */
  62361. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  62362. /**
  62363. * Interpolates between two quaternions
  62364. * @param left defines first quaternion
  62365. * @param right defines second quaternion
  62366. * @param amount defines the gradient to use
  62367. * @returns the new interpolated quaternion
  62368. */
  62369. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62370. /**
  62371. * Interpolates between two quaternions and stores it into a target quaternion
  62372. * @param left defines first quaternion
  62373. * @param right defines second quaternion
  62374. * @param amount defines the gradient to use
  62375. * @param result defines the target quaternion
  62376. */
  62377. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  62378. /**
  62379. * Interpolate between two quaternions using Hermite interpolation
  62380. * @param value1 defines first quaternion
  62381. * @param tangent1 defines the incoming tangent
  62382. * @param value2 defines second quaternion
  62383. * @param tangent2 defines the outgoing tangent
  62384. * @param amount defines the target quaternion
  62385. * @returns the new interpolated quaternion
  62386. */
  62387. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  62388. }
  62389. /**
  62390. * Class used to store matrix data (4x4)
  62391. */
  62392. export class Matrix {
  62393. private static _updateFlagSeed;
  62394. private static _identityReadOnly;
  62395. private _isIdentity;
  62396. private _isIdentityDirty;
  62397. private _isIdentity3x2;
  62398. private _isIdentity3x2Dirty;
  62399. /**
  62400. * Gets the update flag of the matrix which is an unique number for the matrix.
  62401. * It will be incremented every time the matrix data change.
  62402. * You can use it to speed the comparison between two versions of the same matrix.
  62403. */
  62404. updateFlag: number;
  62405. private readonly _m;
  62406. /**
  62407. * Gets the internal data of the matrix
  62408. */
  62409. readonly m: DeepImmutable<Float32Array>;
  62410. /** @hidden */
  62411. _markAsUpdated(): void;
  62412. /** @hidden */
  62413. private _updateIdentityStatus;
  62414. /**
  62415. * Creates an empty matrix (filled with zeros)
  62416. */
  62417. constructor();
  62418. /**
  62419. * Check if the current matrix is identity
  62420. * @returns true is the matrix is the identity matrix
  62421. */
  62422. isIdentity(): boolean;
  62423. /**
  62424. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  62425. * @returns true is the matrix is the identity matrix
  62426. */
  62427. isIdentityAs3x2(): boolean;
  62428. /**
  62429. * Gets the determinant of the matrix
  62430. * @returns the matrix determinant
  62431. */
  62432. determinant(): number;
  62433. /**
  62434. * Returns the matrix as a Float32Array
  62435. * @returns the matrix underlying array
  62436. */
  62437. toArray(): DeepImmutable<Float32Array>;
  62438. /**
  62439. * Returns the matrix as a Float32Array
  62440. * @returns the matrix underlying array.
  62441. */
  62442. asArray(): DeepImmutable<Float32Array>;
  62443. /**
  62444. * Inverts the current matrix in place
  62445. * @returns the current inverted matrix
  62446. */
  62447. invert(): Matrix;
  62448. /**
  62449. * Sets all the matrix elements to zero
  62450. * @returns the current matrix
  62451. */
  62452. reset(): Matrix;
  62453. /**
  62454. * Adds the current matrix with a second one
  62455. * @param other defines the matrix to add
  62456. * @returns a new matrix as the addition of the current matrix and the given one
  62457. */
  62458. add(other: DeepImmutable<Matrix>): Matrix;
  62459. /**
  62460. * Sets the given matrix "result" to the addition of the current matrix and the given one
  62461. * @param other defines the matrix to add
  62462. * @param result defines the target matrix
  62463. * @returns the current matrix
  62464. */
  62465. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62466. /**
  62467. * Adds in place the given matrix to the current matrix
  62468. * @param other defines the second operand
  62469. * @returns the current updated matrix
  62470. */
  62471. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  62472. /**
  62473. * Sets the given matrix to the current inverted Matrix
  62474. * @param other defines the target matrix
  62475. * @returns the unmodified current matrix
  62476. */
  62477. invertToRef(other: Matrix): Matrix;
  62478. /**
  62479. * add a value at the specified position in the current Matrix
  62480. * @param index the index of the value within the matrix. between 0 and 15.
  62481. * @param value the value to be added
  62482. * @returns the current updated matrix
  62483. */
  62484. addAtIndex(index: number, value: number): Matrix;
  62485. /**
  62486. * mutiply the specified position in the current Matrix by a value
  62487. * @param index the index of the value within the matrix. between 0 and 15.
  62488. * @param value the value to be added
  62489. * @returns the current updated matrix
  62490. */
  62491. multiplyAtIndex(index: number, value: number): Matrix;
  62492. /**
  62493. * Inserts the translation vector (using 3 floats) in the current matrix
  62494. * @param x defines the 1st component of the translation
  62495. * @param y defines the 2nd component of the translation
  62496. * @param z defines the 3rd component of the translation
  62497. * @returns the current updated matrix
  62498. */
  62499. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62500. /**
  62501. * Adds the translation vector (using 3 floats) in the current matrix
  62502. * @param x defines the 1st component of the translation
  62503. * @param y defines the 2nd component of the translation
  62504. * @param z defines the 3rd component of the translation
  62505. * @returns the current updated matrix
  62506. */
  62507. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  62508. /**
  62509. * Inserts the translation vector in the current matrix
  62510. * @param vector3 defines the translation to insert
  62511. * @returns the current updated matrix
  62512. */
  62513. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  62514. /**
  62515. * Gets the translation value of the current matrix
  62516. * @returns a new Vector3 as the extracted translation from the matrix
  62517. */
  62518. getTranslation(): Vector3;
  62519. /**
  62520. * Fill a Vector3 with the extracted translation from the matrix
  62521. * @param result defines the Vector3 where to store the translation
  62522. * @returns the current matrix
  62523. */
  62524. getTranslationToRef(result: Vector3): Matrix;
  62525. /**
  62526. * Remove rotation and scaling part from the matrix
  62527. * @returns the updated matrix
  62528. */
  62529. removeRotationAndScaling(): Matrix;
  62530. /**
  62531. * Multiply two matrices
  62532. * @param other defines the second operand
  62533. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  62534. */
  62535. multiply(other: DeepImmutable<Matrix>): Matrix;
  62536. /**
  62537. * Copy the current matrix from the given one
  62538. * @param other defines the source matrix
  62539. * @returns the current updated matrix
  62540. */
  62541. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  62542. /**
  62543. * Populates the given array from the starting index with the current matrix values
  62544. * @param array defines the target array
  62545. * @param offset defines the offset in the target array where to start storing values
  62546. * @returns the current matrix
  62547. */
  62548. copyToArray(array: Float32Array, offset?: number): Matrix;
  62549. /**
  62550. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  62551. * @param other defines the second operand
  62552. * @param result defines the matrix where to store the multiplication
  62553. * @returns the current matrix
  62554. */
  62555. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  62556. /**
  62557. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  62558. * @param other defines the second operand
  62559. * @param result defines the array where to store the multiplication
  62560. * @param offset defines the offset in the target array where to start storing values
  62561. * @returns the current matrix
  62562. */
  62563. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array, offset: number): Matrix;
  62564. /**
  62565. * Check equality between this matrix and a second one
  62566. * @param value defines the second matrix to compare
  62567. * @returns true is the current matrix and the given one values are strictly equal
  62568. */
  62569. equals(value: DeepImmutable<Matrix>): boolean;
  62570. /**
  62571. * Clone the current matrix
  62572. * @returns a new matrix from the current matrix
  62573. */
  62574. clone(): Matrix;
  62575. /**
  62576. * Returns the name of the current matrix class
  62577. * @returns the string "Matrix"
  62578. */
  62579. getClassName(): string;
  62580. /**
  62581. * Gets the hash code of the current matrix
  62582. * @returns the hash code
  62583. */
  62584. getHashCode(): number;
  62585. /**
  62586. * Decomposes the current Matrix into a translation, rotation and scaling components
  62587. * @param scale defines the scale vector3 given as a reference to update
  62588. * @param rotation defines the rotation quaternion given as a reference to update
  62589. * @param translation defines the translation vector3 given as a reference to update
  62590. * @returns true if operation was successful
  62591. */
  62592. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  62593. /**
  62594. * Gets specific row of the matrix
  62595. * @param index defines the number of the row to get
  62596. * @returns the index-th row of the current matrix as a new Vector4
  62597. */
  62598. getRow(index: number): Nullable<Vector4>;
  62599. /**
  62600. * Sets the index-th row of the current matrix to the vector4 values
  62601. * @param index defines the number of the row to set
  62602. * @param row defines the target vector4
  62603. * @returns the updated current matrix
  62604. */
  62605. setRow(index: number, row: Vector4): Matrix;
  62606. /**
  62607. * Compute the transpose of the matrix
  62608. * @returns the new transposed matrix
  62609. */
  62610. transpose(): Matrix;
  62611. /**
  62612. * Compute the transpose of the matrix and store it in a given matrix
  62613. * @param result defines the target matrix
  62614. * @returns the current matrix
  62615. */
  62616. transposeToRef(result: Matrix): Matrix;
  62617. /**
  62618. * Sets the index-th row of the current matrix with the given 4 x float values
  62619. * @param index defines the row index
  62620. * @param x defines the x component to set
  62621. * @param y defines the y component to set
  62622. * @param z defines the z component to set
  62623. * @param w defines the w component to set
  62624. * @returns the updated current matrix
  62625. */
  62626. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  62627. /**
  62628. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  62629. * @param scale defines the scale factor
  62630. * @returns a new matrix
  62631. */
  62632. scale(scale: number): Matrix;
  62633. /**
  62634. * Scale the current matrix values by a factor to a given result matrix
  62635. * @param scale defines the scale factor
  62636. * @param result defines the matrix to store the result
  62637. * @returns the current matrix
  62638. */
  62639. scaleToRef(scale: number, result: Matrix): Matrix;
  62640. /**
  62641. * Scale the current matrix values by a factor and add the result to a given matrix
  62642. * @param scale defines the scale factor
  62643. * @param result defines the Matrix to store the result
  62644. * @returns the current matrix
  62645. */
  62646. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  62647. /**
  62648. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  62649. * @param ref matrix to store the result
  62650. */
  62651. toNormalMatrix(ref: Matrix): void;
  62652. /**
  62653. * Gets only rotation part of the current matrix
  62654. * @returns a new matrix sets to the extracted rotation matrix from the current one
  62655. */
  62656. getRotationMatrix(): Matrix;
  62657. /**
  62658. * Extracts the rotation matrix from the current one and sets it as the given "result"
  62659. * @param result defines the target matrix to store data to
  62660. * @returns the current matrix
  62661. */
  62662. getRotationMatrixToRef(result: Matrix): Matrix;
  62663. /**
  62664. * Toggles model matrix from being right handed to left handed in place and vice versa
  62665. */
  62666. toggleModelMatrixHandInPlace(): void;
  62667. /**
  62668. * Toggles projection matrix from being right handed to left handed in place and vice versa
  62669. */
  62670. toggleProjectionMatrixHandInPlace(): void;
  62671. /**
  62672. * Creates a matrix from an array
  62673. * @param array defines the source array
  62674. * @param offset defines an offset in the source array
  62675. * @returns a new Matrix set from the starting index of the given array
  62676. */
  62677. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  62678. /**
  62679. * Copy the content of an array into a given matrix
  62680. * @param array defines the source array
  62681. * @param offset defines an offset in the source array
  62682. * @param result defines the target matrix
  62683. */
  62684. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  62685. /**
  62686. * Stores an array into a matrix after having multiplied each component by a given factor
  62687. * @param array defines the source array
  62688. * @param offset defines the offset in the source array
  62689. * @param scale defines the scaling factor
  62690. * @param result defines the target matrix
  62691. */
  62692. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array>, offset: number, scale: number, result: Matrix): void;
  62693. /**
  62694. * Gets an identity matrix that must not be updated
  62695. */
  62696. static readonly IdentityReadOnly: DeepImmutable<Matrix>;
  62697. /**
  62698. * Stores a list of values (16) inside a given matrix
  62699. * @param initialM11 defines 1st value of 1st row
  62700. * @param initialM12 defines 2nd value of 1st row
  62701. * @param initialM13 defines 3rd value of 1st row
  62702. * @param initialM14 defines 4th value of 1st row
  62703. * @param initialM21 defines 1st value of 2nd row
  62704. * @param initialM22 defines 2nd value of 2nd row
  62705. * @param initialM23 defines 3rd value of 2nd row
  62706. * @param initialM24 defines 4th value of 2nd row
  62707. * @param initialM31 defines 1st value of 3rd row
  62708. * @param initialM32 defines 2nd value of 3rd row
  62709. * @param initialM33 defines 3rd value of 3rd row
  62710. * @param initialM34 defines 4th value of 3rd row
  62711. * @param initialM41 defines 1st value of 4th row
  62712. * @param initialM42 defines 2nd value of 4th row
  62713. * @param initialM43 defines 3rd value of 4th row
  62714. * @param initialM44 defines 4th value of 4th row
  62715. * @param result defines the target matrix
  62716. */
  62717. 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;
  62718. /**
  62719. * Creates new matrix from a list of values (16)
  62720. * @param initialM11 defines 1st value of 1st row
  62721. * @param initialM12 defines 2nd value of 1st row
  62722. * @param initialM13 defines 3rd value of 1st row
  62723. * @param initialM14 defines 4th value of 1st row
  62724. * @param initialM21 defines 1st value of 2nd row
  62725. * @param initialM22 defines 2nd value of 2nd row
  62726. * @param initialM23 defines 3rd value of 2nd row
  62727. * @param initialM24 defines 4th value of 2nd row
  62728. * @param initialM31 defines 1st value of 3rd row
  62729. * @param initialM32 defines 2nd value of 3rd row
  62730. * @param initialM33 defines 3rd value of 3rd row
  62731. * @param initialM34 defines 4th value of 3rd row
  62732. * @param initialM41 defines 1st value of 4th row
  62733. * @param initialM42 defines 2nd value of 4th row
  62734. * @param initialM43 defines 3rd value of 4th row
  62735. * @param initialM44 defines 4th value of 4th row
  62736. * @returns the new matrix
  62737. */
  62738. 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;
  62739. /**
  62740. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62741. * @param scale defines the scale vector3
  62742. * @param rotation defines the rotation quaternion
  62743. * @param translation defines the translation vector3
  62744. * @returns a new matrix
  62745. */
  62746. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  62747. /**
  62748. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  62749. * @param scale defines the scale vector3
  62750. * @param rotation defines the rotation quaternion
  62751. * @param translation defines the translation vector3
  62752. * @param result defines the target matrix
  62753. */
  62754. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  62755. /**
  62756. * Creates a new identity matrix
  62757. * @returns a new identity matrix
  62758. */
  62759. static Identity(): Matrix;
  62760. /**
  62761. * Creates a new identity matrix and stores the result in a given matrix
  62762. * @param result defines the target matrix
  62763. */
  62764. static IdentityToRef(result: Matrix): void;
  62765. /**
  62766. * Creates a new zero matrix
  62767. * @returns a new zero matrix
  62768. */
  62769. static Zero(): Matrix;
  62770. /**
  62771. * Creates a new rotation matrix for "angle" radians around the X axis
  62772. * @param angle defines the angle (in radians) to use
  62773. * @return the new matrix
  62774. */
  62775. static RotationX(angle: number): Matrix;
  62776. /**
  62777. * Creates a new matrix as the invert of a given matrix
  62778. * @param source defines the source matrix
  62779. * @returns the new matrix
  62780. */
  62781. static Invert(source: DeepImmutable<Matrix>): Matrix;
  62782. /**
  62783. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  62784. * @param angle defines the angle (in radians) to use
  62785. * @param result defines the target matrix
  62786. */
  62787. static RotationXToRef(angle: number, result: Matrix): void;
  62788. /**
  62789. * Creates a new rotation matrix for "angle" radians around the Y axis
  62790. * @param angle defines the angle (in radians) to use
  62791. * @return the new matrix
  62792. */
  62793. static RotationY(angle: number): Matrix;
  62794. /**
  62795. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  62796. * @param angle defines the angle (in radians) to use
  62797. * @param result defines the target matrix
  62798. */
  62799. static RotationYToRef(angle: number, result: Matrix): void;
  62800. /**
  62801. * Creates a new rotation matrix for "angle" radians around the Z axis
  62802. * @param angle defines the angle (in radians) to use
  62803. * @return the new matrix
  62804. */
  62805. static RotationZ(angle: number): Matrix;
  62806. /**
  62807. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  62808. * @param angle defines the angle (in radians) to use
  62809. * @param result defines the target matrix
  62810. */
  62811. static RotationZToRef(angle: number, result: Matrix): void;
  62812. /**
  62813. * Creates a new rotation matrix for "angle" radians around the given axis
  62814. * @param axis defines the axis to use
  62815. * @param angle defines the angle (in radians) to use
  62816. * @return the new matrix
  62817. */
  62818. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  62819. /**
  62820. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  62821. * @param axis defines the axis to use
  62822. * @param angle defines the angle (in radians) to use
  62823. * @param result defines the target matrix
  62824. */
  62825. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  62826. /**
  62827. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  62828. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  62829. * @param from defines the vector to align
  62830. * @param to defines the vector to align to
  62831. * @param result defines the target matrix
  62832. */
  62833. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  62834. /**
  62835. * Creates a rotation matrix
  62836. * @param yaw defines the yaw angle in radians (Y axis)
  62837. * @param pitch defines the pitch angle in radians (X axis)
  62838. * @param roll defines the roll angle in radians (X axis)
  62839. * @returns the new rotation matrix
  62840. */
  62841. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  62842. /**
  62843. * Creates a rotation matrix and stores it in a given matrix
  62844. * @param yaw defines the yaw angle in radians (Y axis)
  62845. * @param pitch defines the pitch angle in radians (X axis)
  62846. * @param roll defines the roll angle in radians (X axis)
  62847. * @param result defines the target matrix
  62848. */
  62849. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  62850. /**
  62851. * Creates a scaling matrix
  62852. * @param x defines the scale factor on X axis
  62853. * @param y defines the scale factor on Y axis
  62854. * @param z defines the scale factor on Z axis
  62855. * @returns the new matrix
  62856. */
  62857. static Scaling(x: number, y: number, z: number): Matrix;
  62858. /**
  62859. * Creates a scaling matrix and stores it in a given matrix
  62860. * @param x defines the scale factor on X axis
  62861. * @param y defines the scale factor on Y axis
  62862. * @param z defines the scale factor on Z axis
  62863. * @param result defines the target matrix
  62864. */
  62865. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  62866. /**
  62867. * Creates a translation matrix
  62868. * @param x defines the translation on X axis
  62869. * @param y defines the translation on Y axis
  62870. * @param z defines the translationon Z axis
  62871. * @returns the new matrix
  62872. */
  62873. static Translation(x: number, y: number, z: number): Matrix;
  62874. /**
  62875. * Creates a translation matrix and stores it in a given matrix
  62876. * @param x defines the translation on X axis
  62877. * @param y defines the translation on Y axis
  62878. * @param z defines the translationon Z axis
  62879. * @param result defines the target matrix
  62880. */
  62881. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  62882. /**
  62883. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62884. * @param startValue defines the start value
  62885. * @param endValue defines the end value
  62886. * @param gradient defines the gradient factor
  62887. * @returns the new matrix
  62888. */
  62889. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62890. /**
  62891. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  62892. * @param startValue defines the start value
  62893. * @param endValue defines the end value
  62894. * @param gradient defines the gradient factor
  62895. * @param result defines the Matrix object where to store data
  62896. */
  62897. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62898. /**
  62899. * Builds a new matrix whose values are computed by:
  62900. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62901. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62902. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62903. * @param startValue defines the first matrix
  62904. * @param endValue defines the second matrix
  62905. * @param gradient defines the gradient between the two matrices
  62906. * @returns the new matrix
  62907. */
  62908. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  62909. /**
  62910. * Update a matrix to values which are computed by:
  62911. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  62912. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  62913. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  62914. * @param startValue defines the first matrix
  62915. * @param endValue defines the second matrix
  62916. * @param gradient defines the gradient between the two matrices
  62917. * @param result defines the target matrix
  62918. */
  62919. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  62920. /**
  62921. * 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"
  62922. * This function works in left handed mode
  62923. * @param eye defines the final position of the entity
  62924. * @param target defines where the entity should look at
  62925. * @param up defines the up vector for the entity
  62926. * @returns the new matrix
  62927. */
  62928. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62929. /**
  62930. * 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".
  62931. * This function works in left handed mode
  62932. * @param eye defines the final position of the entity
  62933. * @param target defines where the entity should look at
  62934. * @param up defines the up vector for the entity
  62935. * @param result defines the target matrix
  62936. */
  62937. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62938. /**
  62939. * 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"
  62940. * This function works in right handed mode
  62941. * @param eye defines the final position of the entity
  62942. * @param target defines where the entity should look at
  62943. * @param up defines the up vector for the entity
  62944. * @returns the new matrix
  62945. */
  62946. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  62947. /**
  62948. * 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".
  62949. * This function works in right handed mode
  62950. * @param eye defines the final position of the entity
  62951. * @param target defines where the entity should look at
  62952. * @param up defines the up vector for the entity
  62953. * @param result defines the target matrix
  62954. */
  62955. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  62956. /**
  62957. * Create a left-handed orthographic projection matrix
  62958. * @param width defines the viewport width
  62959. * @param height defines the viewport height
  62960. * @param znear defines the near clip plane
  62961. * @param zfar defines the far clip plane
  62962. * @returns a new matrix as a left-handed orthographic projection matrix
  62963. */
  62964. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  62965. /**
  62966. * Store a left-handed orthographic projection to a given matrix
  62967. * @param width defines the viewport width
  62968. * @param height defines the viewport height
  62969. * @param znear defines the near clip plane
  62970. * @param zfar defines the far clip plane
  62971. * @param result defines the target matrix
  62972. */
  62973. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  62974. /**
  62975. * Create a left-handed orthographic projection matrix
  62976. * @param left defines the viewport left coordinate
  62977. * @param right defines the viewport right coordinate
  62978. * @param bottom defines the viewport bottom coordinate
  62979. * @param top defines the viewport top coordinate
  62980. * @param znear defines the near clip plane
  62981. * @param zfar defines the far clip plane
  62982. * @returns a new matrix as a left-handed orthographic projection matrix
  62983. */
  62984. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  62985. /**
  62986. * Stores a left-handed orthographic projection into a given matrix
  62987. * @param left defines the viewport left coordinate
  62988. * @param right defines the viewport right coordinate
  62989. * @param bottom defines the viewport bottom coordinate
  62990. * @param top defines the viewport top coordinate
  62991. * @param znear defines the near clip plane
  62992. * @param zfar defines the far clip plane
  62993. * @param result defines the target matrix
  62994. */
  62995. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  62996. /**
  62997. * Creates a right-handed orthographic projection matrix
  62998. * @param left defines the viewport left coordinate
  62999. * @param right defines the viewport right coordinate
  63000. * @param bottom defines the viewport bottom coordinate
  63001. * @param top defines the viewport top coordinate
  63002. * @param znear defines the near clip plane
  63003. * @param zfar defines the far clip plane
  63004. * @returns a new matrix as a right-handed orthographic projection matrix
  63005. */
  63006. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  63007. /**
  63008. * Stores a right-handed orthographic projection into a given matrix
  63009. * @param left defines the viewport left coordinate
  63010. * @param right defines the viewport right coordinate
  63011. * @param bottom defines the viewport bottom coordinate
  63012. * @param top defines the viewport top coordinate
  63013. * @param znear defines the near clip plane
  63014. * @param zfar defines the far clip plane
  63015. * @param result defines the target matrix
  63016. */
  63017. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  63018. /**
  63019. * Creates a left-handed perspective projection matrix
  63020. * @param width defines the viewport width
  63021. * @param height defines the viewport height
  63022. * @param znear defines the near clip plane
  63023. * @param zfar defines the far clip plane
  63024. * @returns a new matrix as a left-handed perspective projection matrix
  63025. */
  63026. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  63027. /**
  63028. * Creates a left-handed perspective projection matrix
  63029. * @param fov defines the horizontal field of view
  63030. * @param aspect defines the aspect ratio
  63031. * @param znear defines the near clip plane
  63032. * @param zfar defines the far clip plane
  63033. * @returns a new matrix as a left-handed perspective projection matrix
  63034. */
  63035. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63036. /**
  63037. * Stores a left-handed perspective projection into a given matrix
  63038. * @param fov defines the horizontal field of view
  63039. * @param aspect defines the aspect ratio
  63040. * @param znear defines the near clip plane
  63041. * @param zfar defines the far clip plane
  63042. * @param result defines the target matrix
  63043. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63044. */
  63045. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63046. /**
  63047. * Creates a right-handed perspective projection matrix
  63048. * @param fov defines the horizontal field of view
  63049. * @param aspect defines the aspect ratio
  63050. * @param znear defines the near clip plane
  63051. * @param zfar defines the far clip plane
  63052. * @returns a new matrix as a right-handed perspective projection matrix
  63053. */
  63054. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  63055. /**
  63056. * Stores a right-handed perspective projection into a given matrix
  63057. * @param fov defines the horizontal field of view
  63058. * @param aspect defines the aspect ratio
  63059. * @param znear defines the near clip plane
  63060. * @param zfar defines the far clip plane
  63061. * @param result defines the target matrix
  63062. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  63063. */
  63064. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  63065. /**
  63066. * Stores a perspective projection for WebVR info a given matrix
  63067. * @param fov defines the field of view
  63068. * @param znear defines the near clip plane
  63069. * @param zfar defines the far clip plane
  63070. * @param result defines the target matrix
  63071. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  63072. */
  63073. static PerspectiveFovWebVRToRef(fov: {
  63074. upDegrees: number;
  63075. downDegrees: number;
  63076. leftDegrees: number;
  63077. rightDegrees: number;
  63078. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  63079. /**
  63080. * Computes a complete transformation matrix
  63081. * @param viewport defines the viewport to use
  63082. * @param world defines the world matrix
  63083. * @param view defines the view matrix
  63084. * @param projection defines the projection matrix
  63085. * @param zmin defines the near clip plane
  63086. * @param zmax defines the far clip plane
  63087. * @returns the transformation matrix
  63088. */
  63089. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  63090. /**
  63091. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  63092. * @param matrix defines the matrix to use
  63093. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  63094. */
  63095. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array;
  63096. /**
  63097. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  63098. * @param matrix defines the matrix to use
  63099. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  63100. */
  63101. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array;
  63102. /**
  63103. * Compute the transpose of a given matrix
  63104. * @param matrix defines the matrix to transpose
  63105. * @returns the new matrix
  63106. */
  63107. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  63108. /**
  63109. * Compute the transpose of a matrix and store it in a target matrix
  63110. * @param matrix defines the matrix to transpose
  63111. * @param result defines the target matrix
  63112. */
  63113. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  63114. /**
  63115. * Computes a reflection matrix from a plane
  63116. * @param plane defines the reflection plane
  63117. * @returns a new matrix
  63118. */
  63119. static Reflection(plane: DeepImmutable<Plane>): Matrix;
  63120. /**
  63121. * Computes a reflection matrix from a plane
  63122. * @param plane defines the reflection plane
  63123. * @param result defines the target matrix
  63124. */
  63125. static ReflectionToRef(plane: DeepImmutable<Plane>, result: Matrix): void;
  63126. /**
  63127. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  63128. * @param xaxis defines the value of the 1st axis
  63129. * @param yaxis defines the value of the 2nd axis
  63130. * @param zaxis defines the value of the 3rd axis
  63131. * @param result defines the target matrix
  63132. */
  63133. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  63134. /**
  63135. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  63136. * @param quat defines the quaternion to use
  63137. * @param result defines the target matrix
  63138. */
  63139. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  63140. }
  63141. /**
  63142. * Represens a plane by the equation ax + by + cz + d = 0
  63143. */
  63144. export class Plane {
  63145. /**
  63146. * Normal of the plane (a,b,c)
  63147. */
  63148. normal: Vector3;
  63149. /**
  63150. * d component of the plane
  63151. */
  63152. d: number;
  63153. /**
  63154. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  63155. * @param a a component of the plane
  63156. * @param b b component of the plane
  63157. * @param c c component of the plane
  63158. * @param d d component of the plane
  63159. */
  63160. constructor(a: number, b: number, c: number, d: number);
  63161. /**
  63162. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  63163. */
  63164. asArray(): number[];
  63165. /**
  63166. * @returns a new plane copied from the current Plane.
  63167. */
  63168. clone(): Plane;
  63169. /**
  63170. * @returns the string "Plane".
  63171. */
  63172. getClassName(): string;
  63173. /**
  63174. * @returns the Plane hash code.
  63175. */
  63176. getHashCode(): number;
  63177. /**
  63178. * Normalize the current Plane in place.
  63179. * @returns the updated Plane.
  63180. */
  63181. normalize(): Plane;
  63182. /**
  63183. * Applies a transformation the plane and returns the result
  63184. * @param transformation the transformation matrix to be applied to the plane
  63185. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  63186. */
  63187. transform(transformation: DeepImmutable<Matrix>): Plane;
  63188. /**
  63189. * Calcualtte the dot product between the point and the plane normal
  63190. * @param point point to calculate the dot product with
  63191. * @returns the dot product (float) of the point coordinates and the plane normal.
  63192. */
  63193. dotCoordinate(point: DeepImmutable<Vector3>): number;
  63194. /**
  63195. * Updates the current Plane from the plane defined by the three given points.
  63196. * @param point1 one of the points used to contruct the plane
  63197. * @param point2 one of the points used to contruct the plane
  63198. * @param point3 one of the points used to contruct the plane
  63199. * @returns the updated Plane.
  63200. */
  63201. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63202. /**
  63203. * Checks if the plane is facing a given direction
  63204. * @param direction the direction to check if the plane is facing
  63205. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  63206. * @returns True is the vector "direction" is the same side than the plane normal.
  63207. */
  63208. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  63209. /**
  63210. * Calculates the distance to a point
  63211. * @param point point to calculate distance to
  63212. * @returns the signed distance (float) from the given point to the Plane.
  63213. */
  63214. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  63215. /**
  63216. * Creates a plane from an array
  63217. * @param array the array to create a plane from
  63218. * @returns a new Plane from the given array.
  63219. */
  63220. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  63221. /**
  63222. * Creates a plane from three points
  63223. * @param point1 point used to create the plane
  63224. * @param point2 point used to create the plane
  63225. * @param point3 point used to create the plane
  63226. * @returns a new Plane defined by the three given points.
  63227. */
  63228. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  63229. /**
  63230. * Creates a plane from an origin point and a normal
  63231. * @param origin origin of the plane to be constructed
  63232. * @param normal normal of the plane to be constructed
  63233. * @returns a new Plane the normal vector to this plane at the given origin point.
  63234. * Note : the vector "normal" is updated because normalized.
  63235. */
  63236. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): Plane;
  63237. /**
  63238. * Calculates the distance from a plane and a point
  63239. * @param origin origin of the plane to be constructed
  63240. * @param normal normal of the plane to be constructed
  63241. * @param point point to calculate distance to
  63242. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  63243. */
  63244. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  63245. }
  63246. /**
  63247. * Class used to represent a viewport on screen
  63248. */
  63249. export class Viewport {
  63250. /** viewport left coordinate */
  63251. x: number;
  63252. /** viewport top coordinate */
  63253. y: number;
  63254. /**viewport width */
  63255. width: number;
  63256. /** viewport height */
  63257. height: number;
  63258. /**
  63259. * Creates a Viewport object located at (x, y) and sized (width, height)
  63260. * @param x defines viewport left coordinate
  63261. * @param y defines viewport top coordinate
  63262. * @param width defines the viewport width
  63263. * @param height defines the viewport height
  63264. */
  63265. constructor(
  63266. /** viewport left coordinate */
  63267. x: number,
  63268. /** viewport top coordinate */
  63269. y: number,
  63270. /**viewport width */
  63271. width: number,
  63272. /** viewport height */
  63273. height: number);
  63274. /**
  63275. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  63276. * @param renderWidth defines the rendering width
  63277. * @param renderHeight defines the rendering height
  63278. * @returns a new Viewport
  63279. */
  63280. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  63281. /**
  63282. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  63283. * @param renderWidth defines the rendering width
  63284. * @param renderHeight defines the rendering height
  63285. * @param ref defines the target viewport
  63286. * @returns the current viewport
  63287. */
  63288. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  63289. /**
  63290. * Returns a new Viewport copied from the current one
  63291. * @returns a new Viewport
  63292. */
  63293. clone(): Viewport;
  63294. }
  63295. /**
  63296. * Reprasents a camera frustum
  63297. */
  63298. export class Frustum {
  63299. /**
  63300. * Gets the planes representing the frustum
  63301. * @param transform matrix to be applied to the returned planes
  63302. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  63303. */
  63304. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  63305. /**
  63306. * Gets the near frustum plane transformed by the transform matrix
  63307. * @param transform transformation matrix to be applied to the resulting frustum plane
  63308. * @param frustumPlane the resuling frustum plane
  63309. */
  63310. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63311. /**
  63312. * Gets the far frustum plane transformed by the transform matrix
  63313. * @param transform transformation matrix to be applied to the resulting frustum plane
  63314. * @param frustumPlane the resuling frustum plane
  63315. */
  63316. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63317. /**
  63318. * Gets the left frustum plane transformed by the transform matrix
  63319. * @param transform transformation matrix to be applied to the resulting frustum plane
  63320. * @param frustumPlane the resuling frustum plane
  63321. */
  63322. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63323. /**
  63324. * Gets the right frustum plane transformed by the transform matrix
  63325. * @param transform transformation matrix to be applied to the resulting frustum plane
  63326. * @param frustumPlane the resuling frustum plane
  63327. */
  63328. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63329. /**
  63330. * Gets the top frustum plane transformed by the transform matrix
  63331. * @param transform transformation matrix to be applied to the resulting frustum plane
  63332. * @param frustumPlane the resuling frustum plane
  63333. */
  63334. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63335. /**
  63336. * Gets the bottom frustum plane transformed by the transform matrix
  63337. * @param transform transformation matrix to be applied to the resulting frustum plane
  63338. * @param frustumPlane the resuling frustum plane
  63339. */
  63340. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  63341. /**
  63342. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  63343. * @param transform transformation matrix to be applied to the resulting frustum planes
  63344. * @param frustumPlanes the resuling frustum planes
  63345. */
  63346. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  63347. }
  63348. /** Defines supported spaces */
  63349. export enum Space {
  63350. /** Local (object) space */
  63351. LOCAL = 0,
  63352. /** World space */
  63353. WORLD = 1,
  63354. /** Bone space */
  63355. BONE = 2
  63356. }
  63357. /** Defines the 3 main axes */
  63358. export class Axis {
  63359. /** X axis */
  63360. static X: Vector3;
  63361. /** Y axis */
  63362. static Y: Vector3;
  63363. /** Z axis */
  63364. static Z: Vector3;
  63365. }
  63366. /** Class used to represent a Bezier curve */
  63367. export class BezierCurve {
  63368. /**
  63369. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  63370. * @param t defines the time
  63371. * @param x1 defines the left coordinate on X axis
  63372. * @param y1 defines the left coordinate on Y axis
  63373. * @param x2 defines the right coordinate on X axis
  63374. * @param y2 defines the right coordinate on Y axis
  63375. * @returns the interpolated value
  63376. */
  63377. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  63378. }
  63379. /**
  63380. * Defines potential orientation for back face culling
  63381. */
  63382. export enum Orientation {
  63383. /**
  63384. * Clockwise
  63385. */
  63386. CW = 0,
  63387. /** Counter clockwise */
  63388. CCW = 1
  63389. }
  63390. /**
  63391. * Defines angle representation
  63392. */
  63393. export class Angle {
  63394. private _radians;
  63395. /**
  63396. * Creates an Angle object of "radians" radians (float).
  63397. * @param radians the angle in radians
  63398. */
  63399. constructor(radians: number);
  63400. /**
  63401. * Get value in degrees
  63402. * @returns the Angle value in degrees (float)
  63403. */
  63404. degrees(): number;
  63405. /**
  63406. * Get value in radians
  63407. * @returns the Angle value in radians (float)
  63408. */
  63409. radians(): number;
  63410. /**
  63411. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  63412. * @param a defines first vector
  63413. * @param b defines second vector
  63414. * @returns a new Angle
  63415. */
  63416. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  63417. /**
  63418. * Gets a new Angle object from the given float in radians
  63419. * @param radians defines the angle value in radians
  63420. * @returns a new Angle
  63421. */
  63422. static FromRadians(radians: number): Angle;
  63423. /**
  63424. * Gets a new Angle object from the given float in degrees
  63425. * @param degrees defines the angle value in degrees
  63426. * @returns a new Angle
  63427. */
  63428. static FromDegrees(degrees: number): Angle;
  63429. }
  63430. /**
  63431. * This represents an arc in a 2d space.
  63432. */
  63433. export class Arc2 {
  63434. /** Defines the start point of the arc */
  63435. startPoint: Vector2;
  63436. /** Defines the mid point of the arc */
  63437. midPoint: Vector2;
  63438. /** Defines the end point of the arc */
  63439. endPoint: Vector2;
  63440. /**
  63441. * Defines the center point of the arc.
  63442. */
  63443. centerPoint: Vector2;
  63444. /**
  63445. * Defines the radius of the arc.
  63446. */
  63447. radius: number;
  63448. /**
  63449. * Defines the angle of the arc (from mid point to end point).
  63450. */
  63451. angle: Angle;
  63452. /**
  63453. * Defines the start angle of the arc (from start point to middle point).
  63454. */
  63455. startAngle: Angle;
  63456. /**
  63457. * Defines the orientation of the arc (clock wise/counter clock wise).
  63458. */
  63459. orientation: Orientation;
  63460. /**
  63461. * Creates an Arc object from the three given points : start, middle and end.
  63462. * @param startPoint Defines the start point of the arc
  63463. * @param midPoint Defines the midlle point of the arc
  63464. * @param endPoint Defines the end point of the arc
  63465. */
  63466. constructor(
  63467. /** Defines the start point of the arc */
  63468. startPoint: Vector2,
  63469. /** Defines the mid point of the arc */
  63470. midPoint: Vector2,
  63471. /** Defines the end point of the arc */
  63472. endPoint: Vector2);
  63473. }
  63474. /**
  63475. * Represents a 2D path made up of multiple 2D points
  63476. */
  63477. export class Path2 {
  63478. private _points;
  63479. private _length;
  63480. /**
  63481. * If the path start and end point are the same
  63482. */
  63483. closed: boolean;
  63484. /**
  63485. * Creates a Path2 object from the starting 2D coordinates x and y.
  63486. * @param x the starting points x value
  63487. * @param y the starting points y value
  63488. */
  63489. constructor(x: number, y: number);
  63490. /**
  63491. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  63492. * @param x the added points x value
  63493. * @param y the added points y value
  63494. * @returns the updated Path2.
  63495. */
  63496. addLineTo(x: number, y: number): Path2;
  63497. /**
  63498. * 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.
  63499. * @param midX middle point x value
  63500. * @param midY middle point y value
  63501. * @param endX end point x value
  63502. * @param endY end point y value
  63503. * @param numberOfSegments (default: 36)
  63504. * @returns the updated Path2.
  63505. */
  63506. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  63507. /**
  63508. * Closes the Path2.
  63509. * @returns the Path2.
  63510. */
  63511. close(): Path2;
  63512. /**
  63513. * Gets the sum of the distance between each sequential point in the path
  63514. * @returns the Path2 total length (float).
  63515. */
  63516. length(): number;
  63517. /**
  63518. * Gets the points which construct the path
  63519. * @returns the Path2 internal array of points.
  63520. */
  63521. getPoints(): Vector2[];
  63522. /**
  63523. * Retreives the point at the distance aways from the starting point
  63524. * @param normalizedLengthPosition the length along the path to retreive the point from
  63525. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  63526. */
  63527. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  63528. /**
  63529. * Creates a new path starting from an x and y position
  63530. * @param x starting x value
  63531. * @param y starting y value
  63532. * @returns a new Path2 starting at the coordinates (x, y).
  63533. */
  63534. static StartingAt(x: number, y: number): Path2;
  63535. }
  63536. /**
  63537. * Represents a 3D path made up of multiple 3D points
  63538. */
  63539. export class Path3D {
  63540. /**
  63541. * an array of Vector3, the curve axis of the Path3D
  63542. */
  63543. path: Vector3[];
  63544. private _curve;
  63545. private _distances;
  63546. private _tangents;
  63547. private _normals;
  63548. private _binormals;
  63549. private _raw;
  63550. /**
  63551. * new Path3D(path, normal, raw)
  63552. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  63553. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  63554. * @param path an array of Vector3, the curve axis of the Path3D
  63555. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  63556. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  63557. */
  63558. constructor(
  63559. /**
  63560. * an array of Vector3, the curve axis of the Path3D
  63561. */
  63562. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean);
  63563. /**
  63564. * Returns the Path3D array of successive Vector3 designing its curve.
  63565. * @returns the Path3D array of successive Vector3 designing its curve.
  63566. */
  63567. getCurve(): Vector3[];
  63568. /**
  63569. * Returns an array populated with tangent vectors on each Path3D curve point.
  63570. * @returns an array populated with tangent vectors on each Path3D curve point.
  63571. */
  63572. getTangents(): Vector3[];
  63573. /**
  63574. * Returns an array populated with normal vectors on each Path3D curve point.
  63575. * @returns an array populated with normal vectors on each Path3D curve point.
  63576. */
  63577. getNormals(): Vector3[];
  63578. /**
  63579. * Returns an array populated with binormal vectors on each Path3D curve point.
  63580. * @returns an array populated with binormal vectors on each Path3D curve point.
  63581. */
  63582. getBinormals(): Vector3[];
  63583. /**
  63584. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  63585. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  63586. */
  63587. getDistances(): number[];
  63588. /**
  63589. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  63590. * @param path path which all values are copied into the curves points
  63591. * @param firstNormal which should be projected onto the curve
  63592. * @returns the same object updated.
  63593. */
  63594. update(path: Vector3[], firstNormal?: Nullable<Vector3>): Path3D;
  63595. private _compute;
  63596. private _getFirstNonNullVector;
  63597. private _getLastNonNullVector;
  63598. private _normalVector;
  63599. }
  63600. /**
  63601. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63602. * A Curve3 is designed from a series of successive Vector3.
  63603. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  63604. */
  63605. export class Curve3 {
  63606. private _points;
  63607. private _length;
  63608. /**
  63609. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  63610. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  63611. * @param v1 (Vector3) the control point
  63612. * @param v2 (Vector3) the end point of the Quadratic Bezier
  63613. * @param nbPoints (integer) the wanted number of points in the curve
  63614. * @returns the created Curve3
  63615. */
  63616. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63617. /**
  63618. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  63619. * @param v0 (Vector3) the origin point of the Cubic Bezier
  63620. * @param v1 (Vector3) the first control point
  63621. * @param v2 (Vector3) the second control point
  63622. * @param v3 (Vector3) the end point of the Cubic Bezier
  63623. * @param nbPoints (integer) the wanted number of points in the curve
  63624. * @returns the created Curve3
  63625. */
  63626. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63627. /**
  63628. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  63629. * @param p1 (Vector3) the origin point of the Hermite Spline
  63630. * @param t1 (Vector3) the tangent vector at the origin point
  63631. * @param p2 (Vector3) the end point of the Hermite Spline
  63632. * @param t2 (Vector3) the tangent vector at the end point
  63633. * @param nbPoints (integer) the wanted number of points in the curve
  63634. * @returns the created Curve3
  63635. */
  63636. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  63637. /**
  63638. * Returns a Curve3 object along a CatmullRom Spline curve :
  63639. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  63640. * @param nbPoints (integer) the wanted number of points between each curve control points
  63641. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  63642. * @returns the created Curve3
  63643. */
  63644. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  63645. /**
  63646. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  63647. * A Curve3 is designed from a series of successive Vector3.
  63648. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  63649. * @param points points which make up the curve
  63650. */
  63651. constructor(points: Vector3[]);
  63652. /**
  63653. * @returns the Curve3 stored array of successive Vector3
  63654. */
  63655. getPoints(): Vector3[];
  63656. /**
  63657. * @returns the computed length (float) of the curve.
  63658. */
  63659. length(): number;
  63660. /**
  63661. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  63662. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  63663. * curveA and curveB keep unchanged.
  63664. * @param curve the curve to continue from this curve
  63665. * @returns the newly constructed curve
  63666. */
  63667. continue(curve: DeepImmutable<Curve3>): Curve3;
  63668. private _computeLength;
  63669. }
  63670. /**
  63671. * Contains position and normal vectors for a vertex
  63672. */
  63673. export class PositionNormalVertex {
  63674. /** the position of the vertex (defaut: 0,0,0) */
  63675. position: Vector3;
  63676. /** the normal of the vertex (defaut: 0,1,0) */
  63677. normal: Vector3;
  63678. /**
  63679. * Creates a PositionNormalVertex
  63680. * @param position the position of the vertex (defaut: 0,0,0)
  63681. * @param normal the normal of the vertex (defaut: 0,1,0)
  63682. */
  63683. constructor(
  63684. /** the position of the vertex (defaut: 0,0,0) */
  63685. position?: Vector3,
  63686. /** the normal of the vertex (defaut: 0,1,0) */
  63687. normal?: Vector3);
  63688. /**
  63689. * Clones the PositionNormalVertex
  63690. * @returns the cloned PositionNormalVertex
  63691. */
  63692. clone(): PositionNormalVertex;
  63693. }
  63694. /**
  63695. * Contains position, normal and uv vectors for a vertex
  63696. */
  63697. export class PositionNormalTextureVertex {
  63698. /** the position of the vertex (defaut: 0,0,0) */
  63699. position: Vector3;
  63700. /** the normal of the vertex (defaut: 0,1,0) */
  63701. normal: Vector3;
  63702. /** the uv of the vertex (default: 0,0) */
  63703. uv: Vector2;
  63704. /**
  63705. * Creates a PositionNormalTextureVertex
  63706. * @param position the position of the vertex (defaut: 0,0,0)
  63707. * @param normal the normal of the vertex (defaut: 0,1,0)
  63708. * @param uv the uv of the vertex (default: 0,0)
  63709. */
  63710. constructor(
  63711. /** the position of the vertex (defaut: 0,0,0) */
  63712. position?: Vector3,
  63713. /** the normal of the vertex (defaut: 0,1,0) */
  63714. normal?: Vector3,
  63715. /** the uv of the vertex (default: 0,0) */
  63716. uv?: Vector2);
  63717. /**
  63718. * Clones the PositionNormalTextureVertex
  63719. * @returns the cloned PositionNormalTextureVertex
  63720. */
  63721. clone(): PositionNormalTextureVertex;
  63722. }
  63723. /**
  63724. * @hidden
  63725. */
  63726. export class Tmp {
  63727. static Color3: Color3[];
  63728. static Color4: Color4[];
  63729. static Vector2: Vector2[];
  63730. static Vector3: Vector3[];
  63731. static Vector4: Vector4[];
  63732. static Quaternion: Quaternion[];
  63733. static Matrix: Matrix[];
  63734. }
  63735. }
  63736. declare module BABYLON {
  63737. /**
  63738. * Class used to enable access to offline support
  63739. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  63740. */
  63741. export interface IOfflineProvider {
  63742. /**
  63743. * Gets a boolean indicating if scene must be saved in the database
  63744. */
  63745. enableSceneOffline: boolean;
  63746. /**
  63747. * Gets a boolean indicating if textures must be saved in the database
  63748. */
  63749. enableTexturesOffline: boolean;
  63750. /**
  63751. * Open the offline support and make it available
  63752. * @param successCallback defines the callback to call on success
  63753. * @param errorCallback defines the callback to call on error
  63754. */
  63755. open(successCallback: () => void, errorCallback: () => void): void;
  63756. /**
  63757. * Loads an image from the offline support
  63758. * @param url defines the url to load from
  63759. * @param image defines the target DOM image
  63760. */
  63761. loadImage(url: string, image: HTMLImageElement): void;
  63762. /**
  63763. * Loads a file from offline support
  63764. * @param url defines the URL to load from
  63765. * @param sceneLoaded defines a callback to call on success
  63766. * @param progressCallBack defines a callback to call when progress changed
  63767. * @param errorCallback defines a callback to call on error
  63768. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  63769. */
  63770. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  63771. }
  63772. }
  63773. declare module BABYLON {
  63774. /**
  63775. * A class serves as a medium between the observable and its observers
  63776. */
  63777. export class EventState {
  63778. /**
  63779. * Create a new EventState
  63780. * @param mask defines the mask associated with this state
  63781. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63782. * @param target defines the original target of the state
  63783. * @param currentTarget defines the current target of the state
  63784. */
  63785. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  63786. /**
  63787. * Initialize the current event state
  63788. * @param mask defines the mask associated with this state
  63789. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  63790. * @param target defines the original target of the state
  63791. * @param currentTarget defines the current target of the state
  63792. * @returns the current event state
  63793. */
  63794. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  63795. /**
  63796. * An Observer can set this property to true to prevent subsequent observers of being notified
  63797. */
  63798. skipNextObservers: boolean;
  63799. /**
  63800. * Get the mask value that were used to trigger the event corresponding to this EventState object
  63801. */
  63802. mask: number;
  63803. /**
  63804. * The object that originally notified the event
  63805. */
  63806. target?: any;
  63807. /**
  63808. * The current object in the bubbling phase
  63809. */
  63810. currentTarget?: any;
  63811. /**
  63812. * This will be populated with the return value of the last function that was executed.
  63813. * If it is the first function in the callback chain it will be the event data.
  63814. */
  63815. lastReturnValue?: any;
  63816. }
  63817. /**
  63818. * Represent an Observer registered to a given Observable object.
  63819. */
  63820. export class Observer<T> {
  63821. /**
  63822. * Defines the callback to call when the observer is notified
  63823. */
  63824. callback: (eventData: T, eventState: EventState) => void;
  63825. /**
  63826. * Defines the mask of the observer (used to filter notifications)
  63827. */
  63828. mask: number;
  63829. /**
  63830. * Defines the current scope used to restore the JS context
  63831. */
  63832. scope: any;
  63833. /** @hidden */
  63834. _willBeUnregistered: boolean;
  63835. /**
  63836. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  63837. */
  63838. unregisterOnNextCall: boolean;
  63839. /**
  63840. * Creates a new observer
  63841. * @param callback defines the callback to call when the observer is notified
  63842. * @param mask defines the mask of the observer (used to filter notifications)
  63843. * @param scope defines the current scope used to restore the JS context
  63844. */
  63845. constructor(
  63846. /**
  63847. * Defines the callback to call when the observer is notified
  63848. */
  63849. callback: (eventData: T, eventState: EventState) => void,
  63850. /**
  63851. * Defines the mask of the observer (used to filter notifications)
  63852. */
  63853. mask: number,
  63854. /**
  63855. * Defines the current scope used to restore the JS context
  63856. */
  63857. scope?: any);
  63858. }
  63859. /**
  63860. * Represent a list of observers registered to multiple Observables object.
  63861. */
  63862. export class MultiObserver<T> {
  63863. private _observers;
  63864. private _observables;
  63865. /**
  63866. * Release associated resources
  63867. */
  63868. dispose(): void;
  63869. /**
  63870. * Raise a callback when one of the observable will notify
  63871. * @param observables defines a list of observables to watch
  63872. * @param callback defines the callback to call on notification
  63873. * @param mask defines the mask used to filter notifications
  63874. * @param scope defines the current scope used to restore the JS context
  63875. * @returns the new MultiObserver
  63876. */
  63877. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  63878. }
  63879. /**
  63880. * The Observable class is a simple implementation of the Observable pattern.
  63881. *
  63882. * 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.
  63883. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  63884. * 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).
  63885. * 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.
  63886. */
  63887. export class Observable<T> {
  63888. private _observers;
  63889. private _eventState;
  63890. private _onObserverAdded;
  63891. /**
  63892. * Creates a new observable
  63893. * @param onObserverAdded defines a callback to call when a new observer is added
  63894. */
  63895. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  63896. /**
  63897. * Create a new Observer with the specified callback
  63898. * @param callback the callback that will be executed for that Observer
  63899. * @param mask the mask used to filter observers
  63900. * @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.
  63901. * @param scope optional scope for the callback to be called from
  63902. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  63903. * @returns the new observer created for the callback
  63904. */
  63905. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  63906. /**
  63907. * Create a new Observer with the specified callback and unregisters after the next notification
  63908. * @param callback the callback that will be executed for that Observer
  63909. * @returns the new observer created for the callback
  63910. */
  63911. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  63912. /**
  63913. * Remove an Observer from the Observable object
  63914. * @param observer the instance of the Observer to remove
  63915. * @returns false if it doesn't belong to this Observable
  63916. */
  63917. remove(observer: Nullable<Observer<T>>): boolean;
  63918. /**
  63919. * Remove a callback from the Observable object
  63920. * @param callback the callback to remove
  63921. * @param scope optional scope. If used only the callbacks with this scope will be removed
  63922. * @returns false if it doesn't belong to this Observable
  63923. */
  63924. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  63925. private _deferUnregister;
  63926. private _remove;
  63927. /**
  63928. * Moves the observable to the top of the observer list making it get called first when notified
  63929. * @param observer the observer to move
  63930. */
  63931. makeObserverTopPriority(observer: Observer<T>): void;
  63932. /**
  63933. * Moves the observable to the bottom of the observer list making it get called last when notified
  63934. * @param observer the observer to move
  63935. */
  63936. makeObserverBottomPriority(observer: Observer<T>): void;
  63937. /**
  63938. * Notify all Observers by calling their respective callback with the given data
  63939. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  63940. * @param eventData defines the data to send to all observers
  63941. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  63942. * @param target defines the original target of the state
  63943. * @param currentTarget defines the current target of the state
  63944. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  63945. */
  63946. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  63947. /**
  63948. * Calling this will execute each callback, expecting it to be a promise or return a value.
  63949. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  63950. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  63951. * and it is crucial that all callbacks will be executed.
  63952. * The order of the callbacks is kept, callbacks are not executed parallel.
  63953. *
  63954. * @param eventData The data to be sent to each callback
  63955. * @param mask is used to filter observers defaults to -1
  63956. * @param target defines the callback target (see EventState)
  63957. * @param currentTarget defines he current object in the bubbling phase
  63958. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  63959. */
  63960. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  63961. /**
  63962. * Notify a specific observer
  63963. * @param observer defines the observer to notify
  63964. * @param eventData defines the data to be sent to each callback
  63965. * @param mask is used to filter observers defaults to -1
  63966. */
  63967. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  63968. /**
  63969. * Gets a boolean indicating if the observable has at least one observer
  63970. * @returns true is the Observable has at least one Observer registered
  63971. */
  63972. hasObservers(): boolean;
  63973. /**
  63974. * Clear the list of observers
  63975. */
  63976. clear(): void;
  63977. /**
  63978. * Clone the current observable
  63979. * @returns a new observable
  63980. */
  63981. clone(): Observable<T>;
  63982. /**
  63983. * Does this observable handles observer registered with a given mask
  63984. * @param mask defines the mask to be tested
  63985. * @return whether or not one observer registered with the given mask is handeled
  63986. **/
  63987. hasSpecificMask(mask?: number): boolean;
  63988. }
  63989. }
  63990. declare module BABYLON {
  63991. /**
  63992. * Class used to help managing file picking and drag'n'drop
  63993. * File Storage
  63994. */
  63995. export class FilesInputStore {
  63996. /**
  63997. * List of files ready to be loaded
  63998. */
  63999. static FilesToLoad: {
  64000. [key: string]: File;
  64001. };
  64002. }
  64003. }
  64004. declare module BABYLON {
  64005. /** Defines the cross module used constants to avoid circular dependncies */
  64006. export class Constants {
  64007. /** Defines that alpha blending is disabled */
  64008. static readonly ALPHA_DISABLE: number;
  64009. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  64010. static readonly ALPHA_ADD: number;
  64011. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  64012. static readonly ALPHA_COMBINE: number;
  64013. /** Defines that alpha blending to DEST - SRC * DEST */
  64014. static readonly ALPHA_SUBTRACT: number;
  64015. /** Defines that alpha blending to SRC * DEST */
  64016. static readonly ALPHA_MULTIPLY: number;
  64017. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  64018. static readonly ALPHA_MAXIMIZED: number;
  64019. /** Defines that alpha blending to SRC + DEST */
  64020. static readonly ALPHA_ONEONE: number;
  64021. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  64022. static readonly ALPHA_PREMULTIPLIED: number;
  64023. /**
  64024. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  64025. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  64026. */
  64027. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  64028. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  64029. static readonly ALPHA_INTERPOLATE: number;
  64030. /**
  64031. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  64032. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  64033. */
  64034. static readonly ALPHA_SCREENMODE: number;
  64035. /** Defines that the ressource is not delayed*/
  64036. static readonly DELAYLOADSTATE_NONE: number;
  64037. /** Defines that the ressource was successfully delay loaded */
  64038. static readonly DELAYLOADSTATE_LOADED: number;
  64039. /** Defines that the ressource is currently delay loading */
  64040. static readonly DELAYLOADSTATE_LOADING: number;
  64041. /** Defines that the ressource is delayed and has not started loading */
  64042. static readonly DELAYLOADSTATE_NOTLOADED: number;
  64043. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  64044. static readonly NEVER: number;
  64045. /** 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 */
  64046. static readonly ALWAYS: number;
  64047. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  64048. static readonly LESS: number;
  64049. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  64050. static readonly EQUAL: number;
  64051. /** 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 */
  64052. static readonly LEQUAL: number;
  64053. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  64054. static readonly GREATER: number;
  64055. /** 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 */
  64056. static readonly GEQUAL: number;
  64057. /** 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 */
  64058. static readonly NOTEQUAL: number;
  64059. /** Passed to stencilOperation to specify that stencil value must be kept */
  64060. static readonly KEEP: number;
  64061. /** Passed to stencilOperation to specify that stencil value must be replaced */
  64062. static readonly REPLACE: number;
  64063. /** Passed to stencilOperation to specify that stencil value must be incremented */
  64064. static readonly INCR: number;
  64065. /** Passed to stencilOperation to specify that stencil value must be decremented */
  64066. static readonly DECR: number;
  64067. /** Passed to stencilOperation to specify that stencil value must be inverted */
  64068. static readonly INVERT: number;
  64069. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  64070. static readonly INCR_WRAP: number;
  64071. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  64072. static readonly DECR_WRAP: number;
  64073. /** Texture is not repeating outside of 0..1 UVs */
  64074. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  64075. /** Texture is repeating outside of 0..1 UVs */
  64076. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  64077. /** Texture is repeating and mirrored */
  64078. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  64079. /** ALPHA */
  64080. static readonly TEXTUREFORMAT_ALPHA: number;
  64081. /** LUMINANCE */
  64082. static readonly TEXTUREFORMAT_LUMINANCE: number;
  64083. /** LUMINANCE_ALPHA */
  64084. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  64085. /** RGB */
  64086. static readonly TEXTUREFORMAT_RGB: number;
  64087. /** RGBA */
  64088. static readonly TEXTUREFORMAT_RGBA: number;
  64089. /** RED */
  64090. static readonly TEXTUREFORMAT_RED: number;
  64091. /** RED (2nd reference) */
  64092. static readonly TEXTUREFORMAT_R: number;
  64093. /** RG */
  64094. static readonly TEXTUREFORMAT_RG: number;
  64095. /** RED_INTEGER */
  64096. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  64097. /** RED_INTEGER (2nd reference) */
  64098. static readonly TEXTUREFORMAT_R_INTEGER: number;
  64099. /** RG_INTEGER */
  64100. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  64101. /** RGB_INTEGER */
  64102. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  64103. /** RGBA_INTEGER */
  64104. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  64105. /** UNSIGNED_BYTE */
  64106. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  64107. /** UNSIGNED_BYTE (2nd reference) */
  64108. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  64109. /** FLOAT */
  64110. static readonly TEXTURETYPE_FLOAT: number;
  64111. /** HALF_FLOAT */
  64112. static readonly TEXTURETYPE_HALF_FLOAT: number;
  64113. /** BYTE */
  64114. static readonly TEXTURETYPE_BYTE: number;
  64115. /** SHORT */
  64116. static readonly TEXTURETYPE_SHORT: number;
  64117. /** UNSIGNED_SHORT */
  64118. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  64119. /** INT */
  64120. static readonly TEXTURETYPE_INT: number;
  64121. /** UNSIGNED_INT */
  64122. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  64123. /** UNSIGNED_SHORT_4_4_4_4 */
  64124. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  64125. /** UNSIGNED_SHORT_5_5_5_1 */
  64126. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  64127. /** UNSIGNED_SHORT_5_6_5 */
  64128. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  64129. /** UNSIGNED_INT_2_10_10_10_REV */
  64130. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  64131. /** UNSIGNED_INT_24_8 */
  64132. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  64133. /** UNSIGNED_INT_10F_11F_11F_REV */
  64134. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  64135. /** UNSIGNED_INT_5_9_9_9_REV */
  64136. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  64137. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  64138. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  64139. /** nearest is mag = nearest and min = nearest and mip = linear */
  64140. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  64141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64142. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  64143. /** Trilinear is mag = linear and min = linear and mip = linear */
  64144. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  64145. /** nearest is mag = nearest and min = nearest and mip = linear */
  64146. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  64147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  64148. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  64149. /** Trilinear is mag = linear and min = linear and mip = linear */
  64150. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  64151. /** mag = nearest and min = nearest and mip = nearest */
  64152. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  64153. /** mag = nearest and min = linear and mip = nearest */
  64154. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  64155. /** mag = nearest and min = linear and mip = linear */
  64156. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  64157. /** mag = nearest and min = linear and mip = none */
  64158. static readonly TEXTURE_NEAREST_LINEAR: number;
  64159. /** mag = nearest and min = nearest and mip = none */
  64160. static readonly TEXTURE_NEAREST_NEAREST: number;
  64161. /** mag = linear and min = nearest and mip = nearest */
  64162. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  64163. /** mag = linear and min = nearest and mip = linear */
  64164. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  64165. /** mag = linear and min = linear and mip = none */
  64166. static readonly TEXTURE_LINEAR_LINEAR: number;
  64167. /** mag = linear and min = nearest and mip = none */
  64168. static readonly TEXTURE_LINEAR_NEAREST: number;
  64169. /** Explicit coordinates mode */
  64170. static readonly TEXTURE_EXPLICIT_MODE: number;
  64171. /** Spherical coordinates mode */
  64172. static readonly TEXTURE_SPHERICAL_MODE: number;
  64173. /** Planar coordinates mode */
  64174. static readonly TEXTURE_PLANAR_MODE: number;
  64175. /** Cubic coordinates mode */
  64176. static readonly TEXTURE_CUBIC_MODE: number;
  64177. /** Projection coordinates mode */
  64178. static readonly TEXTURE_PROJECTION_MODE: number;
  64179. /** Skybox coordinates mode */
  64180. static readonly TEXTURE_SKYBOX_MODE: number;
  64181. /** Inverse Cubic coordinates mode */
  64182. static readonly TEXTURE_INVCUBIC_MODE: number;
  64183. /** Equirectangular coordinates mode */
  64184. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  64185. /** Equirectangular Fixed coordinates mode */
  64186. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  64187. /** Equirectangular Fixed Mirrored coordinates mode */
  64188. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  64189. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  64190. static readonly SCALEMODE_FLOOR: number;
  64191. /** Defines that texture rescaling will look for the nearest power of 2 size */
  64192. static readonly SCALEMODE_NEAREST: number;
  64193. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  64194. static readonly SCALEMODE_CEILING: number;
  64195. /**
  64196. * The dirty texture flag value
  64197. */
  64198. static readonly MATERIAL_TextureDirtyFlag: number;
  64199. /**
  64200. * The dirty light flag value
  64201. */
  64202. static readonly MATERIAL_LightDirtyFlag: number;
  64203. /**
  64204. * The dirty fresnel flag value
  64205. */
  64206. static readonly MATERIAL_FresnelDirtyFlag: number;
  64207. /**
  64208. * The dirty attribute flag value
  64209. */
  64210. static readonly MATERIAL_AttributesDirtyFlag: number;
  64211. /**
  64212. * The dirty misc flag value
  64213. */
  64214. static readonly MATERIAL_MiscDirtyFlag: number;
  64215. /**
  64216. * The all dirty flag value
  64217. */
  64218. static readonly MATERIAL_AllDirtyFlag: number;
  64219. /**
  64220. * Returns the triangle fill mode
  64221. */
  64222. static readonly MATERIAL_TriangleFillMode: number;
  64223. /**
  64224. * Returns the wireframe mode
  64225. */
  64226. static readonly MATERIAL_WireFrameFillMode: number;
  64227. /**
  64228. * Returns the point fill mode
  64229. */
  64230. static readonly MATERIAL_PointFillMode: number;
  64231. /**
  64232. * Returns the point list draw mode
  64233. */
  64234. static readonly MATERIAL_PointListDrawMode: number;
  64235. /**
  64236. * Returns the line list draw mode
  64237. */
  64238. static readonly MATERIAL_LineListDrawMode: number;
  64239. /**
  64240. * Returns the line loop draw mode
  64241. */
  64242. static readonly MATERIAL_LineLoopDrawMode: number;
  64243. /**
  64244. * Returns the line strip draw mode
  64245. */
  64246. static readonly MATERIAL_LineStripDrawMode: number;
  64247. /**
  64248. * Returns the triangle strip draw mode
  64249. */
  64250. static readonly MATERIAL_TriangleStripDrawMode: number;
  64251. /**
  64252. * Returns the triangle fan draw mode
  64253. */
  64254. static readonly MATERIAL_TriangleFanDrawMode: number;
  64255. /**
  64256. * Stores the clock-wise side orientation
  64257. */
  64258. static readonly MATERIAL_ClockWiseSideOrientation: number;
  64259. /**
  64260. * Stores the counter clock-wise side orientation
  64261. */
  64262. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  64263. /**
  64264. * Nothing
  64265. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64266. */
  64267. static readonly ACTION_NothingTrigger: number;
  64268. /**
  64269. * On pick
  64270. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64271. */
  64272. static readonly ACTION_OnPickTrigger: number;
  64273. /**
  64274. * On left pick
  64275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64276. */
  64277. static readonly ACTION_OnLeftPickTrigger: number;
  64278. /**
  64279. * On right pick
  64280. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64281. */
  64282. static readonly ACTION_OnRightPickTrigger: number;
  64283. /**
  64284. * On center pick
  64285. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64286. */
  64287. static readonly ACTION_OnCenterPickTrigger: number;
  64288. /**
  64289. * On pick down
  64290. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64291. */
  64292. static readonly ACTION_OnPickDownTrigger: number;
  64293. /**
  64294. * On double pick
  64295. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64296. */
  64297. static readonly ACTION_OnDoublePickTrigger: number;
  64298. /**
  64299. * On pick up
  64300. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64301. */
  64302. static readonly ACTION_OnPickUpTrigger: number;
  64303. /**
  64304. * On pick out.
  64305. * This trigger will only be raised if you also declared a OnPickDown
  64306. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64307. */
  64308. static readonly ACTION_OnPickOutTrigger: number;
  64309. /**
  64310. * On long press
  64311. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64312. */
  64313. static readonly ACTION_OnLongPressTrigger: number;
  64314. /**
  64315. * On pointer over
  64316. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64317. */
  64318. static readonly ACTION_OnPointerOverTrigger: number;
  64319. /**
  64320. * On pointer out
  64321. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64322. */
  64323. static readonly ACTION_OnPointerOutTrigger: number;
  64324. /**
  64325. * On every frame
  64326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64327. */
  64328. static readonly ACTION_OnEveryFrameTrigger: number;
  64329. /**
  64330. * On intersection enter
  64331. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64332. */
  64333. static readonly ACTION_OnIntersectionEnterTrigger: number;
  64334. /**
  64335. * On intersection exit
  64336. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64337. */
  64338. static readonly ACTION_OnIntersectionExitTrigger: number;
  64339. /**
  64340. * On key down
  64341. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64342. */
  64343. static readonly ACTION_OnKeyDownTrigger: number;
  64344. /**
  64345. * On key up
  64346. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  64347. */
  64348. static readonly ACTION_OnKeyUpTrigger: number;
  64349. /**
  64350. * Billboard mode will only apply to Y axis
  64351. */
  64352. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  64353. /**
  64354. * Billboard mode will apply to all axes
  64355. */
  64356. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  64357. /**
  64358. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  64359. */
  64360. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  64361. /**
  64362. * Gets or sets base Assets URL
  64363. */
  64364. static readonly PARTICLES_BaseAssetsUrl: string;
  64365. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  64366. * Test order :
  64367. * Is the bounding sphere outside the frustum ?
  64368. * If not, are the bounding box vertices outside the frustum ?
  64369. * It not, then the cullable object is in the frustum.
  64370. */
  64371. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  64372. /** Culling strategy : Bounding Sphere Only.
  64373. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  64374. * It's also less accurate than the standard because some not visible objects can still be selected.
  64375. * Test : is the bounding sphere outside the frustum ?
  64376. * If not, then the cullable object is in the frustum.
  64377. */
  64378. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  64379. /** Culling strategy : Optimistic Inclusion.
  64380. * This in an inclusion test first, then the standard exclusion test.
  64381. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  64382. * 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.
  64383. * Anyway, it's as accurate as the standard strategy.
  64384. * Test :
  64385. * Is the cullable object bounding sphere center in the frustum ?
  64386. * If not, apply the default culling strategy.
  64387. */
  64388. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  64389. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  64390. * This in an inclusion test first, then the bounding sphere only exclusion test.
  64391. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  64392. * 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.
  64393. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  64394. * Test :
  64395. * Is the cullable object bounding sphere center in the frustum ?
  64396. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  64397. */
  64398. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  64399. /**
  64400. * No logging while loading
  64401. */
  64402. static readonly SCENELOADER_NO_LOGGING: number;
  64403. /**
  64404. * Minimal logging while loading
  64405. */
  64406. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  64407. /**
  64408. * Summary logging while loading
  64409. */
  64410. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  64411. /**
  64412. * Detailled logging while loading
  64413. */
  64414. static readonly SCENELOADER_DETAILED_LOGGING: number;
  64415. }
  64416. }
  64417. declare module BABYLON {
  64418. /**
  64419. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  64420. * Babylon.js
  64421. */
  64422. export class DomManagement {
  64423. /**
  64424. * Checks if the window object exists
  64425. * @returns true if the window object exists
  64426. */
  64427. static IsWindowObjectExist(): boolean;
  64428. /**
  64429. * Extracts text content from a DOM element hierarchy
  64430. * @param element defines the root element
  64431. * @returns a string
  64432. */
  64433. static GetDOMTextContent(element: HTMLElement): string;
  64434. }
  64435. }
  64436. declare module BABYLON {
  64437. /**
  64438. * Logger used througouht the application to allow configuration of
  64439. * the log level required for the messages.
  64440. */
  64441. export class Logger {
  64442. /**
  64443. * No log
  64444. */
  64445. static readonly NoneLogLevel: number;
  64446. /**
  64447. * Only message logs
  64448. */
  64449. static readonly MessageLogLevel: number;
  64450. /**
  64451. * Only warning logs
  64452. */
  64453. static readonly WarningLogLevel: number;
  64454. /**
  64455. * Only error logs
  64456. */
  64457. static readonly ErrorLogLevel: number;
  64458. /**
  64459. * All logs
  64460. */
  64461. static readonly AllLogLevel: number;
  64462. private static _LogCache;
  64463. /**
  64464. * Gets a value indicating the number of loading errors
  64465. * @ignorenaming
  64466. */
  64467. static errorsCount: number;
  64468. /**
  64469. * Callback called when a new log is added
  64470. */
  64471. static OnNewCacheEntry: (entry: string) => void;
  64472. private static _AddLogEntry;
  64473. private static _FormatMessage;
  64474. private static _LogDisabled;
  64475. private static _LogEnabled;
  64476. private static _WarnDisabled;
  64477. private static _WarnEnabled;
  64478. private static _ErrorDisabled;
  64479. private static _ErrorEnabled;
  64480. /**
  64481. * Log a message to the console
  64482. */
  64483. static Log: (message: string) => void;
  64484. /**
  64485. * Write a warning message to the console
  64486. */
  64487. static Warn: (message: string) => void;
  64488. /**
  64489. * Write an error message to the console
  64490. */
  64491. static Error: (message: string) => void;
  64492. /**
  64493. * Gets current log cache (list of logs)
  64494. */
  64495. static readonly LogCache: string;
  64496. /**
  64497. * Clears the log cache
  64498. */
  64499. static ClearLogCache(): void;
  64500. /**
  64501. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  64502. */
  64503. static LogLevels: number;
  64504. }
  64505. }
  64506. declare module BABYLON {
  64507. /** @hidden */
  64508. export class _TypeStore {
  64509. /** @hidden */
  64510. static RegisteredTypes: {
  64511. [key: string]: Object;
  64512. };
  64513. /** @hidden */
  64514. static GetClass(fqdn: string): any;
  64515. }
  64516. }
  64517. declare module BABYLON {
  64518. /**
  64519. * Class containing a set of static utilities functions for deep copy.
  64520. */
  64521. export class DeepCopier {
  64522. /**
  64523. * Tries to copy an object by duplicating every property
  64524. * @param source defines the source object
  64525. * @param destination defines the target object
  64526. * @param doNotCopyList defines a list of properties to avoid
  64527. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  64528. */
  64529. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  64530. }
  64531. }
  64532. declare module BABYLON {
  64533. /**
  64534. * Class containing a set of static utilities functions for precision date
  64535. */
  64536. export class PrecisionDate {
  64537. /**
  64538. * Gets either window.performance.now() if supported or Date.now() else
  64539. */
  64540. static readonly Now: number;
  64541. }
  64542. }
  64543. declare module BABYLON {
  64544. /** @hidden */
  64545. export class _DevTools {
  64546. static WarnImport(name: string): string;
  64547. }
  64548. }
  64549. declare module BABYLON {
  64550. /**
  64551. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  64552. */
  64553. export class WebRequest {
  64554. private _xhr;
  64555. /**
  64556. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  64557. * i.e. when loading files, where the server/service expects an Authorization header
  64558. */
  64559. static CustomRequestHeaders: {
  64560. [key: string]: string;
  64561. };
  64562. /**
  64563. * Add callback functions in this array to update all the requests before they get sent to the network
  64564. */
  64565. static CustomRequestModifiers: ((request: XMLHttpRequest) => void)[];
  64566. private _injectCustomRequestHeaders;
  64567. /**
  64568. * Gets or sets a function to be called when loading progress changes
  64569. */
  64570. onprogress: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  64571. /**
  64572. * Returns client's state
  64573. */
  64574. readonly readyState: number;
  64575. /**
  64576. * Returns client's status
  64577. */
  64578. readonly status: number;
  64579. /**
  64580. * Returns client's status as a text
  64581. */
  64582. readonly statusText: string;
  64583. /**
  64584. * Returns client's response
  64585. */
  64586. readonly response: any;
  64587. /**
  64588. * Returns client's response url
  64589. */
  64590. readonly responseURL: string;
  64591. /**
  64592. * Returns client's response as text
  64593. */
  64594. readonly responseText: string;
  64595. /**
  64596. * Gets or sets the expected response type
  64597. */
  64598. responseType: XMLHttpRequestResponseType;
  64599. /** @hidden */
  64600. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  64601. /** @hidden */
  64602. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  64603. /**
  64604. * Cancels any network activity
  64605. */
  64606. abort(): void;
  64607. /**
  64608. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  64609. * @param body defines an optional request body
  64610. */
  64611. send(body?: Document | BodyInit | null): void;
  64612. /**
  64613. * Sets the request method, request URL
  64614. * @param method defines the method to use (GET, POST, etc..)
  64615. * @param url defines the url to connect with
  64616. */
  64617. open(method: string, url: string): void;
  64618. }
  64619. }
  64620. declare module BABYLON {
  64621. /**
  64622. * Class used to evalaute queries containing `and` and `or` operators
  64623. */
  64624. export class AndOrNotEvaluator {
  64625. /**
  64626. * Evaluate a query
  64627. * @param query defines the query to evaluate
  64628. * @param evaluateCallback defines the callback used to filter result
  64629. * @returns true if the query matches
  64630. */
  64631. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  64632. private static _HandleParenthesisContent;
  64633. private static _SimplifyNegation;
  64634. }
  64635. }
  64636. declare module BABYLON {
  64637. /**
  64638. * Class used to store custom tags
  64639. */
  64640. export class Tags {
  64641. /**
  64642. * Adds support for tags on the given object
  64643. * @param obj defines the object to use
  64644. */
  64645. static EnableFor(obj: any): void;
  64646. /**
  64647. * Removes tags support
  64648. * @param obj defines the object to use
  64649. */
  64650. static DisableFor(obj: any): void;
  64651. /**
  64652. * Gets a boolean indicating if the given object has tags
  64653. * @param obj defines the object to use
  64654. * @returns a boolean
  64655. */
  64656. static HasTags(obj: any): boolean;
  64657. /**
  64658. * Gets the tags available on a given object
  64659. * @param obj defines the object to use
  64660. * @param asString defines if the tags must be returned as a string instead of an array of strings
  64661. * @returns the tags
  64662. */
  64663. static GetTags(obj: any, asString?: boolean): any;
  64664. /**
  64665. * Adds tags to an object
  64666. * @param obj defines the object to use
  64667. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  64668. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  64669. */
  64670. static AddTagsTo(obj: any, tagsString: string): void;
  64671. /**
  64672. * @hidden
  64673. */
  64674. static _AddTagTo(obj: any, tag: string): void;
  64675. /**
  64676. * Removes specific tags from a specific object
  64677. * @param obj defines the object to use
  64678. * @param tagsString defines the tags to remove
  64679. */
  64680. static RemoveTagsFrom(obj: any, tagsString: string): void;
  64681. /**
  64682. * @hidden
  64683. */
  64684. static _RemoveTagFrom(obj: any, tag: string): void;
  64685. /**
  64686. * Defines if tags hosted on an object match a given query
  64687. * @param obj defines the object to use
  64688. * @param tagsQuery defines the tag query
  64689. * @returns a boolean
  64690. */
  64691. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  64692. }
  64693. }
  64694. declare module BABYLON {
  64695. /**
  64696. * Manages the defines for the Material
  64697. */
  64698. export class MaterialDefines {
  64699. private _keys;
  64700. private _isDirty;
  64701. /** @hidden */
  64702. _renderId: number;
  64703. /** @hidden */
  64704. _areLightsDirty: boolean;
  64705. /** @hidden */
  64706. _areAttributesDirty: boolean;
  64707. /** @hidden */
  64708. _areTexturesDirty: boolean;
  64709. /** @hidden */
  64710. _areFresnelDirty: boolean;
  64711. /** @hidden */
  64712. _areMiscDirty: boolean;
  64713. /** @hidden */
  64714. _areImageProcessingDirty: boolean;
  64715. /** @hidden */
  64716. _normals: boolean;
  64717. /** @hidden */
  64718. _uvs: boolean;
  64719. /** @hidden */
  64720. _needNormals: boolean;
  64721. /** @hidden */
  64722. _needUVs: boolean;
  64723. /**
  64724. * Specifies if the material needs to be re-calculated
  64725. */
  64726. readonly isDirty: boolean;
  64727. /**
  64728. * Marks the material to indicate that it has been re-calculated
  64729. */
  64730. markAsProcessed(): void;
  64731. /**
  64732. * Marks the material to indicate that it needs to be re-calculated
  64733. */
  64734. markAsUnprocessed(): void;
  64735. /**
  64736. * Marks the material to indicate all of its defines need to be re-calculated
  64737. */
  64738. markAllAsDirty(): void;
  64739. /**
  64740. * Marks the material to indicate that image processing needs to be re-calculated
  64741. */
  64742. markAsImageProcessingDirty(): void;
  64743. /**
  64744. * Marks the material to indicate the lights need to be re-calculated
  64745. */
  64746. markAsLightDirty(): void;
  64747. /**
  64748. * Marks the attribute state as changed
  64749. */
  64750. markAsAttributesDirty(): void;
  64751. /**
  64752. * Marks the texture state as changed
  64753. */
  64754. markAsTexturesDirty(): void;
  64755. /**
  64756. * Marks the fresnel state as changed
  64757. */
  64758. markAsFresnelDirty(): void;
  64759. /**
  64760. * Marks the misc state as changed
  64761. */
  64762. markAsMiscDirty(): void;
  64763. /**
  64764. * Rebuilds the material defines
  64765. */
  64766. rebuild(): void;
  64767. /**
  64768. * Specifies if two material defines are equal
  64769. * @param other - A material define instance to compare to
  64770. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  64771. */
  64772. isEqual(other: MaterialDefines): boolean;
  64773. /**
  64774. * Clones this instance's defines to another instance
  64775. * @param other - material defines to clone values to
  64776. */
  64777. cloneTo(other: MaterialDefines): void;
  64778. /**
  64779. * Resets the material define values
  64780. */
  64781. reset(): void;
  64782. /**
  64783. * Converts the material define values to a string
  64784. * @returns - String of material define information
  64785. */
  64786. toString(): string;
  64787. }
  64788. }
  64789. declare module BABYLON {
  64790. /**
  64791. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  64792. */
  64793. export class PerformanceMonitor {
  64794. private _enabled;
  64795. private _rollingFrameTime;
  64796. private _lastFrameTimeMs;
  64797. /**
  64798. * constructor
  64799. * @param frameSampleSize The number of samples required to saturate the sliding window
  64800. */
  64801. constructor(frameSampleSize?: number);
  64802. /**
  64803. * Samples current frame
  64804. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  64805. */
  64806. sampleFrame(timeMs?: number): void;
  64807. /**
  64808. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64809. */
  64810. readonly averageFrameTime: number;
  64811. /**
  64812. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  64813. */
  64814. readonly averageFrameTimeVariance: number;
  64815. /**
  64816. * Returns the frame time of the most recent frame
  64817. */
  64818. readonly instantaneousFrameTime: number;
  64819. /**
  64820. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  64821. */
  64822. readonly averageFPS: number;
  64823. /**
  64824. * Returns the average framerate in frames per second using the most recent frame time
  64825. */
  64826. readonly instantaneousFPS: number;
  64827. /**
  64828. * Returns true if enough samples have been taken to completely fill the sliding window
  64829. */
  64830. readonly isSaturated: boolean;
  64831. /**
  64832. * Enables contributions to the sliding window sample set
  64833. */
  64834. enable(): void;
  64835. /**
  64836. * Disables contributions to the sliding window sample set
  64837. * Samples will not be interpolated over the disabled period
  64838. */
  64839. disable(): void;
  64840. /**
  64841. * Returns true if sampling is enabled
  64842. */
  64843. readonly isEnabled: boolean;
  64844. /**
  64845. * Resets performance monitor
  64846. */
  64847. reset(): void;
  64848. }
  64849. /**
  64850. * RollingAverage
  64851. *
  64852. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  64853. */
  64854. export class RollingAverage {
  64855. /**
  64856. * Current average
  64857. */
  64858. average: number;
  64859. /**
  64860. * Current variance
  64861. */
  64862. variance: number;
  64863. protected _samples: Array<number>;
  64864. protected _sampleCount: number;
  64865. protected _pos: number;
  64866. protected _m2: number;
  64867. /**
  64868. * constructor
  64869. * @param length The number of samples required to saturate the sliding window
  64870. */
  64871. constructor(length: number);
  64872. /**
  64873. * Adds a sample to the sample set
  64874. * @param v The sample value
  64875. */
  64876. add(v: number): void;
  64877. /**
  64878. * Returns previously added values or null if outside of history or outside the sliding window domain
  64879. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  64880. * @return Value previously recorded with add() or null if outside of range
  64881. */
  64882. history(i: number): number;
  64883. /**
  64884. * Returns true if enough samples have been taken to completely fill the sliding window
  64885. * @return true if sample-set saturated
  64886. */
  64887. isSaturated(): boolean;
  64888. /**
  64889. * Resets the rolling average (equivalent to 0 samples taken so far)
  64890. */
  64891. reset(): void;
  64892. /**
  64893. * Wraps a value around the sample range boundaries
  64894. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  64895. * @return Wrapped position in sample range
  64896. */
  64897. protected _wrapPosition(i: number): number;
  64898. }
  64899. }
  64900. declare module BABYLON {
  64901. /**
  64902. * This class implement a typical dictionary using a string as key and the generic type T as value.
  64903. * The underlying implementation relies on an associative array to ensure the best performances.
  64904. * The value can be anything including 'null' but except 'undefined'
  64905. */
  64906. export class StringDictionary<T> {
  64907. /**
  64908. * This will clear this dictionary and copy the content from the 'source' one.
  64909. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  64910. * @param source the dictionary to take the content from and copy to this dictionary
  64911. */
  64912. copyFrom(source: StringDictionary<T>): void;
  64913. /**
  64914. * Get a value based from its key
  64915. * @param key the given key to get the matching value from
  64916. * @return the value if found, otherwise undefined is returned
  64917. */
  64918. get(key: string): T | undefined;
  64919. /**
  64920. * Get a value from its key or add it if it doesn't exist.
  64921. * This method will ensure you that a given key/data will be present in the dictionary.
  64922. * @param key the given key to get the matching value from
  64923. * @param factory the factory that will create the value if the key is not present in the dictionary.
  64924. * The factory will only be invoked if there's no data for the given key.
  64925. * @return the value corresponding to the key.
  64926. */
  64927. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  64928. /**
  64929. * Get a value from its key if present in the dictionary otherwise add it
  64930. * @param key the key to get the value from
  64931. * @param val if there's no such key/value pair in the dictionary add it with this value
  64932. * @return the value corresponding to the key
  64933. */
  64934. getOrAdd(key: string, val: T): T;
  64935. /**
  64936. * Check if there's a given key in the dictionary
  64937. * @param key the key to check for
  64938. * @return true if the key is present, false otherwise
  64939. */
  64940. contains(key: string): boolean;
  64941. /**
  64942. * Add a new key and its corresponding value
  64943. * @param key the key to add
  64944. * @param value the value corresponding to the key
  64945. * @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
  64946. */
  64947. add(key: string, value: T): boolean;
  64948. /**
  64949. * Update a specific value associated to a key
  64950. * @param key defines the key to use
  64951. * @param value defines the value to store
  64952. * @returns true if the value was updated (or false if the key was not found)
  64953. */
  64954. set(key: string, value: T): boolean;
  64955. /**
  64956. * Get the element of the given key and remove it from the dictionary
  64957. * @param key defines the key to search
  64958. * @returns the value associated with the key or null if not found
  64959. */
  64960. getAndRemove(key: string): Nullable<T>;
  64961. /**
  64962. * Remove a key/value from the dictionary.
  64963. * @param key the key to remove
  64964. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  64965. */
  64966. remove(key: string): boolean;
  64967. /**
  64968. * Clear the whole content of the dictionary
  64969. */
  64970. clear(): void;
  64971. /**
  64972. * Gets the current count
  64973. */
  64974. readonly count: number;
  64975. /**
  64976. * Execute a callback on each key/val of the dictionary.
  64977. * Note that you can remove any element in this dictionary in the callback implementation
  64978. * @param callback the callback to execute on a given key/value pair
  64979. */
  64980. forEach(callback: (key: string, val: T) => void): void;
  64981. /**
  64982. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  64983. * If the callback returns null or undefined the method will iterate to the next key/value pair
  64984. * Note that you can remove any element in this dictionary in the callback implementation
  64985. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  64986. * @returns the first item
  64987. */
  64988. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  64989. private _count;
  64990. private _data;
  64991. }
  64992. }
  64993. declare module BABYLON {
  64994. /**
  64995. * Helper class that provides a small promise polyfill
  64996. */
  64997. export class PromisePolyfill {
  64998. /**
  64999. * Static function used to check if the polyfill is required
  65000. * If this is the case then the function will inject the polyfill to window.Promise
  65001. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  65002. */
  65003. static Apply(force?: boolean): void;
  65004. }
  65005. }
  65006. declare module BABYLON {
  65007. /**
  65008. * Class used to store data that will be store in GPU memory
  65009. */
  65010. export class Buffer {
  65011. private _engine;
  65012. private _buffer;
  65013. /** @hidden */
  65014. _data: Nullable<DataArray>;
  65015. private _updatable;
  65016. private _instanced;
  65017. /**
  65018. * Gets the byte stride.
  65019. */
  65020. readonly byteStride: number;
  65021. /**
  65022. * Constructor
  65023. * @param engine the engine
  65024. * @param data the data to use for this buffer
  65025. * @param updatable whether the data is updatable
  65026. * @param stride the stride (optional)
  65027. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65028. * @param instanced whether the buffer is instanced (optional)
  65029. * @param useBytes set to true if the stride in in bytes (optional)
  65030. */
  65031. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean);
  65032. /**
  65033. * Create a new VertexBuffer based on the current buffer
  65034. * @param kind defines the vertex buffer kind (position, normal, etc.)
  65035. * @param offset defines offset in the buffer (0 by default)
  65036. * @param size defines the size in floats of attributes (position is 3 for instance)
  65037. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  65038. * @param instanced defines if the vertex buffer contains indexed data
  65039. * @param useBytes defines if the offset and stride are in bytes
  65040. * @returns the new vertex buffer
  65041. */
  65042. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean): VertexBuffer;
  65043. /**
  65044. * Gets a boolean indicating if the Buffer is updatable?
  65045. * @returns true if the buffer is updatable
  65046. */
  65047. isUpdatable(): boolean;
  65048. /**
  65049. * Gets current buffer's data
  65050. * @returns a DataArray or null
  65051. */
  65052. getData(): Nullable<DataArray>;
  65053. /**
  65054. * Gets underlying native buffer
  65055. * @returns underlying native buffer
  65056. */
  65057. getBuffer(): Nullable<WebGLBuffer>;
  65058. /**
  65059. * Gets the stride in float32 units (i.e. byte stride / 4).
  65060. * May not be an integer if the byte stride is not divisible by 4.
  65061. * DEPRECATED. Use byteStride instead.
  65062. * @returns the stride in float32 units
  65063. */
  65064. getStrideSize(): number;
  65065. /**
  65066. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65067. * @param data defines the data to store
  65068. */
  65069. create(data?: Nullable<DataArray>): void;
  65070. /** @hidden */
  65071. _rebuild(): void;
  65072. /**
  65073. * Update current buffer data
  65074. * @param data defines the data to store
  65075. */
  65076. update(data: DataArray): void;
  65077. /**
  65078. * Updates the data directly.
  65079. * @param data the new data
  65080. * @param offset the new offset
  65081. * @param vertexCount the vertex count (optional)
  65082. * @param useBytes set to true if the offset is in bytes
  65083. */
  65084. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  65085. /**
  65086. * Release all resources
  65087. */
  65088. dispose(): void;
  65089. }
  65090. /**
  65091. * Specialized buffer used to store vertex data
  65092. */
  65093. export class VertexBuffer {
  65094. /** @hidden */
  65095. _buffer: Buffer;
  65096. private _kind;
  65097. private _size;
  65098. private _ownsBuffer;
  65099. private _instanced;
  65100. private _instanceDivisor;
  65101. /**
  65102. * The byte type.
  65103. */
  65104. static readonly BYTE: number;
  65105. /**
  65106. * The unsigned byte type.
  65107. */
  65108. static readonly UNSIGNED_BYTE: number;
  65109. /**
  65110. * The short type.
  65111. */
  65112. static readonly SHORT: number;
  65113. /**
  65114. * The unsigned short type.
  65115. */
  65116. static readonly UNSIGNED_SHORT: number;
  65117. /**
  65118. * The integer type.
  65119. */
  65120. static readonly INT: number;
  65121. /**
  65122. * The unsigned integer type.
  65123. */
  65124. static readonly UNSIGNED_INT: number;
  65125. /**
  65126. * The float type.
  65127. */
  65128. static readonly FLOAT: number;
  65129. /**
  65130. * Gets or sets the instance divisor when in instanced mode
  65131. */
  65132. instanceDivisor: number;
  65133. /**
  65134. * Gets the byte stride.
  65135. */
  65136. readonly byteStride: number;
  65137. /**
  65138. * Gets the byte offset.
  65139. */
  65140. readonly byteOffset: number;
  65141. /**
  65142. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  65143. */
  65144. readonly normalized: boolean;
  65145. /**
  65146. * Gets the data type of each component in the array.
  65147. */
  65148. readonly type: number;
  65149. /**
  65150. * Constructor
  65151. * @param engine the engine
  65152. * @param data the data to use for this vertex buffer
  65153. * @param kind the vertex buffer kind
  65154. * @param updatable whether the data is updatable
  65155. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  65156. * @param stride the stride (optional)
  65157. * @param instanced whether the buffer is instanced (optional)
  65158. * @param offset the offset of the data (optional)
  65159. * @param size the number of components (optional)
  65160. * @param type the type of the component (optional)
  65161. * @param normalized whether the data contains normalized data (optional)
  65162. * @param useBytes set to true if stride and offset are in bytes (optional)
  65163. */
  65164. 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);
  65165. /** @hidden */
  65166. _rebuild(): void;
  65167. /**
  65168. * Returns the kind of the VertexBuffer (string)
  65169. * @returns a string
  65170. */
  65171. getKind(): string;
  65172. /**
  65173. * Gets a boolean indicating if the VertexBuffer is updatable?
  65174. * @returns true if the buffer is updatable
  65175. */
  65176. isUpdatable(): boolean;
  65177. /**
  65178. * Gets current buffer's data
  65179. * @returns a DataArray or null
  65180. */
  65181. getData(): Nullable<DataArray>;
  65182. /**
  65183. * Gets underlying native buffer
  65184. * @returns underlying native buffer
  65185. */
  65186. getBuffer(): Nullable<WebGLBuffer>;
  65187. /**
  65188. * Gets the stride in float32 units (i.e. byte stride / 4).
  65189. * May not be an integer if the byte stride is not divisible by 4.
  65190. * DEPRECATED. Use byteStride instead.
  65191. * @returns the stride in float32 units
  65192. */
  65193. getStrideSize(): number;
  65194. /**
  65195. * Returns the offset as a multiple of the type byte length.
  65196. * DEPRECATED. Use byteOffset instead.
  65197. * @returns the offset in bytes
  65198. */
  65199. getOffset(): number;
  65200. /**
  65201. * Returns the number of components per vertex attribute (integer)
  65202. * @returns the size in float
  65203. */
  65204. getSize(): number;
  65205. /**
  65206. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  65207. * @returns true if this buffer is instanced
  65208. */
  65209. getIsInstanced(): boolean;
  65210. /**
  65211. * Returns the instancing divisor, zero for non-instanced (integer).
  65212. * @returns a number
  65213. */
  65214. getInstanceDivisor(): number;
  65215. /**
  65216. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  65217. * @param data defines the data to store
  65218. */
  65219. create(data?: DataArray): void;
  65220. /**
  65221. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  65222. * This function will create a new buffer if the current one is not updatable
  65223. * @param data defines the data to store
  65224. */
  65225. update(data: DataArray): void;
  65226. /**
  65227. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  65228. * Returns the directly updated WebGLBuffer.
  65229. * @param data the new data
  65230. * @param offset the new offset
  65231. * @param useBytes set to true if the offset is in bytes
  65232. */
  65233. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  65234. /**
  65235. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  65236. */
  65237. dispose(): void;
  65238. /**
  65239. * Enumerates each value of this vertex buffer as numbers.
  65240. * @param count the number of values to enumerate
  65241. * @param callback the callback function called for each value
  65242. */
  65243. forEach(count: number, callback: (value: number, index: number) => void): void;
  65244. /**
  65245. * Positions
  65246. */
  65247. static readonly PositionKind: string;
  65248. /**
  65249. * Normals
  65250. */
  65251. static readonly NormalKind: string;
  65252. /**
  65253. * Tangents
  65254. */
  65255. static readonly TangentKind: string;
  65256. /**
  65257. * Texture coordinates
  65258. */
  65259. static readonly UVKind: string;
  65260. /**
  65261. * Texture coordinates 2
  65262. */
  65263. static readonly UV2Kind: string;
  65264. /**
  65265. * Texture coordinates 3
  65266. */
  65267. static readonly UV3Kind: string;
  65268. /**
  65269. * Texture coordinates 4
  65270. */
  65271. static readonly UV4Kind: string;
  65272. /**
  65273. * Texture coordinates 5
  65274. */
  65275. static readonly UV5Kind: string;
  65276. /**
  65277. * Texture coordinates 6
  65278. */
  65279. static readonly UV6Kind: string;
  65280. /**
  65281. * Colors
  65282. */
  65283. static readonly ColorKind: string;
  65284. /**
  65285. * Matrix indices (for bones)
  65286. */
  65287. static readonly MatricesIndicesKind: string;
  65288. /**
  65289. * Matrix weights (for bones)
  65290. */
  65291. static readonly MatricesWeightsKind: string;
  65292. /**
  65293. * Additional matrix indices (for bones)
  65294. */
  65295. static readonly MatricesIndicesExtraKind: string;
  65296. /**
  65297. * Additional matrix weights (for bones)
  65298. */
  65299. static readonly MatricesWeightsExtraKind: string;
  65300. /**
  65301. * Deduces the stride given a kind.
  65302. * @param kind The kind string to deduce
  65303. * @returns The deduced stride
  65304. */
  65305. static DeduceStride(kind: string): number;
  65306. /**
  65307. * Gets the byte length of the given type.
  65308. * @param type the type
  65309. * @returns the number of bytes
  65310. */
  65311. static GetTypeByteLength(type: number): number;
  65312. /**
  65313. * Enumerates each value of the given parameters as numbers.
  65314. * @param data the data to enumerate
  65315. * @param byteOffset the byte offset of the data
  65316. * @param byteStride the byte stride of the data
  65317. * @param componentCount the number of components per element
  65318. * @param componentType the type of the component
  65319. * @param count the total number of components
  65320. * @param normalized whether the data is normalized
  65321. * @param callback the callback function called for each value
  65322. */
  65323. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  65324. private static _GetFloatValue;
  65325. }
  65326. }
  65327. declare module BABYLON {
  65328. /**
  65329. * Class representing spherical polynomial coefficients to the 3rd degree
  65330. */
  65331. export class SphericalPolynomial {
  65332. /**
  65333. * The x coefficients of the spherical polynomial
  65334. */
  65335. x: Vector3;
  65336. /**
  65337. * The y coefficients of the spherical polynomial
  65338. */
  65339. y: Vector3;
  65340. /**
  65341. * The z coefficients of the spherical polynomial
  65342. */
  65343. z: Vector3;
  65344. /**
  65345. * The xx coefficients of the spherical polynomial
  65346. */
  65347. xx: Vector3;
  65348. /**
  65349. * The yy coefficients of the spherical polynomial
  65350. */
  65351. yy: Vector3;
  65352. /**
  65353. * The zz coefficients of the spherical polynomial
  65354. */
  65355. zz: Vector3;
  65356. /**
  65357. * The xy coefficients of the spherical polynomial
  65358. */
  65359. xy: Vector3;
  65360. /**
  65361. * The yz coefficients of the spherical polynomial
  65362. */
  65363. yz: Vector3;
  65364. /**
  65365. * The zx coefficients of the spherical polynomial
  65366. */
  65367. zx: Vector3;
  65368. /**
  65369. * Adds an ambient color to the spherical polynomial
  65370. * @param color the color to add
  65371. */
  65372. addAmbient(color: Color3): void;
  65373. /**
  65374. * Scales the spherical polynomial by the given amount
  65375. * @param scale the amount to scale
  65376. */
  65377. scale(scale: number): void;
  65378. /**
  65379. * Gets the spherical polynomial from harmonics
  65380. * @param harmonics the spherical harmonics
  65381. * @returns the spherical polynomial
  65382. */
  65383. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  65384. /**
  65385. * Constructs a spherical polynomial from an array.
  65386. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  65387. * @returns the spherical polynomial
  65388. */
  65389. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  65390. }
  65391. /**
  65392. * Class representing spherical harmonics coefficients to the 3rd degree
  65393. */
  65394. export class SphericalHarmonics {
  65395. /**
  65396. * The l0,0 coefficients of the spherical harmonics
  65397. */
  65398. l00: Vector3;
  65399. /**
  65400. * The l1,-1 coefficients of the spherical harmonics
  65401. */
  65402. l1_1: Vector3;
  65403. /**
  65404. * The l1,0 coefficients of the spherical harmonics
  65405. */
  65406. l10: Vector3;
  65407. /**
  65408. * The l1,1 coefficients of the spherical harmonics
  65409. */
  65410. l11: Vector3;
  65411. /**
  65412. * The l2,-2 coefficients of the spherical harmonics
  65413. */
  65414. l2_2: Vector3;
  65415. /**
  65416. * The l2,-1 coefficients of the spherical harmonics
  65417. */
  65418. l2_1: Vector3;
  65419. /**
  65420. * The l2,0 coefficients of the spherical harmonics
  65421. */
  65422. l20: Vector3;
  65423. /**
  65424. * The l2,1 coefficients of the spherical harmonics
  65425. */
  65426. l21: Vector3;
  65427. /**
  65428. * The l2,2 coefficients of the spherical harmonics
  65429. */
  65430. lL22: Vector3;
  65431. /**
  65432. * Adds a light to the spherical harmonics
  65433. * @param direction the direction of the light
  65434. * @param color the color of the light
  65435. * @param deltaSolidAngle the delta solid angle of the light
  65436. */
  65437. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  65438. /**
  65439. * Scales the spherical harmonics by the given amount
  65440. * @param scale the amount to scale
  65441. */
  65442. scale(scale: number): void;
  65443. /**
  65444. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  65445. *
  65446. * ```
  65447. * E_lm = A_l * L_lm
  65448. * ```
  65449. *
  65450. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  65451. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  65452. * the scaling factors are given in equation 9.
  65453. */
  65454. convertIncidentRadianceToIrradiance(): void;
  65455. /**
  65456. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  65457. *
  65458. * ```
  65459. * L = (1/pi) * E * rho
  65460. * ```
  65461. *
  65462. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  65463. */
  65464. convertIrradianceToLambertianRadiance(): void;
  65465. /**
  65466. * Gets the spherical harmonics from polynomial
  65467. * @param polynomial the spherical polynomial
  65468. * @returns the spherical harmonics
  65469. */
  65470. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  65471. /**
  65472. * Constructs a spherical harmonics from an array.
  65473. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  65474. * @returns the spherical harmonics
  65475. */
  65476. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  65477. }
  65478. }
  65479. declare module BABYLON {
  65480. /**
  65481. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  65482. */
  65483. export interface CubeMapInfo {
  65484. /**
  65485. * The pixel array for the front face.
  65486. * This is stored in format, left to right, up to down format.
  65487. */
  65488. front: Nullable<ArrayBufferView>;
  65489. /**
  65490. * The pixel array for the back face.
  65491. * This is stored in format, left to right, up to down format.
  65492. */
  65493. back: Nullable<ArrayBufferView>;
  65494. /**
  65495. * The pixel array for the left face.
  65496. * This is stored in format, left to right, up to down format.
  65497. */
  65498. left: Nullable<ArrayBufferView>;
  65499. /**
  65500. * The pixel array for the right face.
  65501. * This is stored in format, left to right, up to down format.
  65502. */
  65503. right: Nullable<ArrayBufferView>;
  65504. /**
  65505. * The pixel array for the up face.
  65506. * This is stored in format, left to right, up to down format.
  65507. */
  65508. up: Nullable<ArrayBufferView>;
  65509. /**
  65510. * The pixel array for the down face.
  65511. * This is stored in format, left to right, up to down format.
  65512. */
  65513. down: Nullable<ArrayBufferView>;
  65514. /**
  65515. * The size of the cubemap stored.
  65516. *
  65517. * Each faces will be size * size pixels.
  65518. */
  65519. size: number;
  65520. /**
  65521. * The format of the texture.
  65522. *
  65523. * RGBA, RGB.
  65524. */
  65525. format: number;
  65526. /**
  65527. * The type of the texture data.
  65528. *
  65529. * UNSIGNED_INT, FLOAT.
  65530. */
  65531. type: number;
  65532. /**
  65533. * Specifies whether the texture is in gamma space.
  65534. */
  65535. gammaSpace: boolean;
  65536. }
  65537. /**
  65538. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  65539. */
  65540. export class PanoramaToCubeMapTools {
  65541. private static FACE_FRONT;
  65542. private static FACE_BACK;
  65543. private static FACE_RIGHT;
  65544. private static FACE_LEFT;
  65545. private static FACE_DOWN;
  65546. private static FACE_UP;
  65547. /**
  65548. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  65549. *
  65550. * @param float32Array The source data.
  65551. * @param inputWidth The width of the input panorama.
  65552. * @param inputHeight The height of the input panorama.
  65553. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  65554. * @return The cubemap data
  65555. */
  65556. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  65557. private static CreateCubemapTexture;
  65558. private static CalcProjectionSpherical;
  65559. }
  65560. }
  65561. declare module BABYLON {
  65562. /**
  65563. * Helper class dealing with the extraction of spherical polynomial dataArray
  65564. * from a cube map.
  65565. */
  65566. export class CubeMapToSphericalPolynomialTools {
  65567. private static FileFaces;
  65568. /**
  65569. * Converts a texture to the according Spherical Polynomial data.
  65570. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65571. *
  65572. * @param texture The texture to extract the information from.
  65573. * @return The Spherical Polynomial data.
  65574. */
  65575. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): SphericalPolynomial | null;
  65576. /**
  65577. * Converts a cubemap to the according Spherical Polynomial data.
  65578. * This extracts the first 3 orders only as they are the only one used in the lighting.
  65579. *
  65580. * @param cubeInfo The Cube map to extract the information from.
  65581. * @return The Spherical Polynomial data.
  65582. */
  65583. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  65584. }
  65585. }
  65586. declare module BABYLON {
  65587. /**
  65588. * The engine store class is responsible to hold all the instances of Engine and Scene created
  65589. * during the life time of the application.
  65590. */
  65591. export class EngineStore {
  65592. /** Gets the list of created engines */
  65593. static Instances: Engine[];
  65594. /**
  65595. * Gets the latest created engine
  65596. */
  65597. static readonly LastCreatedEngine: Nullable<Engine>;
  65598. /**
  65599. * Gets the latest created scene
  65600. */
  65601. static readonly LastCreatedScene: Nullable<Scene>;
  65602. }
  65603. }
  65604. declare module BABYLON {
  65605. /**
  65606. * Define options used to create a render target texture
  65607. */
  65608. export class RenderTargetCreationOptions {
  65609. /**
  65610. * Specifies is mipmaps must be generated
  65611. */
  65612. generateMipMaps?: boolean;
  65613. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  65614. generateDepthBuffer?: boolean;
  65615. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  65616. generateStencilBuffer?: boolean;
  65617. /** Defines texture type (int by default) */
  65618. type?: number;
  65619. /** Defines sampling mode (trilinear by default) */
  65620. samplingMode?: number;
  65621. /** Defines format (RGBA by default) */
  65622. format?: number;
  65623. }
  65624. }
  65625. declare module BABYLON {
  65626. /**
  65627. * @hidden
  65628. **/
  65629. export class _AlphaState {
  65630. private _isAlphaBlendDirty;
  65631. private _isBlendFunctionParametersDirty;
  65632. private _isBlendEquationParametersDirty;
  65633. private _isBlendConstantsDirty;
  65634. private _alphaBlend;
  65635. private _blendFunctionParameters;
  65636. private _blendEquationParameters;
  65637. private _blendConstants;
  65638. /**
  65639. * Initializes the state.
  65640. */
  65641. constructor();
  65642. readonly isDirty: boolean;
  65643. alphaBlend: boolean;
  65644. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  65645. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  65646. setAlphaEquationParameters(rgb: number, alpha: number): void;
  65647. reset(): void;
  65648. apply(gl: WebGLRenderingContext): void;
  65649. }
  65650. }
  65651. declare module BABYLON {
  65652. /**
  65653. * @hidden
  65654. **/
  65655. export class _DepthCullingState {
  65656. private _isDepthTestDirty;
  65657. private _isDepthMaskDirty;
  65658. private _isDepthFuncDirty;
  65659. private _isCullFaceDirty;
  65660. private _isCullDirty;
  65661. private _isZOffsetDirty;
  65662. private _isFrontFaceDirty;
  65663. private _depthTest;
  65664. private _depthMask;
  65665. private _depthFunc;
  65666. private _cull;
  65667. private _cullFace;
  65668. private _zOffset;
  65669. private _frontFace;
  65670. /**
  65671. * Initializes the state.
  65672. */
  65673. constructor();
  65674. readonly isDirty: boolean;
  65675. zOffset: number;
  65676. cullFace: Nullable<number>;
  65677. cull: Nullable<boolean>;
  65678. depthFunc: Nullable<number>;
  65679. depthMask: boolean;
  65680. depthTest: boolean;
  65681. frontFace: Nullable<number>;
  65682. reset(): void;
  65683. apply(gl: WebGLRenderingContext): void;
  65684. }
  65685. }
  65686. declare module BABYLON {
  65687. /**
  65688. * @hidden
  65689. **/
  65690. export class _StencilState {
  65691. /** 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 */
  65692. static readonly ALWAYS: number;
  65693. /** Passed to stencilOperation to specify that stencil value must be kept */
  65694. static readonly KEEP: number;
  65695. /** Passed to stencilOperation to specify that stencil value must be replaced */
  65696. static readonly REPLACE: number;
  65697. private _isStencilTestDirty;
  65698. private _isStencilMaskDirty;
  65699. private _isStencilFuncDirty;
  65700. private _isStencilOpDirty;
  65701. private _stencilTest;
  65702. private _stencilMask;
  65703. private _stencilFunc;
  65704. private _stencilFuncRef;
  65705. private _stencilFuncMask;
  65706. private _stencilOpStencilFail;
  65707. private _stencilOpDepthFail;
  65708. private _stencilOpStencilDepthPass;
  65709. readonly isDirty: boolean;
  65710. stencilFunc: number;
  65711. stencilFuncRef: number;
  65712. stencilFuncMask: number;
  65713. stencilOpStencilFail: number;
  65714. stencilOpDepthFail: number;
  65715. stencilOpStencilDepthPass: number;
  65716. stencilMask: number;
  65717. stencilTest: boolean;
  65718. constructor();
  65719. reset(): void;
  65720. apply(gl: WebGLRenderingContext): void;
  65721. }
  65722. }
  65723. declare module BABYLON {
  65724. /**
  65725. * @hidden
  65726. **/
  65727. export class _TimeToken {
  65728. _startTimeQuery: Nullable<WebGLQuery>;
  65729. _endTimeQuery: Nullable<WebGLQuery>;
  65730. _timeElapsedQuery: Nullable<WebGLQuery>;
  65731. _timeElapsedQueryEnded: boolean;
  65732. }
  65733. }
  65734. declare module BABYLON {
  65735. /**
  65736. * Class used to store data associated with WebGL texture data for the engine
  65737. * This class should not be used directly
  65738. */
  65739. export class InternalTexture {
  65740. /** hidden */
  65741. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: SphericalPolynomial | null, lodScale: number, lodOffset: number) => Promise<void>;
  65742. /**
  65743. * The source of the texture data is unknown
  65744. */
  65745. static DATASOURCE_UNKNOWN: number;
  65746. /**
  65747. * Texture data comes from an URL
  65748. */
  65749. static DATASOURCE_URL: number;
  65750. /**
  65751. * Texture data is only used for temporary storage
  65752. */
  65753. static DATASOURCE_TEMP: number;
  65754. /**
  65755. * Texture data comes from raw data (ArrayBuffer)
  65756. */
  65757. static DATASOURCE_RAW: number;
  65758. /**
  65759. * Texture content is dynamic (video or dynamic texture)
  65760. */
  65761. static DATASOURCE_DYNAMIC: number;
  65762. /**
  65763. * Texture content is generated by rendering to it
  65764. */
  65765. static DATASOURCE_RENDERTARGET: number;
  65766. /**
  65767. * Texture content is part of a multi render target process
  65768. */
  65769. static DATASOURCE_MULTIRENDERTARGET: number;
  65770. /**
  65771. * Texture data comes from a cube data file
  65772. */
  65773. static DATASOURCE_CUBE: number;
  65774. /**
  65775. * Texture data comes from a raw cube data
  65776. */
  65777. static DATASOURCE_CUBERAW: number;
  65778. /**
  65779. * Texture data come from a prefiltered cube data file
  65780. */
  65781. static DATASOURCE_CUBEPREFILTERED: number;
  65782. /**
  65783. * Texture content is raw 3D data
  65784. */
  65785. static DATASOURCE_RAW3D: number;
  65786. /**
  65787. * Texture content is a depth texture
  65788. */
  65789. static DATASOURCE_DEPTHTEXTURE: number;
  65790. /**
  65791. * Texture data comes from a raw cube data encoded with RGBD
  65792. */
  65793. static DATASOURCE_CUBERAW_RGBD: number;
  65794. /**
  65795. * Defines if the texture is ready
  65796. */
  65797. isReady: boolean;
  65798. /**
  65799. * Defines if the texture is a cube texture
  65800. */
  65801. isCube: boolean;
  65802. /**
  65803. * Defines if the texture contains 3D data
  65804. */
  65805. is3D: boolean;
  65806. /**
  65807. * Defines if the texture contains multiview data
  65808. */
  65809. isMultiview: boolean;
  65810. /**
  65811. * Gets the URL used to load this texture
  65812. */
  65813. url: string;
  65814. /**
  65815. * Gets the sampling mode of the texture
  65816. */
  65817. samplingMode: number;
  65818. /**
  65819. * Gets a boolean indicating if the texture needs mipmaps generation
  65820. */
  65821. generateMipMaps: boolean;
  65822. /**
  65823. * Gets the number of samples used by the texture (WebGL2+ only)
  65824. */
  65825. samples: number;
  65826. /**
  65827. * Gets the type of the texture (int, float...)
  65828. */
  65829. type: number;
  65830. /**
  65831. * Gets the format of the texture (RGB, RGBA...)
  65832. */
  65833. format: number;
  65834. /**
  65835. * Observable called when the texture is loaded
  65836. */
  65837. onLoadedObservable: Observable<InternalTexture>;
  65838. /**
  65839. * Gets the width of the texture
  65840. */
  65841. width: number;
  65842. /**
  65843. * Gets the height of the texture
  65844. */
  65845. height: number;
  65846. /**
  65847. * Gets the depth of the texture
  65848. */
  65849. depth: number;
  65850. /**
  65851. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  65852. */
  65853. baseWidth: number;
  65854. /**
  65855. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  65856. */
  65857. baseHeight: number;
  65858. /**
  65859. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  65860. */
  65861. baseDepth: number;
  65862. /**
  65863. * Gets a boolean indicating if the texture is inverted on Y axis
  65864. */
  65865. invertY: boolean;
  65866. /** @hidden */
  65867. _invertVScale: boolean;
  65868. /** @hidden */
  65869. _associatedChannel: number;
  65870. /** @hidden */
  65871. _dataSource: number;
  65872. /** @hidden */
  65873. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  65874. /** @hidden */
  65875. _bufferView: Nullable<ArrayBufferView>;
  65876. /** @hidden */
  65877. _bufferViewArray: Nullable<ArrayBufferView[]>;
  65878. /** @hidden */
  65879. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  65880. /** @hidden */
  65881. _size: number;
  65882. /** @hidden */
  65883. _extension: string;
  65884. /** @hidden */
  65885. _files: Nullable<string[]>;
  65886. /** @hidden */
  65887. _workingCanvas: Nullable<HTMLCanvasElement>;
  65888. /** @hidden */
  65889. _workingContext: Nullable<CanvasRenderingContext2D>;
  65890. /** @hidden */
  65891. _framebuffer: Nullable<WebGLFramebuffer>;
  65892. /** @hidden */
  65893. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  65894. /** @hidden */
  65895. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  65896. /** @hidden */
  65897. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  65898. /** @hidden */
  65899. _attachments: Nullable<number[]>;
  65900. /** @hidden */
  65901. _cachedCoordinatesMode: Nullable<number>;
  65902. /** @hidden */
  65903. _cachedWrapU: Nullable<number>;
  65904. /** @hidden */
  65905. _cachedWrapV: Nullable<number>;
  65906. /** @hidden */
  65907. _cachedWrapR: Nullable<number>;
  65908. /** @hidden */
  65909. _cachedAnisotropicFilteringLevel: Nullable<number>;
  65910. /** @hidden */
  65911. _isDisabled: boolean;
  65912. /** @hidden */
  65913. _compression: Nullable<string>;
  65914. /** @hidden */
  65915. _generateStencilBuffer: boolean;
  65916. /** @hidden */
  65917. _generateDepthBuffer: boolean;
  65918. /** @hidden */
  65919. _comparisonFunction: number;
  65920. /** @hidden */
  65921. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  65922. /** @hidden */
  65923. _lodGenerationScale: number;
  65924. /** @hidden */
  65925. _lodGenerationOffset: number;
  65926. /** @hidden */
  65927. _colorTextureArray: Nullable<WebGLTexture>;
  65928. /** @hidden */
  65929. _depthStencilTextureArray: Nullable<WebGLTexture>;
  65930. /** @hidden */
  65931. _lodTextureHigh: Nullable<BaseTexture>;
  65932. /** @hidden */
  65933. _lodTextureMid: Nullable<BaseTexture>;
  65934. /** @hidden */
  65935. _lodTextureLow: Nullable<BaseTexture>;
  65936. /** @hidden */
  65937. _isRGBD: boolean;
  65938. /** @hidden */
  65939. _webGLTexture: Nullable<WebGLTexture>;
  65940. /** @hidden */
  65941. _references: number;
  65942. private _engine;
  65943. /**
  65944. * Gets the Engine the texture belongs to.
  65945. * @returns The babylon engine
  65946. */
  65947. getEngine(): Engine;
  65948. /**
  65949. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  65950. */
  65951. readonly dataSource: number;
  65952. /**
  65953. * Creates a new InternalTexture
  65954. * @param engine defines the engine to use
  65955. * @param dataSource defines the type of data that will be used
  65956. * @param delayAllocation if the texture allocation should be delayed (default: false)
  65957. */
  65958. constructor(engine: Engine, dataSource: number, delayAllocation?: boolean);
  65959. /**
  65960. * Increments the number of references (ie. the number of Texture that point to it)
  65961. */
  65962. incrementReferences(): void;
  65963. /**
  65964. * Change the size of the texture (not the size of the content)
  65965. * @param width defines the new width
  65966. * @param height defines the new height
  65967. * @param depth defines the new depth (1 by default)
  65968. */
  65969. updateSize(width: int, height: int, depth?: int): void;
  65970. /** @hidden */
  65971. _rebuild(): void;
  65972. /** @hidden */
  65973. _swapAndDie(target: InternalTexture): void;
  65974. /**
  65975. * Dispose the current allocated resources
  65976. */
  65977. dispose(): void;
  65978. }
  65979. }
  65980. declare module BABYLON {
  65981. /**
  65982. * This represents the main contract an easing function should follow.
  65983. * Easing functions are used throughout the animation system.
  65984. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  65985. */
  65986. export interface IEasingFunction {
  65987. /**
  65988. * Given an input gradient between 0 and 1, this returns the corrseponding value
  65989. * of the easing function.
  65990. * The link below provides some of the most common examples of easing functions.
  65991. * @see https://easings.net/
  65992. * @param gradient Defines the value between 0 and 1 we want the easing value for
  65993. * @returns the corresponding value on the curve defined by the easing function
  65994. */
  65995. ease(gradient: number): number;
  65996. }
  65997. /**
  65998. * Base class used for every default easing function.
  65999. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66000. */
  66001. export class EasingFunction implements IEasingFunction {
  66002. /**
  66003. * Interpolation follows the mathematical formula associated with the easing function.
  66004. */
  66005. static readonly EASINGMODE_EASEIN: number;
  66006. /**
  66007. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  66008. */
  66009. static readonly EASINGMODE_EASEOUT: number;
  66010. /**
  66011. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  66012. */
  66013. static readonly EASINGMODE_EASEINOUT: number;
  66014. private _easingMode;
  66015. /**
  66016. * Sets the easing mode of the current function.
  66017. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  66018. */
  66019. setEasingMode(easingMode: number): void;
  66020. /**
  66021. * Gets the current easing mode.
  66022. * @returns the easing mode
  66023. */
  66024. getEasingMode(): number;
  66025. /**
  66026. * @hidden
  66027. */
  66028. easeInCore(gradient: number): number;
  66029. /**
  66030. * Given an input gradient between 0 and 1, this returns the corrseponding value
  66031. * of the easing function.
  66032. * @param gradient Defines the value between 0 and 1 we want the easing value for
  66033. * @returns the corresponding value on the curve defined by the easing function
  66034. */
  66035. ease(gradient: number): number;
  66036. }
  66037. /**
  66038. * Easing function with a circle shape (see link below).
  66039. * @see https://easings.net/#easeInCirc
  66040. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66041. */
  66042. export class CircleEase extends EasingFunction implements IEasingFunction {
  66043. /** @hidden */
  66044. easeInCore(gradient: number): number;
  66045. }
  66046. /**
  66047. * Easing function with a ease back shape (see link below).
  66048. * @see https://easings.net/#easeInBack
  66049. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66050. */
  66051. export class BackEase extends EasingFunction implements IEasingFunction {
  66052. /** Defines the amplitude of the function */
  66053. amplitude: number;
  66054. /**
  66055. * Instantiates a back ease easing
  66056. * @see https://easings.net/#easeInBack
  66057. * @param amplitude Defines the amplitude of the function
  66058. */
  66059. constructor(
  66060. /** Defines the amplitude of the function */
  66061. amplitude?: number);
  66062. /** @hidden */
  66063. easeInCore(gradient: number): number;
  66064. }
  66065. /**
  66066. * Easing function with a bouncing shape (see link below).
  66067. * @see https://easings.net/#easeInBounce
  66068. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66069. */
  66070. export class BounceEase extends EasingFunction implements IEasingFunction {
  66071. /** Defines the number of bounces */
  66072. bounces: number;
  66073. /** Defines the amplitude of the bounce */
  66074. bounciness: number;
  66075. /**
  66076. * Instantiates a bounce easing
  66077. * @see https://easings.net/#easeInBounce
  66078. * @param bounces Defines the number of bounces
  66079. * @param bounciness Defines the amplitude of the bounce
  66080. */
  66081. constructor(
  66082. /** Defines the number of bounces */
  66083. bounces?: number,
  66084. /** Defines the amplitude of the bounce */
  66085. bounciness?: number);
  66086. /** @hidden */
  66087. easeInCore(gradient: number): number;
  66088. }
  66089. /**
  66090. * Easing function with a power of 3 shape (see link below).
  66091. * @see https://easings.net/#easeInCubic
  66092. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66093. */
  66094. export class CubicEase extends EasingFunction implements IEasingFunction {
  66095. /** @hidden */
  66096. easeInCore(gradient: number): number;
  66097. }
  66098. /**
  66099. * Easing function with an elastic shape (see link below).
  66100. * @see https://easings.net/#easeInElastic
  66101. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66102. */
  66103. export class ElasticEase extends EasingFunction implements IEasingFunction {
  66104. /** Defines the number of oscillations*/
  66105. oscillations: number;
  66106. /** Defines the amplitude of the oscillations*/
  66107. springiness: number;
  66108. /**
  66109. * Instantiates an elastic easing function
  66110. * @see https://easings.net/#easeInElastic
  66111. * @param oscillations Defines the number of oscillations
  66112. * @param springiness Defines the amplitude of the oscillations
  66113. */
  66114. constructor(
  66115. /** Defines the number of oscillations*/
  66116. oscillations?: number,
  66117. /** Defines the amplitude of the oscillations*/
  66118. springiness?: number);
  66119. /** @hidden */
  66120. easeInCore(gradient: number): number;
  66121. }
  66122. /**
  66123. * Easing function with an exponential shape (see link below).
  66124. * @see https://easings.net/#easeInExpo
  66125. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66126. */
  66127. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  66128. /** Defines the exponent of the function */
  66129. exponent: number;
  66130. /**
  66131. * Instantiates an exponential easing function
  66132. * @see https://easings.net/#easeInExpo
  66133. * @param exponent Defines the exponent of the function
  66134. */
  66135. constructor(
  66136. /** Defines the exponent of the function */
  66137. exponent?: number);
  66138. /** @hidden */
  66139. easeInCore(gradient: number): number;
  66140. }
  66141. /**
  66142. * Easing function with a power shape (see link below).
  66143. * @see https://easings.net/#easeInQuad
  66144. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66145. */
  66146. export class PowerEase extends EasingFunction implements IEasingFunction {
  66147. /** Defines the power of the function */
  66148. power: number;
  66149. /**
  66150. * Instantiates an power base easing function
  66151. * @see https://easings.net/#easeInQuad
  66152. * @param power Defines the power of the function
  66153. */
  66154. constructor(
  66155. /** Defines the power of the function */
  66156. power?: number);
  66157. /** @hidden */
  66158. easeInCore(gradient: number): number;
  66159. }
  66160. /**
  66161. * Easing function with a power of 2 shape (see link below).
  66162. * @see https://easings.net/#easeInQuad
  66163. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66164. */
  66165. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  66166. /** @hidden */
  66167. easeInCore(gradient: number): number;
  66168. }
  66169. /**
  66170. * Easing function with a power of 4 shape (see link below).
  66171. * @see https://easings.net/#easeInQuart
  66172. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66173. */
  66174. export class QuarticEase extends EasingFunction implements IEasingFunction {
  66175. /** @hidden */
  66176. easeInCore(gradient: number): number;
  66177. }
  66178. /**
  66179. * Easing function with a power of 5 shape (see link below).
  66180. * @see https://easings.net/#easeInQuint
  66181. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66182. */
  66183. export class QuinticEase extends EasingFunction implements IEasingFunction {
  66184. /** @hidden */
  66185. easeInCore(gradient: number): number;
  66186. }
  66187. /**
  66188. * Easing function with a sin shape (see link below).
  66189. * @see https://easings.net/#easeInSine
  66190. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66191. */
  66192. export class SineEase extends EasingFunction implements IEasingFunction {
  66193. /** @hidden */
  66194. easeInCore(gradient: number): number;
  66195. }
  66196. /**
  66197. * Easing function with a bezier shape (see link below).
  66198. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66199. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  66200. */
  66201. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  66202. /** Defines the x component of the start tangent in the bezier curve */
  66203. x1: number;
  66204. /** Defines the y component of the start tangent in the bezier curve */
  66205. y1: number;
  66206. /** Defines the x component of the end tangent in the bezier curve */
  66207. x2: number;
  66208. /** Defines the y component of the end tangent in the bezier curve */
  66209. y2: number;
  66210. /**
  66211. * Instantiates a bezier function
  66212. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  66213. * @param x1 Defines the x component of the start tangent in the bezier curve
  66214. * @param y1 Defines the y component of the start tangent in the bezier curve
  66215. * @param x2 Defines the x component of the end tangent in the bezier curve
  66216. * @param y2 Defines the y component of the end tangent in the bezier curve
  66217. */
  66218. constructor(
  66219. /** Defines the x component of the start tangent in the bezier curve */
  66220. x1?: number,
  66221. /** Defines the y component of the start tangent in the bezier curve */
  66222. y1?: number,
  66223. /** Defines the x component of the end tangent in the bezier curve */
  66224. x2?: number,
  66225. /** Defines the y component of the end tangent in the bezier curve */
  66226. y2?: number);
  66227. /** @hidden */
  66228. easeInCore(gradient: number): number;
  66229. }
  66230. }
  66231. declare module BABYLON {
  66232. /**
  66233. * Defines an interface which represents an animation key frame
  66234. */
  66235. export interface IAnimationKey {
  66236. /**
  66237. * Frame of the key frame
  66238. */
  66239. frame: number;
  66240. /**
  66241. * Value at the specifies key frame
  66242. */
  66243. value: any;
  66244. /**
  66245. * The input tangent for the cubic hermite spline
  66246. */
  66247. inTangent?: any;
  66248. /**
  66249. * The output tangent for the cubic hermite spline
  66250. */
  66251. outTangent?: any;
  66252. /**
  66253. * The animation interpolation type
  66254. */
  66255. interpolation?: AnimationKeyInterpolation;
  66256. }
  66257. /**
  66258. * Enum for the animation key frame interpolation type
  66259. */
  66260. export enum AnimationKeyInterpolation {
  66261. /**
  66262. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  66263. */
  66264. STEP = 1
  66265. }
  66266. }
  66267. declare module BABYLON {
  66268. /**
  66269. * Represents the range of an animation
  66270. */
  66271. export class AnimationRange {
  66272. /**The name of the animation range**/
  66273. name: string;
  66274. /**The starting frame of the animation */
  66275. from: number;
  66276. /**The ending frame of the animation*/
  66277. to: number;
  66278. /**
  66279. * Initializes the range of an animation
  66280. * @param name The name of the animation range
  66281. * @param from The starting frame of the animation
  66282. * @param to The ending frame of the animation
  66283. */
  66284. constructor(
  66285. /**The name of the animation range**/
  66286. name: string,
  66287. /**The starting frame of the animation */
  66288. from: number,
  66289. /**The ending frame of the animation*/
  66290. to: number);
  66291. /**
  66292. * Makes a copy of the animation range
  66293. * @returns A copy of the animation range
  66294. */
  66295. clone(): AnimationRange;
  66296. }
  66297. }
  66298. declare module BABYLON {
  66299. /**
  66300. * Composed of a frame, and an action function
  66301. */
  66302. export class AnimationEvent {
  66303. /** The frame for which the event is triggered **/
  66304. frame: number;
  66305. /** The event to perform when triggered **/
  66306. action: (currentFrame: number) => void;
  66307. /** Specifies if the event should be triggered only once**/
  66308. onlyOnce?: boolean | undefined;
  66309. /**
  66310. * Specifies if the animation event is done
  66311. */
  66312. isDone: boolean;
  66313. /**
  66314. * Initializes the animation event
  66315. * @param frame The frame for which the event is triggered
  66316. * @param action The event to perform when triggered
  66317. * @param onlyOnce Specifies if the event should be triggered only once
  66318. */
  66319. constructor(
  66320. /** The frame for which the event is triggered **/
  66321. frame: number,
  66322. /** The event to perform when triggered **/
  66323. action: (currentFrame: number) => void,
  66324. /** Specifies if the event should be triggered only once**/
  66325. onlyOnce?: boolean | undefined);
  66326. /** @hidden */
  66327. _clone(): AnimationEvent;
  66328. }
  66329. }
  66330. declare module BABYLON {
  66331. /**
  66332. * Interface used to define a behavior
  66333. */
  66334. export interface Behavior<T> {
  66335. /** gets or sets behavior's name */
  66336. name: string;
  66337. /**
  66338. * Function called when the behavior needs to be initialized (after attaching it to a target)
  66339. */
  66340. init(): void;
  66341. /**
  66342. * Called when the behavior is attached to a target
  66343. * @param target defines the target where the behavior is attached to
  66344. */
  66345. attach(target: T): void;
  66346. /**
  66347. * Called when the behavior is detached from its target
  66348. */
  66349. detach(): void;
  66350. }
  66351. /**
  66352. * Interface implemented by classes supporting behaviors
  66353. */
  66354. export interface IBehaviorAware<T> {
  66355. /**
  66356. * Attach a behavior
  66357. * @param behavior defines the behavior to attach
  66358. * @returns the current host
  66359. */
  66360. addBehavior(behavior: Behavior<T>): T;
  66361. /**
  66362. * Remove a behavior from the current object
  66363. * @param behavior defines the behavior to detach
  66364. * @returns the current host
  66365. */
  66366. removeBehavior(behavior: Behavior<T>): T;
  66367. /**
  66368. * Gets a behavior using its name to search
  66369. * @param name defines the name to search
  66370. * @returns the behavior or null if not found
  66371. */
  66372. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  66373. }
  66374. }
  66375. declare module BABYLON {
  66376. /**
  66377. * @hidden
  66378. */
  66379. export class IntersectionInfo {
  66380. bu: Nullable<number>;
  66381. bv: Nullable<number>;
  66382. distance: number;
  66383. faceId: number;
  66384. subMeshId: number;
  66385. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  66386. }
  66387. }
  66388. declare module BABYLON {
  66389. /**
  66390. * Class used to store bounding sphere information
  66391. */
  66392. export class BoundingSphere {
  66393. /**
  66394. * Gets the center of the bounding sphere in local space
  66395. */
  66396. readonly center: Vector3;
  66397. /**
  66398. * Radius of the bounding sphere in local space
  66399. */
  66400. radius: number;
  66401. /**
  66402. * Gets the center of the bounding sphere in world space
  66403. */
  66404. readonly centerWorld: Vector3;
  66405. /**
  66406. * Radius of the bounding sphere in world space
  66407. */
  66408. radiusWorld: number;
  66409. /**
  66410. * Gets the minimum vector in local space
  66411. */
  66412. readonly minimum: Vector3;
  66413. /**
  66414. * Gets the maximum vector in local space
  66415. */
  66416. readonly maximum: Vector3;
  66417. private _worldMatrix;
  66418. private static readonly TmpVector3;
  66419. /**
  66420. * Creates a new bounding sphere
  66421. * @param min defines the minimum vector (in local space)
  66422. * @param max defines the maximum vector (in local space)
  66423. * @param worldMatrix defines the new world matrix
  66424. */
  66425. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66426. /**
  66427. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  66428. * @param min defines the new minimum vector (in local space)
  66429. * @param max defines the new maximum vector (in local space)
  66430. * @param worldMatrix defines the new world matrix
  66431. */
  66432. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66433. /**
  66434. * Scale the current bounding sphere by applying a scale factor
  66435. * @param factor defines the scale factor to apply
  66436. * @returns the current bounding box
  66437. */
  66438. scale(factor: number): BoundingSphere;
  66439. /**
  66440. * Gets the world matrix of the bounding box
  66441. * @returns a matrix
  66442. */
  66443. getWorldMatrix(): DeepImmutable<Matrix>;
  66444. /** @hidden */
  66445. _update(worldMatrix: DeepImmutable<Matrix>): void;
  66446. /**
  66447. * Tests if the bounding sphere is intersecting the frustum planes
  66448. * @param frustumPlanes defines the frustum planes to test
  66449. * @returns true if there is an intersection
  66450. */
  66451. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66452. /**
  66453. * Tests if the bounding sphere center is in between the frustum planes.
  66454. * Used for optimistic fast inclusion.
  66455. * @param frustumPlanes defines the frustum planes to test
  66456. * @returns true if the sphere center is in between the frustum planes
  66457. */
  66458. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66459. /**
  66460. * Tests if a point is inside the bounding sphere
  66461. * @param point defines the point to test
  66462. * @returns true if the point is inside the bounding sphere
  66463. */
  66464. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66465. /**
  66466. * Checks if two sphere intersct
  66467. * @param sphere0 sphere 0
  66468. * @param sphere1 sphere 1
  66469. * @returns true if the speres intersect
  66470. */
  66471. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  66472. }
  66473. }
  66474. declare module BABYLON {
  66475. /**
  66476. * Class used to store bounding box information
  66477. */
  66478. export class BoundingBox implements ICullable {
  66479. /**
  66480. * Gets the 8 vectors representing the bounding box in local space
  66481. */
  66482. readonly vectors: Vector3[];
  66483. /**
  66484. * Gets the center of the bounding box in local space
  66485. */
  66486. readonly center: Vector3;
  66487. /**
  66488. * Gets the center of the bounding box in world space
  66489. */
  66490. readonly centerWorld: Vector3;
  66491. /**
  66492. * Gets the extend size in local space
  66493. */
  66494. readonly extendSize: Vector3;
  66495. /**
  66496. * Gets the extend size in world space
  66497. */
  66498. readonly extendSizeWorld: Vector3;
  66499. /**
  66500. * Gets the OBB (object bounding box) directions
  66501. */
  66502. readonly directions: Vector3[];
  66503. /**
  66504. * Gets the 8 vectors representing the bounding box in world space
  66505. */
  66506. readonly vectorsWorld: Vector3[];
  66507. /**
  66508. * Gets the minimum vector in world space
  66509. */
  66510. readonly minimumWorld: Vector3;
  66511. /**
  66512. * Gets the maximum vector in world space
  66513. */
  66514. readonly maximumWorld: Vector3;
  66515. /**
  66516. * Gets the minimum vector in local space
  66517. */
  66518. readonly minimum: Vector3;
  66519. /**
  66520. * Gets the maximum vector in local space
  66521. */
  66522. readonly maximum: Vector3;
  66523. private _worldMatrix;
  66524. private static readonly TmpVector3;
  66525. /**
  66526. * @hidden
  66527. */
  66528. _tag: number;
  66529. /**
  66530. * Creates a new bounding box
  66531. * @param min defines the minimum vector (in local space)
  66532. * @param max defines the maximum vector (in local space)
  66533. * @param worldMatrix defines the new world matrix
  66534. */
  66535. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66536. /**
  66537. * Recreates the entire bounding box from scratch as if we call the constructor in place
  66538. * @param min defines the new minimum vector (in local space)
  66539. * @param max defines the new maximum vector (in local space)
  66540. * @param worldMatrix defines the new world matrix
  66541. */
  66542. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66543. /**
  66544. * Scale the current bounding box by applying a scale factor
  66545. * @param factor defines the scale factor to apply
  66546. * @returns the current bounding box
  66547. */
  66548. scale(factor: number): BoundingBox;
  66549. /**
  66550. * Gets the world matrix of the bounding box
  66551. * @returns a matrix
  66552. */
  66553. getWorldMatrix(): DeepImmutable<Matrix>;
  66554. /** @hidden */
  66555. _update(world: DeepImmutable<Matrix>): void;
  66556. /**
  66557. * Tests if the bounding box is intersecting the frustum planes
  66558. * @param frustumPlanes defines the frustum planes to test
  66559. * @returns true if there is an intersection
  66560. */
  66561. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66562. /**
  66563. * Tests if the bounding box is entirely inside the frustum planes
  66564. * @param frustumPlanes defines the frustum planes to test
  66565. * @returns true if there is an inclusion
  66566. */
  66567. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66568. /**
  66569. * Tests if a point is inside the bounding box
  66570. * @param point defines the point to test
  66571. * @returns true if the point is inside the bounding box
  66572. */
  66573. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66574. /**
  66575. * Tests if the bounding box intersects with a bounding sphere
  66576. * @param sphere defines the sphere to test
  66577. * @returns true if there is an intersection
  66578. */
  66579. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  66580. /**
  66581. * Tests if the bounding box intersects with a box defined by a min and max vectors
  66582. * @param min defines the min vector to use
  66583. * @param max defines the max vector to use
  66584. * @returns true if there is an intersection
  66585. */
  66586. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  66587. /**
  66588. * Tests if two bounding boxes are intersections
  66589. * @param box0 defines the first box to test
  66590. * @param box1 defines the second box to test
  66591. * @returns true if there is an intersection
  66592. */
  66593. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  66594. /**
  66595. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  66596. * @param minPoint defines the minimum vector of the bounding box
  66597. * @param maxPoint defines the maximum vector of the bounding box
  66598. * @param sphereCenter defines the sphere center
  66599. * @param sphereRadius defines the sphere radius
  66600. * @returns true if there is an intersection
  66601. */
  66602. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  66603. /**
  66604. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  66605. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66606. * @param frustumPlanes defines the frustum planes to test
  66607. * @return true if there is an inclusion
  66608. */
  66609. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66610. /**
  66611. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  66612. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  66613. * @param frustumPlanes defines the frustum planes to test
  66614. * @return true if there is an intersection
  66615. */
  66616. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66617. }
  66618. }
  66619. declare module BABYLON {
  66620. /** @hidden */
  66621. export class Collider {
  66622. /** Define if a collision was found */
  66623. collisionFound: boolean;
  66624. /**
  66625. * Define last intersection point in local space
  66626. */
  66627. intersectionPoint: Vector3;
  66628. /**
  66629. * Define last collided mesh
  66630. */
  66631. collidedMesh: Nullable<AbstractMesh>;
  66632. private _collisionPoint;
  66633. private _planeIntersectionPoint;
  66634. private _tempVector;
  66635. private _tempVector2;
  66636. private _tempVector3;
  66637. private _tempVector4;
  66638. private _edge;
  66639. private _baseToVertex;
  66640. private _destinationPoint;
  66641. private _slidePlaneNormal;
  66642. private _displacementVector;
  66643. /** @hidden */
  66644. _radius: Vector3;
  66645. /** @hidden */
  66646. _retry: number;
  66647. private _velocity;
  66648. private _basePoint;
  66649. private _epsilon;
  66650. /** @hidden */
  66651. _velocityWorldLength: number;
  66652. /** @hidden */
  66653. _basePointWorld: Vector3;
  66654. private _velocityWorld;
  66655. private _normalizedVelocity;
  66656. /** @hidden */
  66657. _initialVelocity: Vector3;
  66658. /** @hidden */
  66659. _initialPosition: Vector3;
  66660. private _nearestDistance;
  66661. private _collisionMask;
  66662. collisionMask: number;
  66663. /**
  66664. * Gets the plane normal used to compute the sliding response (in local space)
  66665. */
  66666. readonly slidePlaneNormal: Vector3;
  66667. /** @hidden */
  66668. _initialize(source: Vector3, dir: Vector3, e: number): void;
  66669. /** @hidden */
  66670. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  66671. /** @hidden */
  66672. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  66673. /** @hidden */
  66674. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean): void;
  66675. /** @hidden */
  66676. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean): void;
  66677. /** @hidden */
  66678. _getResponse(pos: Vector3, vel: Vector3): void;
  66679. }
  66680. }
  66681. declare module BABYLON {
  66682. /**
  66683. * Interface for cullable objects
  66684. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  66685. */
  66686. export interface ICullable {
  66687. /**
  66688. * Checks if the object or part of the object is in the frustum
  66689. * @param frustumPlanes Camera near/planes
  66690. * @returns true if the object is in frustum otherwise false
  66691. */
  66692. isInFrustum(frustumPlanes: Plane[]): boolean;
  66693. /**
  66694. * Checks if a cullable object (mesh...) is in the camera frustum
  66695. * Unlike isInFrustum this cheks the full bounding box
  66696. * @param frustumPlanes Camera near/planes
  66697. * @returns true if the object is in frustum otherwise false
  66698. */
  66699. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  66700. }
  66701. /**
  66702. * Info for a bounding data of a mesh
  66703. */
  66704. export class BoundingInfo implements ICullable {
  66705. /**
  66706. * Bounding box for the mesh
  66707. */
  66708. readonly boundingBox: BoundingBox;
  66709. /**
  66710. * Bounding sphere for the mesh
  66711. */
  66712. readonly boundingSphere: BoundingSphere;
  66713. private _isLocked;
  66714. private static readonly TmpVector3;
  66715. /**
  66716. * Constructs bounding info
  66717. * @param minimum min vector of the bounding box/sphere
  66718. * @param maximum max vector of the bounding box/sphere
  66719. * @param worldMatrix defines the new world matrix
  66720. */
  66721. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  66722. /**
  66723. * Recreates the entire bounding info from scratch as if we call the constructor in place
  66724. * @param min defines the new minimum vector (in local space)
  66725. * @param max defines the new maximum vector (in local space)
  66726. * @param worldMatrix defines the new world matrix
  66727. */
  66728. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  66729. /**
  66730. * min vector of the bounding box/sphere
  66731. */
  66732. readonly minimum: Vector3;
  66733. /**
  66734. * max vector of the bounding box/sphere
  66735. */
  66736. readonly maximum: Vector3;
  66737. /**
  66738. * If the info is locked and won't be updated to avoid perf overhead
  66739. */
  66740. isLocked: boolean;
  66741. /**
  66742. * Updates the bounding sphere and box
  66743. * @param world world matrix to be used to update
  66744. */
  66745. update(world: DeepImmutable<Matrix>): void;
  66746. /**
  66747. * Recreate the bounding info to be centered around a specific point given a specific extend.
  66748. * @param center New center of the bounding info
  66749. * @param extend New extend of the bounding info
  66750. * @returns the current bounding info
  66751. */
  66752. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  66753. /**
  66754. * Scale the current bounding info by applying a scale factor
  66755. * @param factor defines the scale factor to apply
  66756. * @returns the current bounding info
  66757. */
  66758. scale(factor: number): BoundingInfo;
  66759. /**
  66760. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  66761. * @param frustumPlanes defines the frustum to test
  66762. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  66763. * @returns true if the bounding info is in the frustum planes
  66764. */
  66765. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  66766. /**
  66767. * Gets the world distance between the min and max points of the bounding box
  66768. */
  66769. readonly diagonalLength: number;
  66770. /**
  66771. * Checks if a cullable object (mesh...) is in the camera frustum
  66772. * Unlike isInFrustum this cheks the full bounding box
  66773. * @param frustumPlanes Camera near/planes
  66774. * @returns true if the object is in frustum otherwise false
  66775. */
  66776. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  66777. /** @hidden */
  66778. _checkCollision(collider: Collider): boolean;
  66779. /**
  66780. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  66781. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66782. * @param point the point to check intersection with
  66783. * @returns if the point intersects
  66784. */
  66785. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  66786. /**
  66787. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  66788. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  66789. * @param boundingInfo the bounding info to check intersection with
  66790. * @param precise if the intersection should be done using OBB
  66791. * @returns if the bounding info intersects
  66792. */
  66793. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  66794. }
  66795. }
  66796. declare module BABYLON {
  66797. /**
  66798. * Defines an array and its length.
  66799. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  66800. */
  66801. export interface ISmartArrayLike<T> {
  66802. /**
  66803. * The data of the array.
  66804. */
  66805. data: Array<T>;
  66806. /**
  66807. * The active length of the array.
  66808. */
  66809. length: number;
  66810. }
  66811. /**
  66812. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66813. */
  66814. export class SmartArray<T> implements ISmartArrayLike<T> {
  66815. /**
  66816. * The full set of data from the array.
  66817. */
  66818. data: Array<T>;
  66819. /**
  66820. * The active length of the array.
  66821. */
  66822. length: number;
  66823. protected _id: number;
  66824. /**
  66825. * Instantiates a Smart Array.
  66826. * @param capacity defines the default capacity of the array.
  66827. */
  66828. constructor(capacity: number);
  66829. /**
  66830. * Pushes a value at the end of the active data.
  66831. * @param value defines the object to push in the array.
  66832. */
  66833. push(value: T): void;
  66834. /**
  66835. * Iterates over the active data and apply the lambda to them.
  66836. * @param func defines the action to apply on each value.
  66837. */
  66838. forEach(func: (content: T) => void): void;
  66839. /**
  66840. * Sorts the full sets of data.
  66841. * @param compareFn defines the comparison function to apply.
  66842. */
  66843. sort(compareFn: (a: T, b: T) => number): void;
  66844. /**
  66845. * Resets the active data to an empty array.
  66846. */
  66847. reset(): void;
  66848. /**
  66849. * Releases all the data from the array as well as the array.
  66850. */
  66851. dispose(): void;
  66852. /**
  66853. * Concats the active data with a given array.
  66854. * @param array defines the data to concatenate with.
  66855. */
  66856. concat(array: any): void;
  66857. /**
  66858. * Returns the position of a value in the active data.
  66859. * @param value defines the value to find the index for
  66860. * @returns the index if found in the active data otherwise -1
  66861. */
  66862. indexOf(value: T): number;
  66863. /**
  66864. * Returns whether an element is part of the active data.
  66865. * @param value defines the value to look for
  66866. * @returns true if found in the active data otherwise false
  66867. */
  66868. contains(value: T): boolean;
  66869. private static _GlobalId;
  66870. }
  66871. /**
  66872. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  66873. * The data in this array can only be present once
  66874. */
  66875. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  66876. private _duplicateId;
  66877. /**
  66878. * Pushes a value at the end of the active data.
  66879. * THIS DOES NOT PREVENT DUPPLICATE DATA
  66880. * @param value defines the object to push in the array.
  66881. */
  66882. push(value: T): void;
  66883. /**
  66884. * Pushes a value at the end of the active data.
  66885. * If the data is already present, it won t be added again
  66886. * @param value defines the object to push in the array.
  66887. * @returns true if added false if it was already present
  66888. */
  66889. pushNoDuplicate(value: T): boolean;
  66890. /**
  66891. * Resets the active data to an empty array.
  66892. */
  66893. reset(): void;
  66894. /**
  66895. * Concats the active data with a given array.
  66896. * This ensures no dupplicate will be present in the result.
  66897. * @param array defines the data to concatenate with.
  66898. */
  66899. concatWithNoDuplicate(array: any): void;
  66900. }
  66901. }
  66902. declare module BABYLON {
  66903. /**
  66904. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66905. * separate meshes. This can be use to improve performances.
  66906. * @see http://doc.babylonjs.com/how_to/multi_materials
  66907. */
  66908. export class MultiMaterial extends Material {
  66909. private _subMaterials;
  66910. /**
  66911. * Gets or Sets the list of Materials used within the multi material.
  66912. * They need to be ordered according to the submeshes order in the associated mesh
  66913. */
  66914. subMaterials: Nullable<Material>[];
  66915. /**
  66916. * Function used to align with Node.getChildren()
  66917. * @returns the list of Materials used within the multi material
  66918. */
  66919. getChildren(): Nullable<Material>[];
  66920. /**
  66921. * Instantiates a new Multi Material
  66922. * A multi-material is used to apply different materials to different parts of the same object without the need of
  66923. * separate meshes. This can be use to improve performances.
  66924. * @see http://doc.babylonjs.com/how_to/multi_materials
  66925. * @param name Define the name in the scene
  66926. * @param scene Define the scene the material belongs to
  66927. */
  66928. constructor(name: string, scene: Scene);
  66929. private _hookArray;
  66930. /**
  66931. * Get one of the submaterial by its index in the submaterials array
  66932. * @param index The index to look the sub material at
  66933. * @returns The Material if the index has been defined
  66934. */
  66935. getSubMaterial(index: number): Nullable<Material>;
  66936. /**
  66937. * Get the list of active textures for the whole sub materials list.
  66938. * @returns All the textures that will be used during the rendering
  66939. */
  66940. getActiveTextures(): BaseTexture[];
  66941. /**
  66942. * Gets the current class name of the material e.g. "MultiMaterial"
  66943. * Mainly use in serialization.
  66944. * @returns the class name
  66945. */
  66946. getClassName(): string;
  66947. /**
  66948. * Checks if the material is ready to render the requested sub mesh
  66949. * @param mesh Define the mesh the submesh belongs to
  66950. * @param subMesh Define the sub mesh to look readyness for
  66951. * @param useInstances Define whether or not the material is used with instances
  66952. * @returns true if ready, otherwise false
  66953. */
  66954. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  66955. /**
  66956. * Clones the current material and its related sub materials
  66957. * @param name Define the name of the newly cloned material
  66958. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  66959. * @returns the cloned material
  66960. */
  66961. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  66962. /**
  66963. * Serializes the materials into a JSON representation.
  66964. * @returns the JSON representation
  66965. */
  66966. serialize(): any;
  66967. /**
  66968. * Dispose the material and release its associated resources
  66969. * @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)
  66970. * @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)
  66971. * @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)
  66972. */
  66973. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  66974. /**
  66975. * Creates a MultiMaterial from parsed MultiMaterial data.
  66976. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  66977. * @param scene defines the hosting scene
  66978. * @returns a new MultiMaterial
  66979. */
  66980. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  66981. }
  66982. }
  66983. declare module BABYLON {
  66984. /**
  66985. * Class used to represent data loading progression
  66986. */
  66987. export class SceneLoaderFlags {
  66988. private static _ForceFullSceneLoadingForIncremental;
  66989. private static _ShowLoadingScreen;
  66990. private static _CleanBoneMatrixWeights;
  66991. private static _loggingLevel;
  66992. /**
  66993. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  66994. */
  66995. static ForceFullSceneLoadingForIncremental: boolean;
  66996. /**
  66997. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  66998. */
  66999. static ShowLoadingScreen: boolean;
  67000. /**
  67001. * Defines the current logging level (while loading the scene)
  67002. * @ignorenaming
  67003. */
  67004. static loggingLevel: number;
  67005. /**
  67006. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  67007. */
  67008. static CleanBoneMatrixWeights: boolean;
  67009. }
  67010. }
  67011. declare module BABYLON {
  67012. /**
  67013. * 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.
  67014. * @see https://doc.babylonjs.com/how_to/transformnode
  67015. */
  67016. export class TransformNode extends Node {
  67017. /**
  67018. * Object will not rotate to face the camera
  67019. */
  67020. static BILLBOARDMODE_NONE: number;
  67021. /**
  67022. * Object will rotate to face the camera but only on the x axis
  67023. */
  67024. static BILLBOARDMODE_X: number;
  67025. /**
  67026. * Object will rotate to face the camera but only on the y axis
  67027. */
  67028. static BILLBOARDMODE_Y: number;
  67029. /**
  67030. * Object will rotate to face the camera but only on the z axis
  67031. */
  67032. static BILLBOARDMODE_Z: number;
  67033. /**
  67034. * Object will rotate to face the camera
  67035. */
  67036. static BILLBOARDMODE_ALL: number;
  67037. private _forward;
  67038. private _forwardInverted;
  67039. private _up;
  67040. private _right;
  67041. private _rightInverted;
  67042. private _position;
  67043. private _rotation;
  67044. private _rotationQuaternion;
  67045. protected _scaling: Vector3;
  67046. protected _isDirty: boolean;
  67047. private _transformToBoneReferal;
  67048. private _billboardMode;
  67049. /**
  67050. * Gets or sets the billboard mode. Default is 0.
  67051. *
  67052. * | Value | Type | Description |
  67053. * | --- | --- | --- |
  67054. * | 0 | BILLBOARDMODE_NONE | |
  67055. * | 1 | BILLBOARDMODE_X | |
  67056. * | 2 | BILLBOARDMODE_Y | |
  67057. * | 4 | BILLBOARDMODE_Z | |
  67058. * | 7 | BILLBOARDMODE_ALL | |
  67059. *
  67060. */
  67061. billboardMode: number;
  67062. private _preserveParentRotationForBillboard;
  67063. /**
  67064. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  67065. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  67066. */
  67067. preserveParentRotationForBillboard: boolean;
  67068. /**
  67069. * 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
  67070. */
  67071. scalingDeterminant: number;
  67072. private _infiniteDistance;
  67073. /**
  67074. * Gets or sets the distance of the object to max, often used by skybox
  67075. */
  67076. infiniteDistance: boolean;
  67077. /**
  67078. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  67079. * By default the system will update normals to compensate
  67080. */
  67081. ignoreNonUniformScaling: boolean;
  67082. /**
  67083. * Gets or sets a boolean indicating that even if rotationQuaternion is defined, you can keep updating rotation property and Babylon.js will just mix both
  67084. */
  67085. reIntegrateRotationIntoRotationQuaternion: boolean;
  67086. /** @hidden */
  67087. _poseMatrix: Nullable<Matrix>;
  67088. /** @hidden */
  67089. _localMatrix: Matrix;
  67090. private _usePivotMatrix;
  67091. private _absolutePosition;
  67092. private _pivotMatrix;
  67093. private _pivotMatrixInverse;
  67094. protected _postMultiplyPivotMatrix: boolean;
  67095. protected _isWorldMatrixFrozen: boolean;
  67096. /** @hidden */
  67097. _indexInSceneTransformNodesArray: number;
  67098. /**
  67099. * An event triggered after the world matrix is updated
  67100. */
  67101. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  67102. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  67103. /**
  67104. * Gets a string identifying the name of the class
  67105. * @returns "TransformNode" string
  67106. */
  67107. getClassName(): string;
  67108. /**
  67109. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  67110. */
  67111. position: Vector3;
  67112. /**
  67113. * 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)).
  67114. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  67115. */
  67116. rotation: Vector3;
  67117. /**
  67118. * 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)).
  67119. */
  67120. scaling: Vector3;
  67121. /**
  67122. * 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).
  67123. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  67124. */
  67125. rotationQuaternion: Nullable<Quaternion>;
  67126. /**
  67127. * The forward direction of that transform in world space.
  67128. */
  67129. readonly forward: Vector3;
  67130. /**
  67131. * The up direction of that transform in world space.
  67132. */
  67133. readonly up: Vector3;
  67134. /**
  67135. * The right direction of that transform in world space.
  67136. */
  67137. readonly right: Vector3;
  67138. /**
  67139. * Copies the parameter passed Matrix into the mesh Pose matrix.
  67140. * @param matrix the matrix to copy the pose from
  67141. * @returns this TransformNode.
  67142. */
  67143. updatePoseMatrix(matrix: Matrix): TransformNode;
  67144. /**
  67145. * Returns the mesh Pose matrix.
  67146. * @returns the pose matrix
  67147. */
  67148. getPoseMatrix(): Matrix;
  67149. /** @hidden */
  67150. _isSynchronized(): boolean;
  67151. /** @hidden */
  67152. _initCache(): void;
  67153. /**
  67154. * Flag the transform node as dirty (Forcing it to update everything)
  67155. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  67156. * @returns this transform node
  67157. */
  67158. markAsDirty(property: string): TransformNode;
  67159. /**
  67160. * Returns the current mesh absolute position.
  67161. * Returns a Vector3.
  67162. */
  67163. readonly absolutePosition: Vector3;
  67164. /**
  67165. * Sets a new matrix to apply before all other transformation
  67166. * @param matrix defines the transform matrix
  67167. * @returns the current TransformNode
  67168. */
  67169. setPreTransformMatrix(matrix: Matrix): TransformNode;
  67170. /**
  67171. * Sets a new pivot matrix to the current node
  67172. * @param matrix defines the new pivot matrix to use
  67173. * @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
  67174. * @returns the current TransformNode
  67175. */
  67176. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  67177. /**
  67178. * Returns the mesh pivot matrix.
  67179. * Default : Identity.
  67180. * @returns the matrix
  67181. */
  67182. getPivotMatrix(): Matrix;
  67183. /**
  67184. * Prevents the World matrix to be computed any longer.
  67185. * @returns the TransformNode.
  67186. */
  67187. freezeWorldMatrix(): TransformNode;
  67188. /**
  67189. * Allows back the World matrix computation.
  67190. * @returns the TransformNode.
  67191. */
  67192. unfreezeWorldMatrix(): this;
  67193. /**
  67194. * True if the World matrix has been frozen.
  67195. */
  67196. readonly isWorldMatrixFrozen: boolean;
  67197. /**
  67198. * Retuns the mesh absolute position in the World.
  67199. * @returns a Vector3.
  67200. */
  67201. getAbsolutePosition(): Vector3;
  67202. /**
  67203. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  67204. * @param absolutePosition the absolute position to set
  67205. * @returns the TransformNode.
  67206. */
  67207. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  67208. /**
  67209. * Sets the mesh position in its local space.
  67210. * @param vector3 the position to set in localspace
  67211. * @returns the TransformNode.
  67212. */
  67213. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  67214. /**
  67215. * Returns the mesh position in the local space from the current World matrix values.
  67216. * @returns a new Vector3.
  67217. */
  67218. getPositionExpressedInLocalSpace(): Vector3;
  67219. /**
  67220. * Translates the mesh along the passed Vector3 in its local space.
  67221. * @param vector3 the distance to translate in localspace
  67222. * @returns the TransformNode.
  67223. */
  67224. locallyTranslate(vector3: Vector3): TransformNode;
  67225. private static _lookAtVectorCache;
  67226. /**
  67227. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  67228. * @param targetPoint the position (must be in same space as current mesh) to look at
  67229. * @param yawCor optional yaw (y-axis) correction in radians
  67230. * @param pitchCor optional pitch (x-axis) correction in radians
  67231. * @param rollCor optional roll (z-axis) correction in radians
  67232. * @param space the choosen space of the target
  67233. * @returns the TransformNode.
  67234. */
  67235. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  67236. /**
  67237. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67238. * This Vector3 is expressed in the World space.
  67239. * @param localAxis axis to rotate
  67240. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  67241. */
  67242. getDirection(localAxis: Vector3): Vector3;
  67243. /**
  67244. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  67245. * localAxis is expressed in the mesh local space.
  67246. * result is computed in the Wordl space from the mesh World matrix.
  67247. * @param localAxis axis to rotate
  67248. * @param result the resulting transformnode
  67249. * @returns this TransformNode.
  67250. */
  67251. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  67252. /**
  67253. * Sets this transform node rotation to the given local axis.
  67254. * @param localAxis the axis in local space
  67255. * @param yawCor optional yaw (y-axis) correction in radians
  67256. * @param pitchCor optional pitch (x-axis) correction in radians
  67257. * @param rollCor optional roll (z-axis) correction in radians
  67258. * @returns this TransformNode
  67259. */
  67260. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  67261. /**
  67262. * Sets a new pivot point to the current node
  67263. * @param point defines the new pivot point to use
  67264. * @param space defines if the point is in world or local space (local by default)
  67265. * @returns the current TransformNode
  67266. */
  67267. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  67268. /**
  67269. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  67270. * @returns the pivot point
  67271. */
  67272. getPivotPoint(): Vector3;
  67273. /**
  67274. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  67275. * @param result the vector3 to store the result
  67276. * @returns this TransformNode.
  67277. */
  67278. getPivotPointToRef(result: Vector3): TransformNode;
  67279. /**
  67280. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  67281. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  67282. */
  67283. getAbsolutePivotPoint(): Vector3;
  67284. /**
  67285. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  67286. * @param result vector3 to store the result
  67287. * @returns this TransformNode.
  67288. */
  67289. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  67290. /**
  67291. * Defines the passed node as the parent of the current node.
  67292. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  67293. * @see https://doc.babylonjs.com/how_to/parenting
  67294. * @param node the node ot set as the parent
  67295. * @returns this TransformNode.
  67296. */
  67297. setParent(node: Nullable<Node>): TransformNode;
  67298. private _nonUniformScaling;
  67299. /**
  67300. * True if the scaling property of this object is non uniform eg. (1,2,1)
  67301. */
  67302. readonly nonUniformScaling: boolean;
  67303. /** @hidden */
  67304. _updateNonUniformScalingState(value: boolean): boolean;
  67305. /**
  67306. * Attach the current TransformNode to another TransformNode associated with a bone
  67307. * @param bone Bone affecting the TransformNode
  67308. * @param affectedTransformNode TransformNode associated with the bone
  67309. * @returns this object
  67310. */
  67311. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  67312. /**
  67313. * Detach the transform node if its associated with a bone
  67314. * @returns this object
  67315. */
  67316. detachFromBone(): TransformNode;
  67317. private static _rotationAxisCache;
  67318. /**
  67319. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  67320. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67321. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67322. * The passed axis is also normalized.
  67323. * @param axis the axis to rotate around
  67324. * @param amount the amount to rotate in radians
  67325. * @param space Space to rotate in (Default: local)
  67326. * @returns the TransformNode.
  67327. */
  67328. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  67329. /**
  67330. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  67331. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  67332. * The passed axis is also normalized. .
  67333. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  67334. * @param point the point to rotate around
  67335. * @param axis the axis to rotate around
  67336. * @param amount the amount to rotate in radians
  67337. * @returns the TransformNode
  67338. */
  67339. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  67340. /**
  67341. * Translates the mesh along the axis vector for the passed distance in the given space.
  67342. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  67343. * @param axis the axis to translate in
  67344. * @param distance the distance to translate
  67345. * @param space Space to rotate in (Default: local)
  67346. * @returns the TransformNode.
  67347. */
  67348. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  67349. /**
  67350. * Adds a rotation step to the mesh current rotation.
  67351. * x, y, z are Euler angles expressed in radians.
  67352. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  67353. * This means this rotation is made in the mesh local space only.
  67354. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  67355. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  67356. * ```javascript
  67357. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  67358. * ```
  67359. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  67360. * 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.
  67361. * @param x Rotation to add
  67362. * @param y Rotation to add
  67363. * @param z Rotation to add
  67364. * @returns the TransformNode.
  67365. */
  67366. addRotation(x: number, y: number, z: number): TransformNode;
  67367. /**
  67368. * @hidden
  67369. */
  67370. protected _getEffectiveParent(): Nullable<Node>;
  67371. /**
  67372. * Computes the world matrix of the node
  67373. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  67374. * @returns the world matrix
  67375. */
  67376. computeWorldMatrix(force?: boolean): Matrix;
  67377. protected _afterComputeWorldMatrix(): void;
  67378. /**
  67379. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  67380. * @param func callback function to add
  67381. *
  67382. * @returns the TransformNode.
  67383. */
  67384. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67385. /**
  67386. * Removes a registered callback function.
  67387. * @param func callback function to remove
  67388. * @returns the TransformNode.
  67389. */
  67390. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  67391. /**
  67392. * Gets the position of the current mesh in camera space
  67393. * @param camera defines the camera to use
  67394. * @returns a position
  67395. */
  67396. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  67397. /**
  67398. * Returns the distance from the mesh to the active camera
  67399. * @param camera defines the camera to use
  67400. * @returns the distance
  67401. */
  67402. getDistanceToCamera(camera?: Nullable<Camera>): number;
  67403. /**
  67404. * Clone the current transform node
  67405. * @param name Name of the new clone
  67406. * @param newParent New parent for the clone
  67407. * @param doNotCloneChildren Do not clone children hierarchy
  67408. * @returns the new transform node
  67409. */
  67410. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  67411. /**
  67412. * Serializes the objects information.
  67413. * @param currentSerializationObject defines the object to serialize in
  67414. * @returns the serialized object
  67415. */
  67416. serialize(currentSerializationObject?: any): any;
  67417. /**
  67418. * Returns a new TransformNode object parsed from the source provided.
  67419. * @param parsedTransformNode is the source.
  67420. * @param scene the scne the object belongs to
  67421. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  67422. * @returns a new TransformNode object parsed from the source provided.
  67423. */
  67424. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  67425. /**
  67426. * Get all child-transformNodes of this node
  67427. * @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
  67428. * @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
  67429. * @returns an array of TransformNode
  67430. */
  67431. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  67432. /**
  67433. * Releases resources associated with this transform node.
  67434. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  67435. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  67436. */
  67437. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  67438. }
  67439. }
  67440. declare module BABYLON {
  67441. /**
  67442. * Class used to override all child animations of a given target
  67443. */
  67444. export class AnimationPropertiesOverride {
  67445. /**
  67446. * Gets or sets a value indicating if animation blending must be used
  67447. */
  67448. enableBlending: boolean;
  67449. /**
  67450. * Gets or sets the blending speed to use when enableBlending is true
  67451. */
  67452. blendingSpeed: number;
  67453. /**
  67454. * Gets or sets the default loop mode to use
  67455. */
  67456. loopMode: number;
  67457. }
  67458. }
  67459. declare module BABYLON {
  67460. /**
  67461. * Class used to store bone information
  67462. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  67463. */
  67464. export class Bone extends Node {
  67465. /**
  67466. * defines the bone name
  67467. */
  67468. name: string;
  67469. private static _tmpVecs;
  67470. private static _tmpQuat;
  67471. private static _tmpMats;
  67472. /**
  67473. * Gets the list of child bones
  67474. */
  67475. children: Bone[];
  67476. /** Gets the animations associated with this bone */
  67477. animations: Animation[];
  67478. /**
  67479. * Gets or sets bone length
  67480. */
  67481. length: number;
  67482. /**
  67483. * @hidden Internal only
  67484. * Set this value to map this bone to a different index in the transform matrices
  67485. * Set this value to -1 to exclude the bone from the transform matrices
  67486. */
  67487. _index: Nullable<number>;
  67488. private _skeleton;
  67489. private _localMatrix;
  67490. private _restPose;
  67491. private _baseMatrix;
  67492. private _absoluteTransform;
  67493. private _invertedAbsoluteTransform;
  67494. private _parent;
  67495. private _scalingDeterminant;
  67496. private _worldTransform;
  67497. private _localScaling;
  67498. private _localRotation;
  67499. private _localPosition;
  67500. private _needToDecompose;
  67501. private _needToCompose;
  67502. /** @hidden */
  67503. _linkedTransformNode: Nullable<TransformNode>;
  67504. /** @hidden */
  67505. /** @hidden */
  67506. _matrix: Matrix;
  67507. /**
  67508. * Create a new bone
  67509. * @param name defines the bone name
  67510. * @param skeleton defines the parent skeleton
  67511. * @param parentBone defines the parent (can be null if the bone is the root)
  67512. * @param localMatrix defines the local matrix
  67513. * @param restPose defines the rest pose matrix
  67514. * @param baseMatrix defines the base matrix
  67515. * @param index defines index of the bone in the hiearchy
  67516. */
  67517. constructor(
  67518. /**
  67519. * defines the bone name
  67520. */
  67521. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  67522. /**
  67523. * Gets the current object class name.
  67524. * @return the class name
  67525. */
  67526. getClassName(): string;
  67527. /**
  67528. * Gets the parent skeleton
  67529. * @returns a skeleton
  67530. */
  67531. getSkeleton(): Skeleton;
  67532. /**
  67533. * Gets parent bone
  67534. * @returns a bone or null if the bone is the root of the bone hierarchy
  67535. */
  67536. getParent(): Nullable<Bone>;
  67537. /**
  67538. * Returns an array containing the root bones
  67539. * @returns an array containing the root bones
  67540. */
  67541. getChildren(): Array<Bone>;
  67542. /**
  67543. * Sets the parent bone
  67544. * @param parent defines the parent (can be null if the bone is the root)
  67545. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67546. */
  67547. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  67548. /**
  67549. * Gets the local matrix
  67550. * @returns a matrix
  67551. */
  67552. getLocalMatrix(): Matrix;
  67553. /**
  67554. * Gets the base matrix (initial matrix which remains unchanged)
  67555. * @returns a matrix
  67556. */
  67557. getBaseMatrix(): Matrix;
  67558. /**
  67559. * Gets the rest pose matrix
  67560. * @returns a matrix
  67561. */
  67562. getRestPose(): Matrix;
  67563. /**
  67564. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  67565. */
  67566. getWorldMatrix(): Matrix;
  67567. /**
  67568. * Sets the local matrix to rest pose matrix
  67569. */
  67570. returnToRest(): void;
  67571. /**
  67572. * Gets the inverse of the absolute transform matrix.
  67573. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  67574. * @returns a matrix
  67575. */
  67576. getInvertedAbsoluteTransform(): Matrix;
  67577. /**
  67578. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  67579. * @returns a matrix
  67580. */
  67581. getAbsoluteTransform(): Matrix;
  67582. /**
  67583. * Links with the given transform node.
  67584. * The local matrix of this bone is copied from the transform node every frame.
  67585. * @param transformNode defines the transform node to link to
  67586. */
  67587. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  67588. /** Gets or sets current position (in local space) */
  67589. position: Vector3;
  67590. /** Gets or sets current rotation (in local space) */
  67591. rotation: Vector3;
  67592. /** Gets or sets current rotation quaternion (in local space) */
  67593. rotationQuaternion: Quaternion;
  67594. /** Gets or sets current scaling (in local space) */
  67595. scaling: Vector3;
  67596. /**
  67597. * Gets the animation properties override
  67598. */
  67599. readonly animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  67600. private _decompose;
  67601. private _compose;
  67602. /**
  67603. * Update the base and local matrices
  67604. * @param matrix defines the new base or local matrix
  67605. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  67606. * @param updateLocalMatrix defines if the local matrix should be updated
  67607. */
  67608. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  67609. /** @hidden */
  67610. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  67611. /**
  67612. * Flag the bone as dirty (Forcing it to update everything)
  67613. */
  67614. markAsDirty(): void;
  67615. private _markAsDirtyAndCompose;
  67616. private _markAsDirtyAndDecompose;
  67617. /**
  67618. * Translate the bone in local or world space
  67619. * @param vec The amount to translate the bone
  67620. * @param space The space that the translation is in
  67621. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67622. */
  67623. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67624. /**
  67625. * Set the postion of the bone in local or world space
  67626. * @param position The position to set the bone
  67627. * @param space The space that the position is in
  67628. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67629. */
  67630. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67631. /**
  67632. * Set the absolute position of the bone (world space)
  67633. * @param position The position to set the bone
  67634. * @param mesh The mesh that this bone is attached to
  67635. */
  67636. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  67637. /**
  67638. * Scale the bone on the x, y and z axes (in local space)
  67639. * @param x The amount to scale the bone on the x axis
  67640. * @param y The amount to scale the bone on the y axis
  67641. * @param z The amount to scale the bone on the z axis
  67642. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  67643. */
  67644. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  67645. /**
  67646. * Set the bone scaling in local space
  67647. * @param scale defines the scaling vector
  67648. */
  67649. setScale(scale: Vector3): void;
  67650. /**
  67651. * Gets the current scaling in local space
  67652. * @returns the current scaling vector
  67653. */
  67654. getScale(): Vector3;
  67655. /**
  67656. * Gets the current scaling in local space and stores it in a target vector
  67657. * @param result defines the target vector
  67658. */
  67659. getScaleToRef(result: Vector3): void;
  67660. /**
  67661. * Set the yaw, pitch, and roll of the bone in local or world space
  67662. * @param yaw The rotation of the bone on the y axis
  67663. * @param pitch The rotation of the bone on the x axis
  67664. * @param roll The rotation of the bone on the z axis
  67665. * @param space The space that the axes of rotation are in
  67666. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67667. */
  67668. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  67669. /**
  67670. * Add a rotation to the bone on an axis in local or world space
  67671. * @param axis The axis to rotate the bone on
  67672. * @param amount The amount to rotate the bone
  67673. * @param space The space that the axis is in
  67674. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67675. */
  67676. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  67677. /**
  67678. * Set the rotation of the bone to a particular axis angle in local or world space
  67679. * @param axis The axis to rotate the bone on
  67680. * @param angle The angle that the bone should be rotated to
  67681. * @param space The space that the axis is in
  67682. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67683. */
  67684. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  67685. /**
  67686. * Set the euler rotation of the bone in local of world space
  67687. * @param rotation The euler rotation that the bone should be set to
  67688. * @param space The space that the rotation is in
  67689. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67690. */
  67691. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  67692. /**
  67693. * Set the quaternion rotation of the bone in local of world space
  67694. * @param quat The quaternion rotation that the bone should be set to
  67695. * @param space The space that the rotation is in
  67696. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67697. */
  67698. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  67699. /**
  67700. * Set the rotation matrix of the bone in local of world space
  67701. * @param rotMat The rotation matrix that the bone should be set to
  67702. * @param space The space that the rotation is in
  67703. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67704. */
  67705. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  67706. private _rotateWithMatrix;
  67707. private _getNegativeRotationToRef;
  67708. /**
  67709. * Get the position of the bone in local or world space
  67710. * @param space The space that the returned position is in
  67711. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67712. * @returns The position of the bone
  67713. */
  67714. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67715. /**
  67716. * Copy the position of the bone to a vector3 in local or world space
  67717. * @param space The space that the returned position is in
  67718. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67719. * @param result The vector3 to copy the position to
  67720. */
  67721. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  67722. /**
  67723. * Get the absolute position of the bone (world space)
  67724. * @param mesh The mesh that this bone is attached to
  67725. * @returns The absolute position of the bone
  67726. */
  67727. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  67728. /**
  67729. * Copy the absolute position of the bone (world space) to the result param
  67730. * @param mesh The mesh that this bone is attached to
  67731. * @param result The vector3 to copy the absolute position to
  67732. */
  67733. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  67734. /**
  67735. * Compute the absolute transforms of this bone and its children
  67736. */
  67737. computeAbsoluteTransforms(): void;
  67738. /**
  67739. * Get the world direction from an axis that is in the local space of the bone
  67740. * @param localAxis The local direction that is used to compute the world direction
  67741. * @param mesh The mesh that this bone is attached to
  67742. * @returns The world direction
  67743. */
  67744. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67745. /**
  67746. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  67747. * @param localAxis The local direction that is used to compute the world direction
  67748. * @param mesh The mesh that this bone is attached to
  67749. * @param result The vector3 that the world direction will be copied to
  67750. */
  67751. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67752. /**
  67753. * Get the euler rotation of the bone in local or world space
  67754. * @param space The space that the rotation should be in
  67755. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67756. * @returns The euler rotation
  67757. */
  67758. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  67759. /**
  67760. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  67761. * @param space The space that the rotation should be in
  67762. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67763. * @param result The vector3 that the rotation should be copied to
  67764. */
  67765. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67766. /**
  67767. * Get the quaternion rotation of the bone in either local or world space
  67768. * @param space The space that the rotation should be in
  67769. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67770. * @returns The quaternion rotation
  67771. */
  67772. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  67773. /**
  67774. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  67775. * @param space The space that the rotation should be in
  67776. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67777. * @param result The quaternion that the rotation should be copied to
  67778. */
  67779. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  67780. /**
  67781. * Get the rotation matrix of the bone in local or world space
  67782. * @param space The space that the rotation should be in
  67783. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67784. * @returns The rotation matrix
  67785. */
  67786. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  67787. /**
  67788. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  67789. * @param space The space that the rotation should be in
  67790. * @param mesh The mesh that this bone is attached to. This is only used in world space
  67791. * @param result The quaternion that the rotation should be copied to
  67792. */
  67793. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  67794. /**
  67795. * Get the world position of a point that is in the local space of the bone
  67796. * @param position The local position
  67797. * @param mesh The mesh that this bone is attached to
  67798. * @returns The world position
  67799. */
  67800. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67801. /**
  67802. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  67803. * @param position The local position
  67804. * @param mesh The mesh that this bone is attached to
  67805. * @param result The vector3 that the world position should be copied to
  67806. */
  67807. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67808. /**
  67809. * Get the local position of a point that is in world space
  67810. * @param position The world position
  67811. * @param mesh The mesh that this bone is attached to
  67812. * @returns The local position
  67813. */
  67814. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  67815. /**
  67816. * Get the local position of a point that is in world space and copy it to the result param
  67817. * @param position The world position
  67818. * @param mesh The mesh that this bone is attached to
  67819. * @param result The vector3 that the local position should be copied to
  67820. */
  67821. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  67822. }
  67823. }
  67824. declare module BABYLON {
  67825. /**
  67826. * Enum that determines the text-wrapping mode to use.
  67827. */
  67828. export enum InspectableType {
  67829. /**
  67830. * Checkbox for booleans
  67831. */
  67832. Checkbox = 0,
  67833. /**
  67834. * Sliders for numbers
  67835. */
  67836. Slider = 1,
  67837. /**
  67838. * Vector3
  67839. */
  67840. Vector3 = 2,
  67841. /**
  67842. * Quaternions
  67843. */
  67844. Quaternion = 3,
  67845. /**
  67846. * Color3
  67847. */
  67848. Color3 = 4
  67849. }
  67850. /**
  67851. * Interface used to define custom inspectable properties.
  67852. * This interface is used by the inspector to display custom property grids
  67853. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  67854. */
  67855. export interface IInspectable {
  67856. /**
  67857. * Gets the label to display
  67858. */
  67859. label: string;
  67860. /**
  67861. * Gets the name of the property to edit
  67862. */
  67863. propertyName: string;
  67864. /**
  67865. * Gets the type of the editor to use
  67866. */
  67867. type: InspectableType;
  67868. /**
  67869. * Gets the minimum value of the property when using in "slider" mode
  67870. */
  67871. min?: number;
  67872. /**
  67873. * Gets the maximum value of the property when using in "slider" mode
  67874. */
  67875. max?: number;
  67876. /**
  67877. * Gets the setp to use when using in "slider" mode
  67878. */
  67879. step?: number;
  67880. }
  67881. }
  67882. declare module BABYLON {
  67883. /**
  67884. * Class for creating a cube texture
  67885. */
  67886. export class CubeTexture extends BaseTexture {
  67887. private _delayedOnLoad;
  67888. /**
  67889. * The url of the texture
  67890. */
  67891. url: string;
  67892. /**
  67893. * Gets or sets the center of the bounding box associated with the cube texture.
  67894. * It must define where the camera used to render the texture was set
  67895. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67896. */
  67897. boundingBoxPosition: Vector3;
  67898. private _boundingBoxSize;
  67899. /**
  67900. * Gets or sets the size of the bounding box associated with the cube texture
  67901. * When defined, the cubemap will switch to local mode
  67902. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  67903. * @example https://www.babylonjs-playground.com/#RNASML
  67904. */
  67905. /**
  67906. * Returns the bounding box size
  67907. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  67908. */
  67909. boundingBoxSize: Vector3;
  67910. protected _rotationY: number;
  67911. /**
  67912. * Sets texture matrix rotation angle around Y axis in radians.
  67913. */
  67914. /**
  67915. * Gets texture matrix rotation angle around Y axis radians.
  67916. */
  67917. rotationY: number;
  67918. /**
  67919. * Are mip maps generated for this texture or not.
  67920. */
  67921. readonly noMipmap: boolean;
  67922. private _noMipmap;
  67923. private _files;
  67924. private _extensions;
  67925. private _textureMatrix;
  67926. private _format;
  67927. private _createPolynomials;
  67928. /** @hidden */
  67929. _prefiltered: boolean;
  67930. /**
  67931. * Creates a cube texture from an array of image urls
  67932. * @param files defines an array of image urls
  67933. * @param scene defines the hosting scene
  67934. * @param noMipmap specifies if mip maps are not used
  67935. * @returns a cube texture
  67936. */
  67937. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  67938. /**
  67939. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  67940. * @param url defines the url of the prefiltered texture
  67941. * @param scene defines the scene the texture is attached to
  67942. * @param forcedExtension defines the extension of the file if different from the url
  67943. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67944. * @return the prefiltered texture
  67945. */
  67946. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  67947. /**
  67948. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  67949. * as prefiltered data.
  67950. * @param rootUrl defines the url of the texture or the root name of the six images
  67951. * @param scene defines the scene the texture is attached to
  67952. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  67953. * @param noMipmap defines if mipmaps should be created or not
  67954. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  67955. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  67956. * @param onError defines a callback triggered in case of error during load
  67957. * @param format defines the internal format to use for the texture once loaded
  67958. * @param prefiltered defines whether or not the texture is created from prefiltered data
  67959. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  67960. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  67961. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  67962. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  67963. * @return the cube texture
  67964. */
  67965. 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);
  67966. /**
  67967. * Get the current class name of the texture useful for serialization or dynamic coding.
  67968. * @returns "CubeTexture"
  67969. */
  67970. getClassName(): string;
  67971. /**
  67972. * Update the url (and optional buffer) of this texture if url was null during construction.
  67973. * @param url the url of the texture
  67974. * @param forcedExtension defines the extension to use
  67975. * @param onLoad callback called when the texture is loaded (defaults to null)
  67976. */
  67977. updateURL(url: string, forcedExtension?: string, onLoad?: () => void): void;
  67978. /**
  67979. * Delays loading of the cube texture
  67980. * @param forcedExtension defines the extension to use
  67981. */
  67982. delayLoad(forcedExtension?: string): void;
  67983. /**
  67984. * Returns the reflection texture matrix
  67985. * @returns the reflection texture matrix
  67986. */
  67987. getReflectionTextureMatrix(): Matrix;
  67988. /**
  67989. * Sets the reflection texture matrix
  67990. * @param value Reflection texture matrix
  67991. */
  67992. setReflectionTextureMatrix(value: Matrix): void;
  67993. /**
  67994. * Parses text to create a cube texture
  67995. * @param parsedTexture define the serialized text to read from
  67996. * @param scene defines the hosting scene
  67997. * @param rootUrl defines the root url of the cube texture
  67998. * @returns a cube texture
  67999. */
  68000. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  68001. /**
  68002. * Makes a clone, or deep copy, of the cube texture
  68003. * @returns a new cube texture
  68004. */
  68005. clone(): CubeTexture;
  68006. }
  68007. }
  68008. declare module BABYLON {
  68009. /** @hidden */
  68010. export var postprocessVertexShader: {
  68011. name: string;
  68012. shader: string;
  68013. };
  68014. }
  68015. declare module BABYLON {
  68016. /**
  68017. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  68018. * This is the base of the follow, arc rotate cameras and Free camera
  68019. * @see http://doc.babylonjs.com/features/cameras
  68020. */
  68021. export class TargetCamera extends Camera {
  68022. private static _RigCamTransformMatrix;
  68023. private static _TargetTransformMatrix;
  68024. private static _TargetFocalPoint;
  68025. /**
  68026. * Define the current direction the camera is moving to
  68027. */
  68028. cameraDirection: Vector3;
  68029. /**
  68030. * Define the current rotation the camera is rotating to
  68031. */
  68032. cameraRotation: Vector2;
  68033. /**
  68034. * When set, the up vector of the camera will be updated by the rotation of the camera
  68035. */
  68036. updateUpVectorFromRotation: boolean;
  68037. private _tmpQuaternion;
  68038. /**
  68039. * Define the current rotation of the camera
  68040. */
  68041. rotation: Vector3;
  68042. /**
  68043. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  68044. */
  68045. rotationQuaternion: Quaternion;
  68046. /**
  68047. * Define the current speed of the camera
  68048. */
  68049. speed: number;
  68050. /**
  68051. * Add cconstraint to the camera to prevent it to move freely in all directions and
  68052. * around all axis.
  68053. */
  68054. noRotationConstraint: boolean;
  68055. /**
  68056. * Define the current target of the camera as an object or a position.
  68057. */
  68058. lockedTarget: any;
  68059. /** @hidden */
  68060. _currentTarget: Vector3;
  68061. /** @hidden */
  68062. _initialFocalDistance: number;
  68063. /** @hidden */
  68064. _viewMatrix: Matrix;
  68065. /** @hidden */
  68066. _camMatrix: Matrix;
  68067. /** @hidden */
  68068. _cameraTransformMatrix: Matrix;
  68069. /** @hidden */
  68070. _cameraRotationMatrix: Matrix;
  68071. /** @hidden */
  68072. _referencePoint: Vector3;
  68073. /** @hidden */
  68074. _transformedReferencePoint: Vector3;
  68075. protected _globalCurrentTarget: Vector3;
  68076. protected _globalCurrentUpVector: Vector3;
  68077. /** @hidden */
  68078. _reset: () => void;
  68079. private _defaultUp;
  68080. /**
  68081. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  68082. * This is the base of the follow, arc rotate cameras and Free camera
  68083. * @see http://doc.babylonjs.com/features/cameras
  68084. * @param name Defines the name of the camera in the scene
  68085. * @param position Defines the start position of the camera in the scene
  68086. * @param scene Defines the scene the camera belongs to
  68087. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  68088. */
  68089. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  68090. /**
  68091. * Gets the position in front of the camera at a given distance.
  68092. * @param distance The distance from the camera we want the position to be
  68093. * @returns the position
  68094. */
  68095. getFrontPosition(distance: number): Vector3;
  68096. /** @hidden */
  68097. _getLockedTargetPosition(): Nullable<Vector3>;
  68098. private _storedPosition;
  68099. private _storedRotation;
  68100. private _storedRotationQuaternion;
  68101. /**
  68102. * Store current camera state of the camera (fov, position, rotation, etc..)
  68103. * @returns the camera
  68104. */
  68105. storeState(): Camera;
  68106. /**
  68107. * Restored camera state. You must call storeState() first
  68108. * @returns whether it was successful or not
  68109. * @hidden
  68110. */
  68111. _restoreStateValues(): boolean;
  68112. /** @hidden */
  68113. _initCache(): void;
  68114. /** @hidden */
  68115. _updateCache(ignoreParentClass?: boolean): void;
  68116. /** @hidden */
  68117. _isSynchronizedViewMatrix(): boolean;
  68118. /** @hidden */
  68119. _computeLocalCameraSpeed(): number;
  68120. /**
  68121. * Defines the target the camera should look at.
  68122. * This will automatically adapt alpha beta and radius to fit within the new target.
  68123. * @param target Defines the new target as a Vector or a mesh
  68124. */
  68125. setTarget(target: Vector3): void;
  68126. /**
  68127. * Return the current target position of the camera. This value is expressed in local space.
  68128. * @returns the target position
  68129. */
  68130. getTarget(): Vector3;
  68131. /** @hidden */
  68132. _decideIfNeedsToMove(): boolean;
  68133. /** @hidden */
  68134. _updatePosition(): void;
  68135. /** @hidden */
  68136. _checkInputs(): void;
  68137. protected _updateCameraRotationMatrix(): void;
  68138. /**
  68139. * 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)
  68140. * @returns the current camera
  68141. */
  68142. private _rotateUpVectorWithCameraRotationMatrix;
  68143. private _cachedRotationZ;
  68144. private _cachedQuaternionRotationZ;
  68145. /** @hidden */
  68146. _getViewMatrix(): Matrix;
  68147. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  68148. /**
  68149. * @hidden
  68150. */
  68151. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  68152. /**
  68153. * @hidden
  68154. */
  68155. _updateRigCameras(): void;
  68156. private _getRigCamPositionAndTarget;
  68157. /**
  68158. * Gets the current object class name.
  68159. * @return the class name
  68160. */
  68161. getClassName(): string;
  68162. }
  68163. }
  68164. declare module BABYLON {
  68165. /**
  68166. * @ignore
  68167. * This is a list of all the different input types that are available in the application.
  68168. * Fo instance: ArcRotateCameraGamepadInput...
  68169. */
  68170. export var CameraInputTypes: {};
  68171. /**
  68172. * This is the contract to implement in order to create a new input class.
  68173. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  68174. */
  68175. export interface ICameraInput<TCamera extends Camera> {
  68176. /**
  68177. * Defines the camera the input is attached to.
  68178. */
  68179. camera: Nullable<TCamera>;
  68180. /**
  68181. * Gets the class name of the current intput.
  68182. * @returns the class name
  68183. */
  68184. getClassName(): string;
  68185. /**
  68186. * Get the friendly name associated with the input class.
  68187. * @returns the input friendly name
  68188. */
  68189. getSimpleName(): string;
  68190. /**
  68191. * Attach the input controls to a specific dom element to get the input from.
  68192. * @param element Defines the element the controls should be listened from
  68193. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68194. */
  68195. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68196. /**
  68197. * Detach the current controls from the specified dom element.
  68198. * @param element Defines the element to stop listening the inputs from
  68199. */
  68200. detachControl(element: Nullable<HTMLElement>): void;
  68201. /**
  68202. * Update the current camera state depending on the inputs that have been used this frame.
  68203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68204. */
  68205. checkInputs?: () => void;
  68206. }
  68207. /**
  68208. * Represents a map of input types to input instance or input index to input instance.
  68209. */
  68210. export interface CameraInputsMap<TCamera extends Camera> {
  68211. /**
  68212. * Accessor to the input by input type.
  68213. */
  68214. [name: string]: ICameraInput<TCamera>;
  68215. /**
  68216. * Accessor to the input by input index.
  68217. */
  68218. [idx: number]: ICameraInput<TCamera>;
  68219. }
  68220. /**
  68221. * This represents the input manager used within a camera.
  68222. * It helps dealing with all the different kind of input attached to a camera.
  68223. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68224. */
  68225. export class CameraInputsManager<TCamera extends Camera> {
  68226. /**
  68227. * Defines the list of inputs attahed to the camera.
  68228. */
  68229. attached: CameraInputsMap<TCamera>;
  68230. /**
  68231. * Defines the dom element the camera is collecting inputs from.
  68232. * This is null if the controls have not been attached.
  68233. */
  68234. attachedElement: Nullable<HTMLElement>;
  68235. /**
  68236. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68237. */
  68238. noPreventDefault: boolean;
  68239. /**
  68240. * Defined the camera the input manager belongs to.
  68241. */
  68242. camera: TCamera;
  68243. /**
  68244. * Update the current camera state depending on the inputs that have been used this frame.
  68245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68246. */
  68247. checkInputs: () => void;
  68248. /**
  68249. * Instantiate a new Camera Input Manager.
  68250. * @param camera Defines the camera the input manager blongs to
  68251. */
  68252. constructor(camera: TCamera);
  68253. /**
  68254. * Add an input method to a camera
  68255. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68256. * @param input camera input method
  68257. */
  68258. add(input: ICameraInput<TCamera>): void;
  68259. /**
  68260. * Remove a specific input method from a camera
  68261. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  68262. * @param inputToRemove camera input method
  68263. */
  68264. remove(inputToRemove: ICameraInput<TCamera>): void;
  68265. /**
  68266. * Remove a specific input type from a camera
  68267. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  68268. * @param inputType the type of the input to remove
  68269. */
  68270. removeByType(inputType: string): void;
  68271. private _addCheckInputs;
  68272. /**
  68273. * Attach the input controls to the currently attached dom element to listen the events from.
  68274. * @param input Defines the input to attach
  68275. */
  68276. attachInput(input: ICameraInput<TCamera>): void;
  68277. /**
  68278. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  68279. * @param element Defines the dom element to collect the events from
  68280. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68281. */
  68282. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  68283. /**
  68284. * Detach the current manager inputs controls from a specific dom element.
  68285. * @param element Defines the dom element to collect the events from
  68286. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  68287. */
  68288. detachElement(element: HTMLElement, disconnect?: boolean): void;
  68289. /**
  68290. * Rebuild the dynamic inputCheck function from the current list of
  68291. * defined inputs in the manager.
  68292. */
  68293. rebuildInputCheck(): void;
  68294. /**
  68295. * Remove all attached input methods from a camera
  68296. */
  68297. clear(): void;
  68298. /**
  68299. * Serialize the current input manager attached to a camera.
  68300. * This ensures than once parsed,
  68301. * the input associated to the camera will be identical to the current ones
  68302. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  68303. */
  68304. serialize(serializedCamera: any): void;
  68305. /**
  68306. * Parses an input manager serialized JSON to restore the previous list of inputs
  68307. * and states associated to a camera.
  68308. * @param parsedCamera Defines the JSON to parse
  68309. */
  68310. parse(parsedCamera: any): void;
  68311. }
  68312. }
  68313. declare module BABYLON {
  68314. /**
  68315. * Gather the list of keyboard event types as constants.
  68316. */
  68317. export class KeyboardEventTypes {
  68318. /**
  68319. * The keydown event is fired when a key becomes active (pressed).
  68320. */
  68321. static readonly KEYDOWN: number;
  68322. /**
  68323. * The keyup event is fired when a key has been released.
  68324. */
  68325. static readonly KEYUP: number;
  68326. }
  68327. /**
  68328. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68329. */
  68330. export class KeyboardInfo {
  68331. /**
  68332. * Defines the type of event (KeyboardEventTypes)
  68333. */
  68334. type: number;
  68335. /**
  68336. * Defines the related dom event
  68337. */
  68338. event: KeyboardEvent;
  68339. /**
  68340. * Instantiates a new keyboard info.
  68341. * This class is used to store keyboard related info for the onKeyboardObservable event.
  68342. * @param type Defines the type of event (KeyboardEventTypes)
  68343. * @param event Defines the related dom event
  68344. */
  68345. constructor(
  68346. /**
  68347. * Defines the type of event (KeyboardEventTypes)
  68348. */
  68349. type: number,
  68350. /**
  68351. * Defines the related dom event
  68352. */
  68353. event: KeyboardEvent);
  68354. }
  68355. /**
  68356. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68357. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  68358. */
  68359. export class KeyboardInfoPre extends KeyboardInfo {
  68360. /**
  68361. * Defines the type of event (KeyboardEventTypes)
  68362. */
  68363. type: number;
  68364. /**
  68365. * Defines the related dom event
  68366. */
  68367. event: KeyboardEvent;
  68368. /**
  68369. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  68370. */
  68371. skipOnPointerObservable: boolean;
  68372. /**
  68373. * Instantiates a new keyboard pre info.
  68374. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  68375. * @param type Defines the type of event (KeyboardEventTypes)
  68376. * @param event Defines the related dom event
  68377. */
  68378. constructor(
  68379. /**
  68380. * Defines the type of event (KeyboardEventTypes)
  68381. */
  68382. type: number,
  68383. /**
  68384. * Defines the related dom event
  68385. */
  68386. event: KeyboardEvent);
  68387. }
  68388. }
  68389. declare module BABYLON {
  68390. /**
  68391. * Manage the keyboard inputs to control the movement of a free camera.
  68392. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  68393. */
  68394. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  68395. /**
  68396. * Defines the camera the input is attached to.
  68397. */
  68398. camera: FreeCamera;
  68399. /**
  68400. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  68401. */
  68402. keysUp: number[];
  68403. /**
  68404. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  68405. */
  68406. keysDown: number[];
  68407. /**
  68408. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  68409. */
  68410. keysLeft: number[];
  68411. /**
  68412. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  68413. */
  68414. keysRight: number[];
  68415. private _keys;
  68416. private _onCanvasBlurObserver;
  68417. private _onKeyboardObserver;
  68418. private _engine;
  68419. private _scene;
  68420. /**
  68421. * Attach the input controls to a specific dom element to get the input from.
  68422. * @param element Defines the element the controls should be listened from
  68423. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  68424. */
  68425. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  68426. /**
  68427. * Detach the current controls from the specified dom element.
  68428. * @param element Defines the element to stop listening the inputs from
  68429. */
  68430. detachControl(element: Nullable<HTMLElement>): void;
  68431. /**
  68432. * Update the current camera state depending on the inputs that have been used this frame.
  68433. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  68434. */
  68435. checkInputs(): void;
  68436. /**
  68437. * Gets the class name of the current intput.
  68438. * @returns the class name
  68439. */
  68440. getClassName(): string;
  68441. /** @hidden */
  68442. _onLostFocus(): void;
  68443. /**
  68444. * Get the friendly name associated with the input class.
  68445. * @returns the input friendly name
  68446. */
  68447. getSimpleName(): string;
  68448. }
  68449. }
  68450. declare module BABYLON {
  68451. /**
  68452. * Interface describing all the common properties and methods a shadow light needs to implement.
  68453. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  68454. * as well as binding the different shadow properties to the effects.
  68455. */
  68456. export interface IShadowLight extends Light {
  68457. /**
  68458. * The light id in the scene (used in scene.findLighById for instance)
  68459. */
  68460. id: string;
  68461. /**
  68462. * The position the shdow will be casted from.
  68463. */
  68464. position: Vector3;
  68465. /**
  68466. * In 2d mode (needCube being false), the direction used to cast the shadow.
  68467. */
  68468. direction: Vector3;
  68469. /**
  68470. * The transformed position. Position of the light in world space taking parenting in account.
  68471. */
  68472. transformedPosition: Vector3;
  68473. /**
  68474. * The transformed direction. Direction of the light in world space taking parenting in account.
  68475. */
  68476. transformedDirection: Vector3;
  68477. /**
  68478. * The friendly name of the light in the scene.
  68479. */
  68480. name: string;
  68481. /**
  68482. * Defines the shadow projection clipping minimum z value.
  68483. */
  68484. shadowMinZ: number;
  68485. /**
  68486. * Defines the shadow projection clipping maximum z value.
  68487. */
  68488. shadowMaxZ: number;
  68489. /**
  68490. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68491. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68492. */
  68493. computeTransformedInformation(): boolean;
  68494. /**
  68495. * Gets the scene the light belongs to.
  68496. * @returns The scene
  68497. */
  68498. getScene(): Scene;
  68499. /**
  68500. * Callback defining a custom Projection Matrix Builder.
  68501. * This can be used to override the default projection matrix computation.
  68502. */
  68503. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68504. /**
  68505. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68506. * @param matrix The materix to updated with the projection information
  68507. * @param viewMatrix The transform matrix of the light
  68508. * @param renderList The list of mesh to render in the map
  68509. * @returns The current light
  68510. */
  68511. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68512. /**
  68513. * Gets the current depth scale used in ESM.
  68514. * @returns The scale
  68515. */
  68516. getDepthScale(): number;
  68517. /**
  68518. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68519. * @returns true if a cube texture needs to be use
  68520. */
  68521. needCube(): boolean;
  68522. /**
  68523. * Detects if the projection matrix requires to be recomputed this frame.
  68524. * @returns true if it requires to be recomputed otherwise, false.
  68525. */
  68526. needProjectionMatrixCompute(): boolean;
  68527. /**
  68528. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68529. */
  68530. forceProjectionMatrixCompute(): void;
  68531. /**
  68532. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68533. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68534. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68535. */
  68536. getShadowDirection(faceIndex?: number): Vector3;
  68537. /**
  68538. * Gets the minZ used for shadow according to both the scene and the light.
  68539. * @param activeCamera The camera we are returning the min for
  68540. * @returns the depth min z
  68541. */
  68542. getDepthMinZ(activeCamera: Camera): number;
  68543. /**
  68544. * Gets the maxZ used for shadow according to both the scene and the light.
  68545. * @param activeCamera The camera we are returning the max for
  68546. * @returns the depth max z
  68547. */
  68548. getDepthMaxZ(activeCamera: Camera): number;
  68549. }
  68550. /**
  68551. * Base implementation IShadowLight
  68552. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  68553. */
  68554. export abstract class ShadowLight extends Light implements IShadowLight {
  68555. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  68556. protected _position: Vector3;
  68557. protected _setPosition(value: Vector3): void;
  68558. /**
  68559. * Sets the position the shadow will be casted from. Also use as the light position for both
  68560. * point and spot lights.
  68561. */
  68562. /**
  68563. * Sets the position the shadow will be casted from. Also use as the light position for both
  68564. * point and spot lights.
  68565. */
  68566. position: Vector3;
  68567. protected _direction: Vector3;
  68568. protected _setDirection(value: Vector3): void;
  68569. /**
  68570. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  68571. * Also use as the light direction on spot and directional lights.
  68572. */
  68573. /**
  68574. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  68575. * Also use as the light direction on spot and directional lights.
  68576. */
  68577. direction: Vector3;
  68578. private _shadowMinZ;
  68579. /**
  68580. * Gets the shadow projection clipping minimum z value.
  68581. */
  68582. /**
  68583. * Sets the shadow projection clipping minimum z value.
  68584. */
  68585. shadowMinZ: number;
  68586. private _shadowMaxZ;
  68587. /**
  68588. * Sets the shadow projection clipping maximum z value.
  68589. */
  68590. /**
  68591. * Gets the shadow projection clipping maximum z value.
  68592. */
  68593. shadowMaxZ: number;
  68594. /**
  68595. * Callback defining a custom Projection Matrix Builder.
  68596. * This can be used to override the default projection matrix computation.
  68597. */
  68598. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  68599. /**
  68600. * The transformed position. Position of the light in world space taking parenting in account.
  68601. */
  68602. transformedPosition: Vector3;
  68603. /**
  68604. * The transformed direction. Direction of the light in world space taking parenting in account.
  68605. */
  68606. transformedDirection: Vector3;
  68607. private _needProjectionMatrixCompute;
  68608. /**
  68609. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  68610. * @returns true if the information has been computed, false if it does not need to (no parenting)
  68611. */
  68612. computeTransformedInformation(): boolean;
  68613. /**
  68614. * Return the depth scale used for the shadow map.
  68615. * @returns the depth scale.
  68616. */
  68617. getDepthScale(): number;
  68618. /**
  68619. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  68620. * @param faceIndex The index of the face we are computed the direction to generate shadow
  68621. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  68622. */
  68623. getShadowDirection(faceIndex?: number): Vector3;
  68624. /**
  68625. * Returns the ShadowLight absolute position in the World.
  68626. * @returns the position vector in world space
  68627. */
  68628. getAbsolutePosition(): Vector3;
  68629. /**
  68630. * Sets the ShadowLight direction toward the passed target.
  68631. * @param target The point to target in local space
  68632. * @returns the updated ShadowLight direction
  68633. */
  68634. setDirectionToTarget(target: Vector3): Vector3;
  68635. /**
  68636. * Returns the light rotation in euler definition.
  68637. * @returns the x y z rotation in local space.
  68638. */
  68639. getRotation(): Vector3;
  68640. /**
  68641. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  68642. * @returns true if a cube texture needs to be use
  68643. */
  68644. needCube(): boolean;
  68645. /**
  68646. * Detects if the projection matrix requires to be recomputed this frame.
  68647. * @returns true if it requires to be recomputed otherwise, false.
  68648. */
  68649. needProjectionMatrixCompute(): boolean;
  68650. /**
  68651. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  68652. */
  68653. forceProjectionMatrixCompute(): void;
  68654. /** @hidden */
  68655. _initCache(): void;
  68656. /** @hidden */
  68657. _isSynchronized(): boolean;
  68658. /**
  68659. * Computes the world matrix of the node
  68660. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  68661. * @returns the world matrix
  68662. */
  68663. computeWorldMatrix(force?: boolean): Matrix;
  68664. /**
  68665. * Gets the minZ used for shadow according to both the scene and the light.
  68666. * @param activeCamera The camera we are returning the min for
  68667. * @returns the depth min z
  68668. */
  68669. getDepthMinZ(activeCamera: Camera): number;
  68670. /**
  68671. * Gets the maxZ used for shadow according to both the scene and the light.
  68672. * @param activeCamera The camera we are returning the max for
  68673. * @returns the depth max z
  68674. */
  68675. getDepthMaxZ(activeCamera: Camera): number;
  68676. /**
  68677. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  68678. * @param matrix The materix to updated with the projection information
  68679. * @param viewMatrix The transform matrix of the light
  68680. * @param renderList The list of mesh to render in the map
  68681. * @returns The current light
  68682. */
  68683. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  68684. }
  68685. }
  68686. declare module BABYLON {
  68687. /**
  68688. * "Static Class" containing the most commonly used helper while dealing with material for
  68689. * rendering purpose.
  68690. *
  68691. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  68692. *
  68693. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  68694. */
  68695. export class MaterialHelper {
  68696. /**
  68697. * Bind the current view position to an effect.
  68698. * @param effect The effect to be bound
  68699. * @param scene The scene the eyes position is used from
  68700. */
  68701. static BindEyePosition(effect: Effect, scene: Scene): void;
  68702. /**
  68703. * Helps preparing the defines values about the UVs in used in the effect.
  68704. * UVs are shared as much as we can accross channels in the shaders.
  68705. * @param texture The texture we are preparing the UVs for
  68706. * @param defines The defines to update
  68707. * @param key The channel key "diffuse", "specular"... used in the shader
  68708. */
  68709. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  68710. /**
  68711. * Binds a texture matrix value to its corrsponding uniform
  68712. * @param texture The texture to bind the matrix for
  68713. * @param uniformBuffer The uniform buffer receivin the data
  68714. * @param key The channel key "diffuse", "specular"... used in the shader
  68715. */
  68716. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  68717. /**
  68718. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  68719. * @param mesh defines the current mesh
  68720. * @param scene defines the current scene
  68721. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  68722. * @param pointsCloud defines if point cloud rendering has to be turned on
  68723. * @param fogEnabled defines if fog has to be turned on
  68724. * @param alphaTest defines if alpha testing has to be turned on
  68725. * @param defines defines the current list of defines
  68726. */
  68727. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  68728. /**
  68729. * Helper used to prepare the list of defines associated with frame values for shader compilation
  68730. * @param scene defines the current scene
  68731. * @param engine defines the current engine
  68732. * @param defines specifies the list of active defines
  68733. * @param useInstances defines if instances have to be turned on
  68734. * @param useClipPlane defines if clip plane have to be turned on
  68735. */
  68736. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>): void;
  68737. /**
  68738. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  68739. * @param mesh The mesh containing the geometry data we will draw
  68740. * @param defines The defines to update
  68741. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  68742. * @param useBones Precise whether bones should be used or not (override mesh info)
  68743. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  68744. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  68745. * @returns false if defines are considered not dirty and have not been checked
  68746. */
  68747. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  68748. /**
  68749. * Prepares the defines related to multiview
  68750. * @param scene The scene we are intending to draw
  68751. * @param defines The defines to update
  68752. */
  68753. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  68754. /**
  68755. * Prepares the defines related to the light information passed in parameter
  68756. * @param scene The scene we are intending to draw
  68757. * @param mesh The mesh the effect is compiling for
  68758. * @param defines The defines to update
  68759. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  68760. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  68761. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  68762. * @returns true if normals will be required for the rest of the effect
  68763. */
  68764. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  68765. /**
  68766. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  68767. * that won t be acctive due to defines being turned off.
  68768. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  68769. * @param samplersList The samplers list
  68770. * @param defines The defines helping in the list generation
  68771. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  68772. */
  68773. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | EffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  68774. /**
  68775. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  68776. * @param defines The defines to update while falling back
  68777. * @param fallbacks The authorized effect fallbacks
  68778. * @param maxSimultaneousLights The maximum number of lights allowed
  68779. * @param rank the current rank of the Effect
  68780. * @returns The newly affected rank
  68781. */
  68782. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  68783. /**
  68784. * Prepares the list of attributes required for morph targets according to the effect defines.
  68785. * @param attribs The current list of supported attribs
  68786. * @param mesh The mesh to prepare the morph targets attributes for
  68787. * @param defines The current Defines of the effect
  68788. */
  68789. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  68790. /**
  68791. * Prepares the list of attributes required for bones according to the effect defines.
  68792. * @param attribs The current list of supported attribs
  68793. * @param mesh The mesh to prepare the bones attributes for
  68794. * @param defines The current Defines of the effect
  68795. * @param fallbacks The current efffect fallback strategy
  68796. */
  68797. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  68798. /**
  68799. * Prepares the list of attributes required for instances according to the effect defines.
  68800. * @param attribs The current list of supported attribs
  68801. * @param defines The current Defines of the effect
  68802. */
  68803. static PrepareAttributesForInstances(attribs: string[], defines: any): void;
  68804. /**
  68805. * Binds the light shadow information to the effect for the given mesh.
  68806. * @param light The light containing the generator
  68807. * @param scene The scene the lights belongs to
  68808. * @param mesh The mesh we are binding the information to render
  68809. * @param lightIndex The light index in the effect used to render the mesh
  68810. * @param effect The effect we are binding the data to
  68811. */
  68812. static BindLightShadow(light: Light, mesh: AbstractMesh, lightIndex: string, effect: Effect): void;
  68813. /**
  68814. * Binds the light information to the effect.
  68815. * @param light The light containing the generator
  68816. * @param effect The effect we are binding the data to
  68817. * @param lightIndex The light index in the effect used to render
  68818. */
  68819. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  68820. /**
  68821. * Binds the lights information from the scene to the effect for the given mesh.
  68822. * @param scene The scene the lights belongs to
  68823. * @param mesh The mesh we are binding the information to render
  68824. * @param effect The effect we are binding the data to
  68825. * @param defines The generated defines for the effect
  68826. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  68827. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  68828. */
  68829. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, usePhysicalLightFalloff?: boolean): void;
  68830. private static _tempFogColor;
  68831. /**
  68832. * Binds the fog information from the scene to the effect for the given mesh.
  68833. * @param scene The scene the lights belongs to
  68834. * @param mesh The mesh we are binding the information to render
  68835. * @param effect The effect we are binding the data to
  68836. * @param linearSpace Defines if the fog effect is applied in linear space
  68837. */
  68838. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  68839. /**
  68840. * Binds the bones information from the mesh to the effect.
  68841. * @param mesh The mesh we are binding the information to render
  68842. * @param effect The effect we are binding the data to
  68843. */
  68844. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect): void;
  68845. /**
  68846. * Binds the morph targets information from the mesh to the effect.
  68847. * @param abstractMesh The mesh we are binding the information to render
  68848. * @param effect The effect we are binding the data to
  68849. */
  68850. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  68851. /**
  68852. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  68853. * @param defines The generated defines used in the effect
  68854. * @param effect The effect we are binding the data to
  68855. * @param scene The scene we are willing to render with logarithmic scale for
  68856. */
  68857. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  68858. /**
  68859. * Binds the clip plane information from the scene to the effect.
  68860. * @param scene The scene the clip plane information are extracted from
  68861. * @param effect The effect we are binding the data to
  68862. */
  68863. static BindClipPlane(effect: Effect, scene: Scene): void;
  68864. }
  68865. }
  68866. declare module BABYLON {
  68867. /** @hidden */
  68868. export var kernelBlurVaryingDeclaration: {
  68869. name: string;
  68870. shader: string;
  68871. };
  68872. }
  68873. declare module BABYLON {
  68874. /** @hidden */
  68875. export var kernelBlurFragment: {
  68876. name: string;
  68877. shader: string;
  68878. };
  68879. }
  68880. declare module BABYLON {
  68881. /** @hidden */
  68882. export var kernelBlurFragment2: {
  68883. name: string;
  68884. shader: string;
  68885. };
  68886. }
  68887. declare module BABYLON {
  68888. /** @hidden */
  68889. export var kernelBlurPixelShader: {
  68890. name: string;
  68891. shader: string;
  68892. };
  68893. }
  68894. declare module BABYLON {
  68895. /** @hidden */
  68896. export var kernelBlurVertex: {
  68897. name: string;
  68898. shader: string;
  68899. };
  68900. }
  68901. declare module BABYLON {
  68902. /** @hidden */
  68903. export var kernelBlurVertexShader: {
  68904. name: string;
  68905. shader: string;
  68906. };
  68907. }
  68908. declare module BABYLON {
  68909. /**
  68910. * The Blur Post Process which blurs an image based on a kernel and direction.
  68911. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  68912. */
  68913. export class BlurPostProcess extends PostProcess {
  68914. /** The direction in which to blur the image. */
  68915. direction: Vector2;
  68916. private blockCompilation;
  68917. protected _kernel: number;
  68918. protected _idealKernel: number;
  68919. protected _packedFloat: boolean;
  68920. private _staticDefines;
  68921. /**
  68922. * Sets the length in pixels of the blur sample region
  68923. */
  68924. /**
  68925. * Gets the length in pixels of the blur sample region
  68926. */
  68927. kernel: number;
  68928. /**
  68929. * Sets wether or not the blur needs to unpack/repack floats
  68930. */
  68931. /**
  68932. * Gets wether or not the blur is unpacking/repacking floats
  68933. */
  68934. packedFloat: boolean;
  68935. /**
  68936. * Creates a new instance BlurPostProcess
  68937. * @param name The name of the effect.
  68938. * @param direction The direction in which to blur the image.
  68939. * @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.
  68940. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  68941. * @param camera The camera to apply the render pass to.
  68942. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  68943. * @param engine The engine which the post process will be applied. (default: current engine)
  68944. * @param reusable If the post process can be reused on the same frame. (default: false)
  68945. * @param textureType Type of textures used when performing the post process. (default: 0)
  68946. * @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)
  68947. */
  68948. constructor(name: string,
  68949. /** The direction in which to blur the image. */
  68950. direction: Vector2, kernel: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, defines?: string, blockCompilation?: boolean);
  68951. /**
  68952. * Updates the effect with the current post process compile time values and recompiles the shader.
  68953. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  68954. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  68955. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  68956. * @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
  68957. * @param onCompiled Called when the shader has been compiled.
  68958. * @param onError Called if there is an error when compiling a shader.
  68959. */
  68960. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68961. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  68962. /**
  68963. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  68964. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  68965. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  68966. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  68967. * The gaps between physical kernels are compensated for in the weighting of the samples
  68968. * @param idealKernel Ideal blur kernel.
  68969. * @return Nearest best kernel.
  68970. */
  68971. protected _nearestBestKernel(idealKernel: number): number;
  68972. /**
  68973. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  68974. * @param x The point on the Gaussian distribution to sample.
  68975. * @return the value of the Gaussian function at x.
  68976. */
  68977. protected _gaussianWeight(x: number): number;
  68978. /**
  68979. * Generates a string that can be used as a floating point number in GLSL.
  68980. * @param x Value to print.
  68981. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  68982. * @return GLSL float string.
  68983. */
  68984. protected _glslFloat(x: number, decimalFigures?: number): string;
  68985. }
  68986. }
  68987. declare module BABYLON {
  68988. /** @hidden */
  68989. export var shadowMapPixelShader: {
  68990. name: string;
  68991. shader: string;
  68992. };
  68993. }
  68994. declare module BABYLON {
  68995. /** @hidden */
  68996. export var bonesDeclaration: {
  68997. name: string;
  68998. shader: string;
  68999. };
  69000. }
  69001. declare module BABYLON {
  69002. /** @hidden */
  69003. export var morphTargetsVertexGlobalDeclaration: {
  69004. name: string;
  69005. shader: string;
  69006. };
  69007. }
  69008. declare module BABYLON {
  69009. /** @hidden */
  69010. export var morphTargetsVertexDeclaration: {
  69011. name: string;
  69012. shader: string;
  69013. };
  69014. }
  69015. declare module BABYLON {
  69016. /** @hidden */
  69017. export var instancesDeclaration: {
  69018. name: string;
  69019. shader: string;
  69020. };
  69021. }
  69022. declare module BABYLON {
  69023. /** @hidden */
  69024. export var helperFunctions: {
  69025. name: string;
  69026. shader: string;
  69027. };
  69028. }
  69029. declare module BABYLON {
  69030. /** @hidden */
  69031. export var morphTargetsVertex: {
  69032. name: string;
  69033. shader: string;
  69034. };
  69035. }
  69036. declare module BABYLON {
  69037. /** @hidden */
  69038. export var instancesVertex: {
  69039. name: string;
  69040. shader: string;
  69041. };
  69042. }
  69043. declare module BABYLON {
  69044. /** @hidden */
  69045. export var bonesVertex: {
  69046. name: string;
  69047. shader: string;
  69048. };
  69049. }
  69050. declare module BABYLON {
  69051. /** @hidden */
  69052. export var shadowMapVertexShader: {
  69053. name: string;
  69054. shader: string;
  69055. };
  69056. }
  69057. declare module BABYLON {
  69058. /** @hidden */
  69059. export var depthBoxBlurPixelShader: {
  69060. name: string;
  69061. shader: string;
  69062. };
  69063. }
  69064. declare module BABYLON {
  69065. /**
  69066. * Defines the options associated with the creation of a custom shader for a shadow generator.
  69067. */
  69068. export interface ICustomShaderOptions {
  69069. /**
  69070. * Gets or sets the custom shader name to use
  69071. */
  69072. shaderName: string;
  69073. /**
  69074. * The list of attribute names used in the shader
  69075. */
  69076. attributes?: string[];
  69077. /**
  69078. * The list of unifrom names used in the shader
  69079. */
  69080. uniforms?: string[];
  69081. /**
  69082. * The list of sampler names used in the shader
  69083. */
  69084. samplers?: string[];
  69085. /**
  69086. * The list of defines used in the shader
  69087. */
  69088. defines?: string[];
  69089. }
  69090. /**
  69091. * Interface to implement to create a shadow generator compatible with BJS.
  69092. */
  69093. export interface IShadowGenerator {
  69094. /**
  69095. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69096. * @returns The render target texture if present otherwise, null
  69097. */
  69098. getShadowMap(): Nullable<RenderTargetTexture>;
  69099. /**
  69100. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69101. * @returns The render target texture if the shadow map is present otherwise, null
  69102. */
  69103. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69104. /**
  69105. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69106. * @param subMesh The submesh we want to render in the shadow map
  69107. * @param useInstances Defines wether will draw in the map using instances
  69108. * @returns true if ready otherwise, false
  69109. */
  69110. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69111. /**
  69112. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69113. * @param defines Defines of the material we want to update
  69114. * @param lightIndex Index of the light in the enabled light list of the material
  69115. */
  69116. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  69117. /**
  69118. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69119. * defined in the generator but impacting the effect).
  69120. * It implies the unifroms available on the materials are the standard BJS ones.
  69121. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69122. * @param effect The effect we are binfing the information for
  69123. */
  69124. bindShadowLight(lightIndex: string, effect: Effect): void;
  69125. /**
  69126. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69127. * (eq to shadow prjection matrix * light transform matrix)
  69128. * @returns The transform matrix used to create the shadow map
  69129. */
  69130. getTransformMatrix(): Matrix;
  69131. /**
  69132. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69133. * Cube and 2D textures for instance.
  69134. */
  69135. recreateShadowMap(): void;
  69136. /**
  69137. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69138. * @param onCompiled Callback triggered at the and of the effects compilation
  69139. * @param options Sets of optional options forcing the compilation with different modes
  69140. */
  69141. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69142. useInstances: boolean;
  69143. }>): void;
  69144. /**
  69145. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69146. * @param options Sets of optional options forcing the compilation with different modes
  69147. * @returns A promise that resolves when the compilation completes
  69148. */
  69149. forceCompilationAsync(options?: Partial<{
  69150. useInstances: boolean;
  69151. }>): Promise<void>;
  69152. /**
  69153. * Serializes the shadow generator setup to a json object.
  69154. * @returns The serialized JSON object
  69155. */
  69156. serialize(): any;
  69157. /**
  69158. * Disposes the Shadow map and related Textures and effects.
  69159. */
  69160. dispose(): void;
  69161. }
  69162. /**
  69163. * Default implementation IShadowGenerator.
  69164. * This is the main object responsible of generating shadows in the framework.
  69165. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  69166. */
  69167. export class ShadowGenerator implements IShadowGenerator {
  69168. /**
  69169. * Shadow generator mode None: no filtering applied.
  69170. */
  69171. static readonly FILTER_NONE: number;
  69172. /**
  69173. * Shadow generator mode ESM: Exponential Shadow Mapping.
  69174. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69175. */
  69176. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  69177. /**
  69178. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  69179. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  69180. */
  69181. static readonly FILTER_POISSONSAMPLING: number;
  69182. /**
  69183. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  69184. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69185. */
  69186. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  69187. /**
  69188. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  69189. * edge artifacts on steep falloff.
  69190. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69191. */
  69192. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  69193. /**
  69194. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  69195. * edge artifacts on steep falloff.
  69196. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  69197. */
  69198. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  69199. /**
  69200. * Shadow generator mode PCF: Percentage Closer Filtering
  69201. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69202. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  69203. */
  69204. static readonly FILTER_PCF: number;
  69205. /**
  69206. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  69207. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  69208. * Contact Hardening
  69209. */
  69210. static readonly FILTER_PCSS: number;
  69211. /**
  69212. * Reserved for PCF and PCSS
  69213. * Highest Quality.
  69214. *
  69215. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  69216. *
  69217. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  69218. */
  69219. static readonly QUALITY_HIGH: number;
  69220. /**
  69221. * Reserved for PCF and PCSS
  69222. * Good tradeoff for quality/perf cross devices
  69223. *
  69224. * Execute PCF on a 3*3 kernel.
  69225. *
  69226. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  69227. */
  69228. static readonly QUALITY_MEDIUM: number;
  69229. /**
  69230. * Reserved for PCF and PCSS
  69231. * The lowest quality but the fastest.
  69232. *
  69233. * Execute PCF on a 1*1 kernel.
  69234. *
  69235. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  69236. */
  69237. static readonly QUALITY_LOW: number;
  69238. /** Gets or sets the custom shader name to use */
  69239. customShaderOptions: ICustomShaderOptions;
  69240. /**
  69241. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  69242. */
  69243. onBeforeShadowMapRenderObservable: Observable<Effect>;
  69244. /**
  69245. * Observable triggered before a mesh is rendered in the shadow map.
  69246. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  69247. */
  69248. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  69249. private _bias;
  69250. /**
  69251. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  69252. */
  69253. /**
  69254. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  69255. */
  69256. bias: number;
  69257. private _normalBias;
  69258. /**
  69259. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69260. */
  69261. /**
  69262. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  69263. */
  69264. normalBias: number;
  69265. private _blurBoxOffset;
  69266. /**
  69267. * Gets the blur box offset: offset applied during the blur pass.
  69268. * Only useful if useKernelBlur = false
  69269. */
  69270. /**
  69271. * Sets the blur box offset: offset applied during the blur pass.
  69272. * Only useful if useKernelBlur = false
  69273. */
  69274. blurBoxOffset: number;
  69275. private _blurScale;
  69276. /**
  69277. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  69278. * 2 means half of the size.
  69279. */
  69280. /**
  69281. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  69282. * 2 means half of the size.
  69283. */
  69284. blurScale: number;
  69285. private _blurKernel;
  69286. /**
  69287. * Gets the blur kernel: kernel size of the blur pass.
  69288. * Only useful if useKernelBlur = true
  69289. */
  69290. /**
  69291. * Sets the blur kernel: kernel size of the blur pass.
  69292. * Only useful if useKernelBlur = true
  69293. */
  69294. blurKernel: number;
  69295. private _useKernelBlur;
  69296. /**
  69297. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  69298. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69299. */
  69300. /**
  69301. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  69302. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  69303. */
  69304. useKernelBlur: boolean;
  69305. private _depthScale;
  69306. /**
  69307. * Gets the depth scale used in ESM mode.
  69308. */
  69309. /**
  69310. * Sets the depth scale used in ESM mode.
  69311. * This can override the scale stored on the light.
  69312. */
  69313. depthScale: number;
  69314. private _filter;
  69315. /**
  69316. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  69317. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69318. */
  69319. /**
  69320. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  69321. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  69322. */
  69323. filter: number;
  69324. /**
  69325. * Gets if the current filter is set to Poisson Sampling.
  69326. */
  69327. /**
  69328. * Sets the current filter to Poisson Sampling.
  69329. */
  69330. usePoissonSampling: boolean;
  69331. /**
  69332. * Gets if the current filter is set to ESM.
  69333. */
  69334. /**
  69335. * Sets the current filter is to ESM.
  69336. */
  69337. useExponentialShadowMap: boolean;
  69338. /**
  69339. * Gets if the current filter is set to filtered ESM.
  69340. */
  69341. /**
  69342. * Gets if the current filter is set to filtered ESM.
  69343. */
  69344. useBlurExponentialShadowMap: boolean;
  69345. /**
  69346. * Gets if the current filter is set to "close ESM" (using the inverse of the
  69347. * exponential to prevent steep falloff artifacts).
  69348. */
  69349. /**
  69350. * Sets the current filter to "close ESM" (using the inverse of the
  69351. * exponential to prevent steep falloff artifacts).
  69352. */
  69353. useCloseExponentialShadowMap: boolean;
  69354. /**
  69355. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  69356. * exponential to prevent steep falloff artifacts).
  69357. */
  69358. /**
  69359. * Sets the current filter to filtered "close ESM" (using the inverse of the
  69360. * exponential to prevent steep falloff artifacts).
  69361. */
  69362. useBlurCloseExponentialShadowMap: boolean;
  69363. /**
  69364. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  69365. */
  69366. /**
  69367. * Sets the current filter to "PCF" (percentage closer filtering).
  69368. */
  69369. usePercentageCloserFiltering: boolean;
  69370. private _filteringQuality;
  69371. /**
  69372. * Gets the PCF or PCSS Quality.
  69373. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69374. */
  69375. /**
  69376. * Sets the PCF or PCSS Quality.
  69377. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  69378. */
  69379. filteringQuality: number;
  69380. /**
  69381. * Gets if the current filter is set to "PCSS" (contact hardening).
  69382. */
  69383. /**
  69384. * Sets the current filter to "PCSS" (contact hardening).
  69385. */
  69386. useContactHardeningShadow: boolean;
  69387. private _contactHardeningLightSizeUVRatio;
  69388. /**
  69389. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69390. * Using a ratio helps keeping shape stability independently of the map size.
  69391. *
  69392. * It does not account for the light projection as it was having too much
  69393. * instability during the light setup or during light position changes.
  69394. *
  69395. * Only valid if useContactHardeningShadow is true.
  69396. */
  69397. /**
  69398. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  69399. * Using a ratio helps keeping shape stability independently of the map size.
  69400. *
  69401. * It does not account for the light projection as it was having too much
  69402. * instability during the light setup or during light position changes.
  69403. *
  69404. * Only valid if useContactHardeningShadow is true.
  69405. */
  69406. contactHardeningLightSizeUVRatio: number;
  69407. private _darkness;
  69408. /**
  69409. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  69410. * 0 means strongest and 1 would means no shadow.
  69411. * @returns the darkness.
  69412. */
  69413. getDarkness(): number;
  69414. /**
  69415. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  69416. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  69417. * @returns the shadow generator allowing fluent coding.
  69418. */
  69419. setDarkness(darkness: number): ShadowGenerator;
  69420. private _transparencyShadow;
  69421. /**
  69422. * Sets the ability to have transparent shadow (boolean).
  69423. * @param transparent True if transparent else False
  69424. * @returns the shadow generator allowing fluent coding
  69425. */
  69426. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  69427. private _shadowMap;
  69428. private _shadowMap2;
  69429. /**
  69430. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  69431. * @returns The render target texture if present otherwise, null
  69432. */
  69433. getShadowMap(): Nullable<RenderTargetTexture>;
  69434. /**
  69435. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  69436. * @returns The render target texture if the shadow map is present otherwise, null
  69437. */
  69438. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  69439. /**
  69440. * Helper function to add a mesh and its descendants to the list of shadow casters.
  69441. * @param mesh Mesh to add
  69442. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  69443. * @returns the Shadow Generator itself
  69444. */
  69445. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69446. /**
  69447. * Helper function to remove a mesh and its descendants from the list of shadow casters
  69448. * @param mesh Mesh to remove
  69449. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  69450. * @returns the Shadow Generator itself
  69451. */
  69452. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  69453. /**
  69454. * Controls the extent to which the shadows fade out at the edge of the frustum
  69455. * Used only by directionals and spots
  69456. */
  69457. frustumEdgeFalloff: number;
  69458. private _light;
  69459. /**
  69460. * Returns the associated light object.
  69461. * @returns the light generating the shadow
  69462. */
  69463. getLight(): IShadowLight;
  69464. /**
  69465. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  69466. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  69467. * It might on the other hand introduce peter panning.
  69468. */
  69469. forceBackFacesOnly: boolean;
  69470. private _scene;
  69471. private _lightDirection;
  69472. private _effect;
  69473. private _viewMatrix;
  69474. private _projectionMatrix;
  69475. private _transformMatrix;
  69476. private _cachedPosition;
  69477. private _cachedDirection;
  69478. private _cachedDefines;
  69479. private _currentRenderID;
  69480. private _boxBlurPostprocess;
  69481. private _kernelBlurXPostprocess;
  69482. private _kernelBlurYPostprocess;
  69483. private _blurPostProcesses;
  69484. private _mapSize;
  69485. private _currentFaceIndex;
  69486. private _currentFaceIndexCache;
  69487. private _textureType;
  69488. private _defaultTextureMatrix;
  69489. /** @hidden */
  69490. static _SceneComponentInitialization: (scene: Scene) => void;
  69491. /**
  69492. * Creates a ShadowGenerator object.
  69493. * A ShadowGenerator is the required tool to use the shadows.
  69494. * Each light casting shadows needs to use its own ShadowGenerator.
  69495. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  69496. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  69497. * @param light The light object generating the shadows.
  69498. * @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.
  69499. */
  69500. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  69501. private _initializeGenerator;
  69502. private _initializeShadowMap;
  69503. private _initializeBlurRTTAndPostProcesses;
  69504. private _renderForShadowMap;
  69505. private _renderSubMeshForShadowMap;
  69506. private _applyFilterValues;
  69507. /**
  69508. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69509. * @param onCompiled Callback triggered at the and of the effects compilation
  69510. * @param options Sets of optional options forcing the compilation with different modes
  69511. */
  69512. forceCompilation(onCompiled?: (generator: ShadowGenerator) => void, options?: Partial<{
  69513. useInstances: boolean;
  69514. }>): void;
  69515. /**
  69516. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  69517. * @param options Sets of optional options forcing the compilation with different modes
  69518. * @returns A promise that resolves when the compilation completes
  69519. */
  69520. forceCompilationAsync(options?: Partial<{
  69521. useInstances: boolean;
  69522. }>): Promise<void>;
  69523. /**
  69524. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  69525. * @param subMesh The submesh we want to render in the shadow map
  69526. * @param useInstances Defines wether will draw in the map using instances
  69527. * @returns true if ready otherwise, false
  69528. */
  69529. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  69530. /**
  69531. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  69532. * @param defines Defines of the material we want to update
  69533. * @param lightIndex Index of the light in the enabled light list of the material
  69534. */
  69535. prepareDefines(defines: any, lightIndex: number): void;
  69536. /**
  69537. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  69538. * defined in the generator but impacting the effect).
  69539. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  69540. * @param effect The effect we are binfing the information for
  69541. */
  69542. bindShadowLight(lightIndex: string, effect: Effect): void;
  69543. /**
  69544. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  69545. * (eq to shadow prjection matrix * light transform matrix)
  69546. * @returns The transform matrix used to create the shadow map
  69547. */
  69548. getTransformMatrix(): Matrix;
  69549. /**
  69550. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  69551. * Cube and 2D textures for instance.
  69552. */
  69553. recreateShadowMap(): void;
  69554. private _disposeBlurPostProcesses;
  69555. private _disposeRTTandPostProcesses;
  69556. /**
  69557. * Disposes the ShadowGenerator.
  69558. * Returns nothing.
  69559. */
  69560. dispose(): void;
  69561. /**
  69562. * Serializes the shadow generator setup to a json object.
  69563. * @returns The serialized JSON object
  69564. */
  69565. serialize(): any;
  69566. /**
  69567. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  69568. * @param parsedShadowGenerator The JSON object to parse
  69569. * @param scene The scene to create the shadow map for
  69570. * @returns The parsed shadow generator
  69571. */
  69572. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  69573. }
  69574. }
  69575. declare module BABYLON {
  69576. /**
  69577. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  69578. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  69579. * 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.
  69580. */
  69581. export abstract class Light extends Node {
  69582. /**
  69583. * Falloff Default: light is falling off following the material specification:
  69584. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  69585. */
  69586. static readonly FALLOFF_DEFAULT: number;
  69587. /**
  69588. * Falloff Physical: light is falling off following the inverse squared distance law.
  69589. */
  69590. static readonly FALLOFF_PHYSICAL: number;
  69591. /**
  69592. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  69593. * to enhance interoperability with other engines.
  69594. */
  69595. static readonly FALLOFF_GLTF: number;
  69596. /**
  69597. * Falloff Standard: light is falling off like in the standard material
  69598. * to enhance interoperability with other materials.
  69599. */
  69600. static readonly FALLOFF_STANDARD: number;
  69601. /**
  69602. * If every light affecting the material is in this lightmapMode,
  69603. * material.lightmapTexture adds or multiplies
  69604. * (depends on material.useLightmapAsShadowmap)
  69605. * after every other light calculations.
  69606. */
  69607. static readonly LIGHTMAP_DEFAULT: number;
  69608. /**
  69609. * material.lightmapTexture as only diffuse lighting from this light
  69610. * adds only specular lighting from this light
  69611. * adds dynamic shadows
  69612. */
  69613. static readonly LIGHTMAP_SPECULAR: number;
  69614. /**
  69615. * material.lightmapTexture as only lighting
  69616. * no light calculation from this light
  69617. * only adds dynamic shadows from this light
  69618. */
  69619. static readonly LIGHTMAP_SHADOWSONLY: number;
  69620. /**
  69621. * Each light type uses the default quantity according to its type:
  69622. * point/spot lights use luminous intensity
  69623. * directional lights use illuminance
  69624. */
  69625. static readonly INTENSITYMODE_AUTOMATIC: number;
  69626. /**
  69627. * lumen (lm)
  69628. */
  69629. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  69630. /**
  69631. * candela (lm/sr)
  69632. */
  69633. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  69634. /**
  69635. * lux (lm/m^2)
  69636. */
  69637. static readonly INTENSITYMODE_ILLUMINANCE: number;
  69638. /**
  69639. * nit (cd/m^2)
  69640. */
  69641. static readonly INTENSITYMODE_LUMINANCE: number;
  69642. /**
  69643. * Light type const id of the point light.
  69644. */
  69645. static readonly LIGHTTYPEID_POINTLIGHT: number;
  69646. /**
  69647. * Light type const id of the directional light.
  69648. */
  69649. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  69650. /**
  69651. * Light type const id of the spot light.
  69652. */
  69653. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  69654. /**
  69655. * Light type const id of the hemispheric light.
  69656. */
  69657. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  69658. /**
  69659. * Diffuse gives the basic color to an object.
  69660. */
  69661. diffuse: Color3;
  69662. /**
  69663. * Specular produces a highlight color on an object.
  69664. * Note: This is note affecting PBR materials.
  69665. */
  69666. specular: Color3;
  69667. /**
  69668. * Defines the falloff type for this light. This lets overrriding how punctual light are
  69669. * falling off base on range or angle.
  69670. * This can be set to any values in Light.FALLOFF_x.
  69671. *
  69672. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  69673. * other types of materials.
  69674. */
  69675. falloffType: number;
  69676. /**
  69677. * Strength of the light.
  69678. * Note: By default it is define in the framework own unit.
  69679. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  69680. */
  69681. intensity: number;
  69682. private _range;
  69683. protected _inverseSquaredRange: number;
  69684. /**
  69685. * Defines how far from the source the light is impacting in scene units.
  69686. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69687. */
  69688. /**
  69689. * Defines how far from the source the light is impacting in scene units.
  69690. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  69691. */
  69692. range: number;
  69693. /**
  69694. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  69695. * of light.
  69696. */
  69697. private _photometricScale;
  69698. private _intensityMode;
  69699. /**
  69700. * Gets the photometric scale used to interpret the intensity.
  69701. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69702. */
  69703. /**
  69704. * Sets the photometric scale used to interpret the intensity.
  69705. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  69706. */
  69707. intensityMode: number;
  69708. private _radius;
  69709. /**
  69710. * Gets the light radius used by PBR Materials to simulate soft area lights.
  69711. */
  69712. /**
  69713. * sets the light radius used by PBR Materials to simulate soft area lights.
  69714. */
  69715. radius: number;
  69716. private _renderPriority;
  69717. /**
  69718. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  69719. * exceeding the number allowed of the materials.
  69720. */
  69721. renderPriority: number;
  69722. private _shadowEnabled;
  69723. /**
  69724. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69725. * the current shadow generator.
  69726. */
  69727. /**
  69728. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  69729. * the current shadow generator.
  69730. */
  69731. shadowEnabled: boolean;
  69732. private _includedOnlyMeshes;
  69733. /**
  69734. * Gets the only meshes impacted by this light.
  69735. */
  69736. /**
  69737. * Sets the only meshes impacted by this light.
  69738. */
  69739. includedOnlyMeshes: AbstractMesh[];
  69740. private _excludedMeshes;
  69741. /**
  69742. * Gets the meshes not impacted by this light.
  69743. */
  69744. /**
  69745. * Sets the meshes not impacted by this light.
  69746. */
  69747. excludedMeshes: AbstractMesh[];
  69748. private _excludeWithLayerMask;
  69749. /**
  69750. * Gets the layer id use to find what meshes are not impacted by the light.
  69751. * Inactive if 0
  69752. */
  69753. /**
  69754. * Sets the layer id use to find what meshes are not impacted by the light.
  69755. * Inactive if 0
  69756. */
  69757. excludeWithLayerMask: number;
  69758. private _includeOnlyWithLayerMask;
  69759. /**
  69760. * Gets the layer id use to find what meshes are impacted by the light.
  69761. * Inactive if 0
  69762. */
  69763. /**
  69764. * Sets the layer id use to find what meshes are impacted by the light.
  69765. * Inactive if 0
  69766. */
  69767. includeOnlyWithLayerMask: number;
  69768. private _lightmapMode;
  69769. /**
  69770. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69771. */
  69772. /**
  69773. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  69774. */
  69775. lightmapMode: number;
  69776. /**
  69777. * Shadow generator associted to the light.
  69778. * @hidden Internal use only.
  69779. */
  69780. _shadowGenerator: Nullable<IShadowGenerator>;
  69781. /**
  69782. * @hidden Internal use only.
  69783. */
  69784. _excludedMeshesIds: string[];
  69785. /**
  69786. * @hidden Internal use only.
  69787. */
  69788. _includedOnlyMeshesIds: string[];
  69789. /**
  69790. * The current light unifom buffer.
  69791. * @hidden Internal use only.
  69792. */
  69793. _uniformBuffer: UniformBuffer;
  69794. /**
  69795. * Creates a Light object in the scene.
  69796. * Documentation : https://doc.babylonjs.com/babylon101/lights
  69797. * @param name The firendly name of the light
  69798. * @param scene The scene the light belongs too
  69799. */
  69800. constructor(name: string, scene: Scene);
  69801. protected abstract _buildUniformLayout(): void;
  69802. /**
  69803. * Sets the passed Effect "effect" with the Light information.
  69804. * @param effect The effect to update
  69805. * @param lightIndex The index of the light in the effect to update
  69806. * @returns The light
  69807. */
  69808. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  69809. /**
  69810. * Returns the string "Light".
  69811. * @returns the class name
  69812. */
  69813. getClassName(): string;
  69814. /** @hidden */
  69815. readonly _isLight: boolean;
  69816. /**
  69817. * Converts the light information to a readable string for debug purpose.
  69818. * @param fullDetails Supports for multiple levels of logging within scene loading
  69819. * @returns the human readable light info
  69820. */
  69821. toString(fullDetails?: boolean): string;
  69822. /** @hidden */
  69823. protected _syncParentEnabledState(): void;
  69824. /**
  69825. * Set the enabled state of this node.
  69826. * @param value - the new enabled state
  69827. */
  69828. setEnabled(value: boolean): void;
  69829. /**
  69830. * Returns the Light associated shadow generator if any.
  69831. * @return the associated shadow generator.
  69832. */
  69833. getShadowGenerator(): Nullable<IShadowGenerator>;
  69834. /**
  69835. * Returns a Vector3, the absolute light position in the World.
  69836. * @returns the world space position of the light
  69837. */
  69838. getAbsolutePosition(): Vector3;
  69839. /**
  69840. * Specifies if the light will affect the passed mesh.
  69841. * @param mesh The mesh to test against the light
  69842. * @return true the mesh is affected otherwise, false.
  69843. */
  69844. canAffectMesh(mesh: AbstractMesh): boolean;
  69845. /**
  69846. * Sort function to order lights for rendering.
  69847. * @param a First Light object to compare to second.
  69848. * @param b Second Light object to compare first.
  69849. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  69850. */
  69851. static CompareLightsPriority(a: Light, b: Light): number;
  69852. /**
  69853. * Releases resources associated with this node.
  69854. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  69855. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  69856. */
  69857. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  69858. /**
  69859. * Returns the light type ID (integer).
  69860. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  69861. */
  69862. getTypeID(): number;
  69863. /**
  69864. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  69865. * @returns the scaled intensity in intensity mode unit
  69866. */
  69867. getScaledIntensity(): number;
  69868. /**
  69869. * Returns a new Light object, named "name", from the current one.
  69870. * @param name The name of the cloned light
  69871. * @returns the new created light
  69872. */
  69873. clone(name: string): Nullable<Light>;
  69874. /**
  69875. * Serializes the current light into a Serialization object.
  69876. * @returns the serialized object.
  69877. */
  69878. serialize(): any;
  69879. /**
  69880. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  69881. * This new light is named "name" and added to the passed scene.
  69882. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  69883. * @param name The friendly name of the light
  69884. * @param scene The scene the new light will belong to
  69885. * @returns the constructor function
  69886. */
  69887. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  69888. /**
  69889. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  69890. * @param parsedLight The JSON representation of the light
  69891. * @param scene The scene to create the parsed light in
  69892. * @returns the created light after parsing
  69893. */
  69894. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  69895. private _hookArrayForExcluded;
  69896. private _hookArrayForIncludedOnly;
  69897. private _resyncMeshes;
  69898. /**
  69899. * Forces the meshes to update their light related information in their rendering used effects
  69900. * @hidden Internal Use Only
  69901. */
  69902. _markMeshesAsLightDirty(): void;
  69903. /**
  69904. * Recomputes the cached photometric scale if needed.
  69905. */
  69906. private _computePhotometricScale;
  69907. /**
  69908. * Returns the Photometric Scale according to the light type and intensity mode.
  69909. */
  69910. private _getPhotometricScale;
  69911. /**
  69912. * Reorder the light in the scene according to their defined priority.
  69913. * @hidden Internal Use Only
  69914. */
  69915. _reorderLightsInScene(): void;
  69916. /**
  69917. * Prepares the list of defines specific to the light type.
  69918. * @param defines the list of defines
  69919. * @param lightIndex defines the index of the light for the effect
  69920. */
  69921. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  69922. }
  69923. }
  69924. declare module BABYLON {
  69925. /**
  69926. * Interface used to define Action
  69927. */
  69928. export interface IAction {
  69929. /**
  69930. * Trigger for the action
  69931. */
  69932. trigger: number;
  69933. /** Options of the trigger */
  69934. triggerOptions: any;
  69935. /**
  69936. * Gets the trigger parameters
  69937. * @returns the trigger parameters
  69938. */
  69939. getTriggerParameter(): any;
  69940. /**
  69941. * Internal only - executes current action event
  69942. * @hidden
  69943. */
  69944. _executeCurrent(evt?: ActionEvent): void;
  69945. /**
  69946. * Serialize placeholder for child classes
  69947. * @param parent of child
  69948. * @returns the serialized object
  69949. */
  69950. serialize(parent: any): any;
  69951. /**
  69952. * Internal only
  69953. * @hidden
  69954. */
  69955. _prepare(): void;
  69956. /**
  69957. * Internal only - manager for action
  69958. * @hidden
  69959. */
  69960. _actionManager: AbstractActionManager;
  69961. }
  69962. /**
  69963. * The action to be carried out following a trigger
  69964. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  69965. */
  69966. export class Action implements IAction {
  69967. /** the trigger, with or without parameters, for the action */
  69968. triggerOptions: any;
  69969. /**
  69970. * Trigger for the action
  69971. */
  69972. trigger: number;
  69973. /**
  69974. * Internal only - manager for action
  69975. * @hidden
  69976. */
  69977. _actionManager: ActionManager;
  69978. private _nextActiveAction;
  69979. private _child;
  69980. private _condition?;
  69981. private _triggerParameter;
  69982. /**
  69983. * An event triggered prior to action being executed.
  69984. */
  69985. onBeforeExecuteObservable: Observable<Action>;
  69986. /**
  69987. * Creates a new Action
  69988. * @param triggerOptions the trigger, with or without parameters, for the action
  69989. * @param condition an optional determinant of action
  69990. */
  69991. constructor(
  69992. /** the trigger, with or without parameters, for the action */
  69993. triggerOptions: any, condition?: Condition);
  69994. /**
  69995. * Internal only
  69996. * @hidden
  69997. */
  69998. _prepare(): void;
  69999. /**
  70000. * Gets the trigger parameters
  70001. * @returns the trigger parameters
  70002. */
  70003. getTriggerParameter(): any;
  70004. /**
  70005. * Internal only - executes current action event
  70006. * @hidden
  70007. */
  70008. _executeCurrent(evt?: ActionEvent): void;
  70009. /**
  70010. * Execute placeholder for child classes
  70011. * @param evt optional action event
  70012. */
  70013. execute(evt?: ActionEvent): void;
  70014. /**
  70015. * Skips to next active action
  70016. */
  70017. skipToNextActiveAction(): void;
  70018. /**
  70019. * Adds action to chain of actions, may be a DoNothingAction
  70020. * @param action defines the next action to execute
  70021. * @returns The action passed in
  70022. * @see https://www.babylonjs-playground.com/#1T30HR#0
  70023. */
  70024. then(action: Action): Action;
  70025. /**
  70026. * Internal only
  70027. * @hidden
  70028. */
  70029. _getProperty(propertyPath: string): string;
  70030. /**
  70031. * Internal only
  70032. * @hidden
  70033. */
  70034. _getEffectiveTarget(target: any, propertyPath: string): any;
  70035. /**
  70036. * Serialize placeholder for child classes
  70037. * @param parent of child
  70038. * @returns the serialized object
  70039. */
  70040. serialize(parent: any): any;
  70041. /**
  70042. * Internal only called by serialize
  70043. * @hidden
  70044. */
  70045. protected _serialize(serializedAction: any, parent?: any): any;
  70046. /**
  70047. * Internal only
  70048. * @hidden
  70049. */
  70050. static _SerializeValueAsString: (value: any) => string;
  70051. /**
  70052. * Internal only
  70053. * @hidden
  70054. */
  70055. static _GetTargetProperty: (target: Scene | Node) => {
  70056. name: string;
  70057. targetType: string;
  70058. value: string;
  70059. };
  70060. }
  70061. }
  70062. declare module BABYLON {
  70063. /**
  70064. * A Condition applied to an Action
  70065. */
  70066. export class Condition {
  70067. /**
  70068. * Internal only - manager for action
  70069. * @hidden
  70070. */
  70071. _actionManager: ActionManager;
  70072. /**
  70073. * Internal only
  70074. * @hidden
  70075. */
  70076. _evaluationId: number;
  70077. /**
  70078. * Internal only
  70079. * @hidden
  70080. */
  70081. _currentResult: boolean;
  70082. /**
  70083. * Creates a new Condition
  70084. * @param actionManager the manager of the action the condition is applied to
  70085. */
  70086. constructor(actionManager: ActionManager);
  70087. /**
  70088. * Check if the current condition is valid
  70089. * @returns a boolean
  70090. */
  70091. isValid(): boolean;
  70092. /**
  70093. * Internal only
  70094. * @hidden
  70095. */
  70096. _getProperty(propertyPath: string): string;
  70097. /**
  70098. * Internal only
  70099. * @hidden
  70100. */
  70101. _getEffectiveTarget(target: any, propertyPath: string): any;
  70102. /**
  70103. * Serialize placeholder for child classes
  70104. * @returns the serialized object
  70105. */
  70106. serialize(): any;
  70107. /**
  70108. * Internal only
  70109. * @hidden
  70110. */
  70111. protected _serialize(serializedCondition: any): any;
  70112. }
  70113. /**
  70114. * Defines specific conditional operators as extensions of Condition
  70115. */
  70116. export class ValueCondition extends Condition {
  70117. /** path to specify the property of the target the conditional operator uses */
  70118. propertyPath: string;
  70119. /** the value compared by the conditional operator against the current value of the property */
  70120. value: any;
  70121. /** the conditional operator, default ValueCondition.IsEqual */
  70122. operator: number;
  70123. /**
  70124. * Internal only
  70125. * @hidden
  70126. */
  70127. private static _IsEqual;
  70128. /**
  70129. * Internal only
  70130. * @hidden
  70131. */
  70132. private static _IsDifferent;
  70133. /**
  70134. * Internal only
  70135. * @hidden
  70136. */
  70137. private static _IsGreater;
  70138. /**
  70139. * Internal only
  70140. * @hidden
  70141. */
  70142. private static _IsLesser;
  70143. /**
  70144. * returns the number for IsEqual
  70145. */
  70146. static readonly IsEqual: number;
  70147. /**
  70148. * Returns the number for IsDifferent
  70149. */
  70150. static readonly IsDifferent: number;
  70151. /**
  70152. * Returns the number for IsGreater
  70153. */
  70154. static readonly IsGreater: number;
  70155. /**
  70156. * Returns the number for IsLesser
  70157. */
  70158. static readonly IsLesser: number;
  70159. /**
  70160. * Internal only The action manager for the condition
  70161. * @hidden
  70162. */
  70163. _actionManager: ActionManager;
  70164. /**
  70165. * Internal only
  70166. * @hidden
  70167. */
  70168. private _target;
  70169. /**
  70170. * Internal only
  70171. * @hidden
  70172. */
  70173. private _effectiveTarget;
  70174. /**
  70175. * Internal only
  70176. * @hidden
  70177. */
  70178. private _property;
  70179. /**
  70180. * Creates a new ValueCondition
  70181. * @param actionManager manager for the action the condition applies to
  70182. * @param target for the action
  70183. * @param propertyPath path to specify the property of the target the conditional operator uses
  70184. * @param value the value compared by the conditional operator against the current value of the property
  70185. * @param operator the conditional operator, default ValueCondition.IsEqual
  70186. */
  70187. constructor(actionManager: ActionManager, target: any,
  70188. /** path to specify the property of the target the conditional operator uses */
  70189. propertyPath: string,
  70190. /** the value compared by the conditional operator against the current value of the property */
  70191. value: any,
  70192. /** the conditional operator, default ValueCondition.IsEqual */
  70193. operator?: number);
  70194. /**
  70195. * Compares the given value with the property value for the specified conditional operator
  70196. * @returns the result of the comparison
  70197. */
  70198. isValid(): boolean;
  70199. /**
  70200. * Serialize the ValueCondition into a JSON compatible object
  70201. * @returns serialization object
  70202. */
  70203. serialize(): any;
  70204. /**
  70205. * Gets the name of the conditional operator for the ValueCondition
  70206. * @param operator the conditional operator
  70207. * @returns the name
  70208. */
  70209. static GetOperatorName(operator: number): string;
  70210. }
  70211. /**
  70212. * Defines a predicate condition as an extension of Condition
  70213. */
  70214. export class PredicateCondition extends Condition {
  70215. /** defines the predicate function used to validate the condition */
  70216. predicate: () => boolean;
  70217. /**
  70218. * Internal only - manager for action
  70219. * @hidden
  70220. */
  70221. _actionManager: ActionManager;
  70222. /**
  70223. * Creates a new PredicateCondition
  70224. * @param actionManager manager for the action the condition applies to
  70225. * @param predicate defines the predicate function used to validate the condition
  70226. */
  70227. constructor(actionManager: ActionManager,
  70228. /** defines the predicate function used to validate the condition */
  70229. predicate: () => boolean);
  70230. /**
  70231. * @returns the validity of the predicate condition
  70232. */
  70233. isValid(): boolean;
  70234. }
  70235. /**
  70236. * Defines a state condition as an extension of Condition
  70237. */
  70238. export class StateCondition extends Condition {
  70239. /** Value to compare with target state */
  70240. value: string;
  70241. /**
  70242. * Internal only - manager for action
  70243. * @hidden
  70244. */
  70245. _actionManager: ActionManager;
  70246. /**
  70247. * Internal only
  70248. * @hidden
  70249. */
  70250. private _target;
  70251. /**
  70252. * Creates a new StateCondition
  70253. * @param actionManager manager for the action the condition applies to
  70254. * @param target of the condition
  70255. * @param value to compare with target state
  70256. */
  70257. constructor(actionManager: ActionManager, target: any,
  70258. /** Value to compare with target state */
  70259. value: string);
  70260. /**
  70261. * Gets a boolean indicating if the current condition is met
  70262. * @returns the validity of the state
  70263. */
  70264. isValid(): boolean;
  70265. /**
  70266. * Serialize the StateCondition into a JSON compatible object
  70267. * @returns serialization object
  70268. */
  70269. serialize(): any;
  70270. }
  70271. }
  70272. declare module BABYLON {
  70273. /**
  70274. * This defines an action responsible to toggle a boolean once triggered.
  70275. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70276. */
  70277. export class SwitchBooleanAction extends Action {
  70278. /**
  70279. * The path to the boolean property in the target object
  70280. */
  70281. propertyPath: string;
  70282. private _target;
  70283. private _effectiveTarget;
  70284. private _property;
  70285. /**
  70286. * Instantiate the action
  70287. * @param triggerOptions defines the trigger options
  70288. * @param target defines the object containing the boolean
  70289. * @param propertyPath defines the path to the boolean property in the target object
  70290. * @param condition defines the trigger related conditions
  70291. */
  70292. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  70293. /** @hidden */
  70294. _prepare(): void;
  70295. /**
  70296. * Execute the action toggle the boolean value.
  70297. */
  70298. execute(): void;
  70299. /**
  70300. * Serializes the actions and its related information.
  70301. * @param parent defines the object to serialize in
  70302. * @returns the serialized object
  70303. */
  70304. serialize(parent: any): any;
  70305. }
  70306. /**
  70307. * This defines an action responsible to set a the state field of the target
  70308. * to a desired value once triggered.
  70309. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70310. */
  70311. export class SetStateAction extends Action {
  70312. /**
  70313. * The value to store in the state field.
  70314. */
  70315. value: string;
  70316. private _target;
  70317. /**
  70318. * Instantiate the action
  70319. * @param triggerOptions defines the trigger options
  70320. * @param target defines the object containing the state property
  70321. * @param value defines the value to store in the state field
  70322. * @param condition defines the trigger related conditions
  70323. */
  70324. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  70325. /**
  70326. * Execute the action and store the value on the target state property.
  70327. */
  70328. execute(): void;
  70329. /**
  70330. * Serializes the actions and its related information.
  70331. * @param parent defines the object to serialize in
  70332. * @returns the serialized object
  70333. */
  70334. serialize(parent: any): any;
  70335. }
  70336. /**
  70337. * This defines an action responsible to set a property of the target
  70338. * to a desired value once triggered.
  70339. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70340. */
  70341. export class SetValueAction extends Action {
  70342. /**
  70343. * The path of the property to set in the target.
  70344. */
  70345. propertyPath: string;
  70346. /**
  70347. * The value to set in the property
  70348. */
  70349. value: any;
  70350. private _target;
  70351. private _effectiveTarget;
  70352. private _property;
  70353. /**
  70354. * Instantiate the action
  70355. * @param triggerOptions defines the trigger options
  70356. * @param target defines the object containing the property
  70357. * @param propertyPath defines the path of the property to set in the target
  70358. * @param value defines the value to set in the property
  70359. * @param condition defines the trigger related conditions
  70360. */
  70361. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70362. /** @hidden */
  70363. _prepare(): void;
  70364. /**
  70365. * Execute the action and set the targetted property to the desired value.
  70366. */
  70367. execute(): void;
  70368. /**
  70369. * Serializes the actions and its related information.
  70370. * @param parent defines the object to serialize in
  70371. * @returns the serialized object
  70372. */
  70373. serialize(parent: any): any;
  70374. }
  70375. /**
  70376. * This defines an action responsible to increment the target value
  70377. * to a desired value once triggered.
  70378. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70379. */
  70380. export class IncrementValueAction extends Action {
  70381. /**
  70382. * The path of the property to increment in the target.
  70383. */
  70384. propertyPath: string;
  70385. /**
  70386. * The value we should increment the property by.
  70387. */
  70388. value: any;
  70389. private _target;
  70390. private _effectiveTarget;
  70391. private _property;
  70392. /**
  70393. * Instantiate the action
  70394. * @param triggerOptions defines the trigger options
  70395. * @param target defines the object containing the property
  70396. * @param propertyPath defines the path of the property to increment in the target
  70397. * @param value defines the value value we should increment the property by
  70398. * @param condition defines the trigger related conditions
  70399. */
  70400. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  70401. /** @hidden */
  70402. _prepare(): void;
  70403. /**
  70404. * Execute the action and increment the target of the value amount.
  70405. */
  70406. execute(): void;
  70407. /**
  70408. * Serializes the actions and its related information.
  70409. * @param parent defines the object to serialize in
  70410. * @returns the serialized object
  70411. */
  70412. serialize(parent: any): any;
  70413. }
  70414. /**
  70415. * This defines an action responsible to start an animation once triggered.
  70416. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70417. */
  70418. export class PlayAnimationAction extends Action {
  70419. /**
  70420. * Where the animation should start (animation frame)
  70421. */
  70422. from: number;
  70423. /**
  70424. * Where the animation should stop (animation frame)
  70425. */
  70426. to: number;
  70427. /**
  70428. * Define if the animation should loop or stop after the first play.
  70429. */
  70430. loop?: boolean;
  70431. private _target;
  70432. /**
  70433. * Instantiate the action
  70434. * @param triggerOptions defines the trigger options
  70435. * @param target defines the target animation or animation name
  70436. * @param from defines from where the animation should start (animation frame)
  70437. * @param end defines where the animation should stop (animation frame)
  70438. * @param loop defines if the animation should loop or stop after the first play
  70439. * @param condition defines the trigger related conditions
  70440. */
  70441. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  70442. /** @hidden */
  70443. _prepare(): void;
  70444. /**
  70445. * Execute the action and play the animation.
  70446. */
  70447. execute(): void;
  70448. /**
  70449. * Serializes the actions and its related information.
  70450. * @param parent defines the object to serialize in
  70451. * @returns the serialized object
  70452. */
  70453. serialize(parent: any): any;
  70454. }
  70455. /**
  70456. * This defines an action responsible to stop an animation once triggered.
  70457. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70458. */
  70459. export class StopAnimationAction extends Action {
  70460. private _target;
  70461. /**
  70462. * Instantiate the action
  70463. * @param triggerOptions defines the trigger options
  70464. * @param target defines the target animation or animation name
  70465. * @param condition defines the trigger related conditions
  70466. */
  70467. constructor(triggerOptions: any, target: any, condition?: Condition);
  70468. /** @hidden */
  70469. _prepare(): void;
  70470. /**
  70471. * Execute the action and stop the animation.
  70472. */
  70473. execute(): void;
  70474. /**
  70475. * Serializes the actions and its related information.
  70476. * @param parent defines the object to serialize in
  70477. * @returns the serialized object
  70478. */
  70479. serialize(parent: any): any;
  70480. }
  70481. /**
  70482. * This defines an action responsible that does nothing once triggered.
  70483. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70484. */
  70485. export class DoNothingAction extends Action {
  70486. /**
  70487. * Instantiate the action
  70488. * @param triggerOptions defines the trigger options
  70489. * @param condition defines the trigger related conditions
  70490. */
  70491. constructor(triggerOptions?: any, condition?: Condition);
  70492. /**
  70493. * Execute the action and do nothing.
  70494. */
  70495. execute(): void;
  70496. /**
  70497. * Serializes the actions and its related information.
  70498. * @param parent defines the object to serialize in
  70499. * @returns the serialized object
  70500. */
  70501. serialize(parent: any): any;
  70502. }
  70503. /**
  70504. * This defines an action responsible to trigger several actions once triggered.
  70505. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70506. */
  70507. export class CombineAction extends Action {
  70508. /**
  70509. * The list of aggregated animations to run.
  70510. */
  70511. children: Action[];
  70512. /**
  70513. * Instantiate the action
  70514. * @param triggerOptions defines the trigger options
  70515. * @param children defines the list of aggregated animations to run
  70516. * @param condition defines the trigger related conditions
  70517. */
  70518. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  70519. /** @hidden */
  70520. _prepare(): void;
  70521. /**
  70522. * Execute the action and executes all the aggregated actions.
  70523. */
  70524. execute(evt: ActionEvent): void;
  70525. /**
  70526. * Serializes the actions and its related information.
  70527. * @param parent defines the object to serialize in
  70528. * @returns the serialized object
  70529. */
  70530. serialize(parent: any): any;
  70531. }
  70532. /**
  70533. * This defines an action responsible to run code (external event) once triggered.
  70534. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70535. */
  70536. export class ExecuteCodeAction extends Action {
  70537. /**
  70538. * The callback function to run.
  70539. */
  70540. func: (evt: ActionEvent) => void;
  70541. /**
  70542. * Instantiate the action
  70543. * @param triggerOptions defines the trigger options
  70544. * @param func defines the callback function to run
  70545. * @param condition defines the trigger related conditions
  70546. */
  70547. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  70548. /**
  70549. * Execute the action and run the attached code.
  70550. */
  70551. execute(evt: ActionEvent): void;
  70552. }
  70553. /**
  70554. * This defines an action responsible to set the parent property of the target once triggered.
  70555. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70556. */
  70557. export class SetParentAction extends Action {
  70558. private _parent;
  70559. private _target;
  70560. /**
  70561. * Instantiate the action
  70562. * @param triggerOptions defines the trigger options
  70563. * @param target defines the target containing the parent property
  70564. * @param parent defines from where the animation should start (animation frame)
  70565. * @param condition defines the trigger related conditions
  70566. */
  70567. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  70568. /** @hidden */
  70569. _prepare(): void;
  70570. /**
  70571. * Execute the action and set the parent property.
  70572. */
  70573. execute(): void;
  70574. /**
  70575. * Serializes the actions and its related information.
  70576. * @param parent defines the object to serialize in
  70577. * @returns the serialized object
  70578. */
  70579. serialize(parent: any): any;
  70580. }
  70581. }
  70582. declare module BABYLON {
  70583. /**
  70584. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  70585. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  70586. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  70587. */
  70588. export class ActionManager extends AbstractActionManager {
  70589. /**
  70590. * Nothing
  70591. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70592. */
  70593. static readonly NothingTrigger: number;
  70594. /**
  70595. * On pick
  70596. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70597. */
  70598. static readonly OnPickTrigger: number;
  70599. /**
  70600. * On left pick
  70601. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70602. */
  70603. static readonly OnLeftPickTrigger: number;
  70604. /**
  70605. * On right pick
  70606. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70607. */
  70608. static readonly OnRightPickTrigger: number;
  70609. /**
  70610. * On center pick
  70611. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70612. */
  70613. static readonly OnCenterPickTrigger: number;
  70614. /**
  70615. * On pick down
  70616. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70617. */
  70618. static readonly OnPickDownTrigger: number;
  70619. /**
  70620. * On double pick
  70621. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70622. */
  70623. static readonly OnDoublePickTrigger: number;
  70624. /**
  70625. * On pick up
  70626. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70627. */
  70628. static readonly OnPickUpTrigger: number;
  70629. /**
  70630. * On pick out.
  70631. * This trigger will only be raised if you also declared a OnPickDown
  70632. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70633. */
  70634. static readonly OnPickOutTrigger: number;
  70635. /**
  70636. * On long press
  70637. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70638. */
  70639. static readonly OnLongPressTrigger: number;
  70640. /**
  70641. * On pointer over
  70642. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70643. */
  70644. static readonly OnPointerOverTrigger: number;
  70645. /**
  70646. * On pointer out
  70647. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70648. */
  70649. static readonly OnPointerOutTrigger: number;
  70650. /**
  70651. * On every frame
  70652. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70653. */
  70654. static readonly OnEveryFrameTrigger: number;
  70655. /**
  70656. * On intersection enter
  70657. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70658. */
  70659. static readonly OnIntersectionEnterTrigger: number;
  70660. /**
  70661. * On intersection exit
  70662. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70663. */
  70664. static readonly OnIntersectionExitTrigger: number;
  70665. /**
  70666. * On key down
  70667. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70668. */
  70669. static readonly OnKeyDownTrigger: number;
  70670. /**
  70671. * On key up
  70672. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  70673. */
  70674. static readonly OnKeyUpTrigger: number;
  70675. private _scene;
  70676. /**
  70677. * Creates a new action manager
  70678. * @param scene defines the hosting scene
  70679. */
  70680. constructor(scene: Scene);
  70681. /**
  70682. * Releases all associated resources
  70683. */
  70684. dispose(): void;
  70685. /**
  70686. * Gets hosting scene
  70687. * @returns the hosting scene
  70688. */
  70689. getScene(): Scene;
  70690. /**
  70691. * Does this action manager handles actions of any of the given triggers
  70692. * @param triggers defines the triggers to be tested
  70693. * @return a boolean indicating whether one (or more) of the triggers is handled
  70694. */
  70695. hasSpecificTriggers(triggers: number[]): boolean;
  70696. /**
  70697. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  70698. * speed.
  70699. * @param triggerA defines the trigger to be tested
  70700. * @param triggerB defines the trigger to be tested
  70701. * @return a boolean indicating whether one (or more) of the triggers is handled
  70702. */
  70703. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  70704. /**
  70705. * Does this action manager handles actions of a given trigger
  70706. * @param trigger defines the trigger to be tested
  70707. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  70708. * @return whether the trigger is handled
  70709. */
  70710. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  70711. /**
  70712. * Does this action manager has pointer triggers
  70713. */
  70714. readonly hasPointerTriggers: boolean;
  70715. /**
  70716. * Does this action manager has pick triggers
  70717. */
  70718. readonly hasPickTriggers: boolean;
  70719. /**
  70720. * Registers an action to this action manager
  70721. * @param action defines the action to be registered
  70722. * @return the action amended (prepared) after registration
  70723. */
  70724. registerAction(action: IAction): Nullable<IAction>;
  70725. /**
  70726. * Unregisters an action to this action manager
  70727. * @param action defines the action to be unregistered
  70728. * @return a boolean indicating whether the action has been unregistered
  70729. */
  70730. unregisterAction(action: IAction): Boolean;
  70731. /**
  70732. * Process a specific trigger
  70733. * @param trigger defines the trigger to process
  70734. * @param evt defines the event details to be processed
  70735. */
  70736. processTrigger(trigger: number, evt?: IActionEvent): void;
  70737. /** @hidden */
  70738. _getEffectiveTarget(target: any, propertyPath: string): any;
  70739. /** @hidden */
  70740. _getProperty(propertyPath: string): string;
  70741. /**
  70742. * Serialize this manager to a JSON object
  70743. * @param name defines the property name to store this manager
  70744. * @returns a JSON representation of this manager
  70745. */
  70746. serialize(name: string): any;
  70747. /**
  70748. * Creates a new ActionManager from a JSON data
  70749. * @param parsedActions defines the JSON data to read from
  70750. * @param object defines the hosting mesh
  70751. * @param scene defines the hosting scene
  70752. */
  70753. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  70754. /**
  70755. * Get a trigger name by index
  70756. * @param trigger defines the trigger index
  70757. * @returns a trigger name
  70758. */
  70759. static GetTriggerName(trigger: number): string;
  70760. }
  70761. }
  70762. declare module BABYLON {
  70763. /**
  70764. * Class representing a ray with position and direction
  70765. */
  70766. export class Ray {
  70767. /** origin point */
  70768. origin: Vector3;
  70769. /** direction */
  70770. direction: Vector3;
  70771. /** length of the ray */
  70772. length: number;
  70773. private static readonly TmpVector3;
  70774. private _tmpRay;
  70775. /**
  70776. * Creates a new ray
  70777. * @param origin origin point
  70778. * @param direction direction
  70779. * @param length length of the ray
  70780. */
  70781. constructor(
  70782. /** origin point */
  70783. origin: Vector3,
  70784. /** direction */
  70785. direction: Vector3,
  70786. /** length of the ray */
  70787. length?: number);
  70788. /**
  70789. * Checks if the ray intersects a box
  70790. * @param minimum bound of the box
  70791. * @param maximum bound of the box
  70792. * @param intersectionTreshold extra extend to be added to the box in all direction
  70793. * @returns if the box was hit
  70794. */
  70795. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  70796. /**
  70797. * Checks if the ray intersects a box
  70798. * @param box the bounding box to check
  70799. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  70800. * @returns if the box was hit
  70801. */
  70802. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  70803. /**
  70804. * If the ray hits a sphere
  70805. * @param sphere the bounding sphere to check
  70806. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  70807. * @returns true if it hits the sphere
  70808. */
  70809. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  70810. /**
  70811. * If the ray hits a triange
  70812. * @param vertex0 triangle vertex
  70813. * @param vertex1 triangle vertex
  70814. * @param vertex2 triangle vertex
  70815. * @returns intersection information if hit
  70816. */
  70817. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  70818. /**
  70819. * Checks if ray intersects a plane
  70820. * @param plane the plane to check
  70821. * @returns the distance away it was hit
  70822. */
  70823. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  70824. /**
  70825. * Checks if ray intersects a mesh
  70826. * @param mesh the mesh to check
  70827. * @param fastCheck if only the bounding box should checked
  70828. * @returns picking info of the intersecton
  70829. */
  70830. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  70831. /**
  70832. * Checks if ray intersects a mesh
  70833. * @param meshes the meshes to check
  70834. * @param fastCheck if only the bounding box should checked
  70835. * @param results array to store result in
  70836. * @returns Array of picking infos
  70837. */
  70838. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  70839. private _comparePickingInfo;
  70840. private static smallnum;
  70841. private static rayl;
  70842. /**
  70843. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  70844. * @param sega the first point of the segment to test the intersection against
  70845. * @param segb the second point of the segment to test the intersection against
  70846. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  70847. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  70848. */
  70849. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  70850. /**
  70851. * Update the ray from viewport position
  70852. * @param x position
  70853. * @param y y position
  70854. * @param viewportWidth viewport width
  70855. * @param viewportHeight viewport height
  70856. * @param world world matrix
  70857. * @param view view matrix
  70858. * @param projection projection matrix
  70859. * @returns this ray updated
  70860. */
  70861. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70862. /**
  70863. * Creates a ray with origin and direction of 0,0,0
  70864. * @returns the new ray
  70865. */
  70866. static Zero(): Ray;
  70867. /**
  70868. * Creates a new ray from screen space and viewport
  70869. * @param x position
  70870. * @param y y position
  70871. * @param viewportWidth viewport width
  70872. * @param viewportHeight viewport height
  70873. * @param world world matrix
  70874. * @param view view matrix
  70875. * @param projection projection matrix
  70876. * @returns new ray
  70877. */
  70878. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  70879. /**
  70880. * 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
  70881. * transformed to the given world matrix.
  70882. * @param origin The origin point
  70883. * @param end The end point
  70884. * @param world a matrix to transform the ray to. Default is the identity matrix.
  70885. * @returns the new ray
  70886. */
  70887. static CreateNewFromTo(origin: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, world?: DeepImmutable<Matrix>): Ray;
  70888. /**
  70889. * Transforms a ray by a matrix
  70890. * @param ray ray to transform
  70891. * @param matrix matrix to apply
  70892. * @returns the resulting new ray
  70893. */
  70894. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  70895. /**
  70896. * Transforms a ray by a matrix
  70897. * @param ray ray to transform
  70898. * @param matrix matrix to apply
  70899. * @param result ray to store result in
  70900. */
  70901. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  70902. /**
  70903. * Unproject a ray from screen space to object space
  70904. * @param sourceX defines the screen space x coordinate to use
  70905. * @param sourceY defines the screen space y coordinate to use
  70906. * @param viewportWidth defines the current width of the viewport
  70907. * @param viewportHeight defines the current height of the viewport
  70908. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70909. * @param view defines the view matrix to use
  70910. * @param projection defines the projection matrix to use
  70911. */
  70912. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  70913. }
  70914. /**
  70915. * Type used to define predicate used to select faces when a mesh intersection is detected
  70916. */
  70917. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  70918. interface Scene {
  70919. /** @hidden */
  70920. _tempPickingRay: Nullable<Ray>;
  70921. /** @hidden */
  70922. _cachedRayForTransform: Ray;
  70923. /** @hidden */
  70924. _pickWithRayInverseMatrix: Matrix;
  70925. /** @hidden */
  70926. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  70927. /** @hidden */
  70928. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  70929. }
  70930. }
  70931. declare module BABYLON {
  70932. /**
  70933. * Groups all the scene component constants in one place to ease maintenance.
  70934. * @hidden
  70935. */
  70936. export class SceneComponentConstants {
  70937. static readonly NAME_EFFECTLAYER: string;
  70938. static readonly NAME_LAYER: string;
  70939. static readonly NAME_LENSFLARESYSTEM: string;
  70940. static readonly NAME_BOUNDINGBOXRENDERER: string;
  70941. static readonly NAME_PARTICLESYSTEM: string;
  70942. static readonly NAME_GAMEPAD: string;
  70943. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  70944. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  70945. static readonly NAME_DEPTHRENDERER: string;
  70946. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  70947. static readonly NAME_SPRITE: string;
  70948. static readonly NAME_OUTLINERENDERER: string;
  70949. static readonly NAME_PROCEDURALTEXTURE: string;
  70950. static readonly NAME_SHADOWGENERATOR: string;
  70951. static readonly NAME_OCTREE: string;
  70952. static readonly NAME_PHYSICSENGINE: string;
  70953. static readonly NAME_AUDIO: string;
  70954. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  70955. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70956. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  70957. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  70958. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  70959. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  70960. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  70961. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  70962. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  70963. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  70964. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  70965. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  70966. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  70967. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  70968. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  70969. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  70970. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  70971. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  70972. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  70973. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  70974. static readonly STEP_AFTERRENDER_AUDIO: number;
  70975. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  70976. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  70977. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  70978. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  70979. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  70980. static readonly STEP_POINTERMOVE_SPRITE: number;
  70981. static readonly STEP_POINTERDOWN_SPRITE: number;
  70982. static readonly STEP_POINTERUP_SPRITE: number;
  70983. }
  70984. /**
  70985. * This represents a scene component.
  70986. *
  70987. * This is used to decouple the dependency the scene is having on the different workloads like
  70988. * layers, post processes...
  70989. */
  70990. export interface ISceneComponent {
  70991. /**
  70992. * The name of the component. Each component must have a unique name.
  70993. */
  70994. name: string;
  70995. /**
  70996. * The scene the component belongs to.
  70997. */
  70998. scene: Scene;
  70999. /**
  71000. * Register the component to one instance of a scene.
  71001. */
  71002. register(): void;
  71003. /**
  71004. * Rebuilds the elements related to this component in case of
  71005. * context lost for instance.
  71006. */
  71007. rebuild(): void;
  71008. /**
  71009. * Disposes the component and the associated ressources.
  71010. */
  71011. dispose(): void;
  71012. }
  71013. /**
  71014. * This represents a SERIALIZABLE scene component.
  71015. *
  71016. * This extends Scene Component to add Serialization methods on top.
  71017. */
  71018. export interface ISceneSerializableComponent extends ISceneComponent {
  71019. /**
  71020. * Adds all the element from the container to the scene
  71021. * @param container the container holding the elements
  71022. */
  71023. addFromContainer(container: AbstractScene): void;
  71024. /**
  71025. * Removes all the elements in the container from the scene
  71026. * @param container contains the elements to remove
  71027. * @param dispose if the removed element should be disposed (default: false)
  71028. */
  71029. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  71030. /**
  71031. * Serializes the component data to the specified json object
  71032. * @param serializationObject The object to serialize to
  71033. */
  71034. serialize(serializationObject: any): void;
  71035. }
  71036. /**
  71037. * Strong typing of a Mesh related stage step action
  71038. */
  71039. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  71040. /**
  71041. * Strong typing of a Evaluate Sub Mesh related stage step action
  71042. */
  71043. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  71044. /**
  71045. * Strong typing of a Active Mesh related stage step action
  71046. */
  71047. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  71048. /**
  71049. * Strong typing of a Camera related stage step action
  71050. */
  71051. export type CameraStageAction = (camera: Camera) => void;
  71052. /**
  71053. * Strong typing of a Camera Frame buffer related stage step action
  71054. */
  71055. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  71056. /**
  71057. * Strong typing of a Render Target related stage step action
  71058. */
  71059. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  71060. /**
  71061. * Strong typing of a RenderingGroup related stage step action
  71062. */
  71063. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  71064. /**
  71065. * Strong typing of a Mesh Render related stage step action
  71066. */
  71067. export type RenderingMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  71068. /**
  71069. * Strong typing of a simple stage step action
  71070. */
  71071. export type SimpleStageAction = () => void;
  71072. /**
  71073. * Strong typing of a render target action.
  71074. */
  71075. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  71076. /**
  71077. * Strong typing of a pointer move action.
  71078. */
  71079. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, canvas: HTMLCanvasElement) => Nullable<PickingInfo>;
  71080. /**
  71081. * Strong typing of a pointer up/down action.
  71082. */
  71083. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  71084. /**
  71085. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  71086. * @hidden
  71087. */
  71088. export class Stage<T extends Function> extends Array<{
  71089. index: number;
  71090. component: ISceneComponent;
  71091. action: T;
  71092. }> {
  71093. /**
  71094. * Hide ctor from the rest of the world.
  71095. * @param items The items to add.
  71096. */
  71097. private constructor();
  71098. /**
  71099. * Creates a new Stage.
  71100. * @returns A new instance of a Stage
  71101. */
  71102. static Create<T extends Function>(): Stage<T>;
  71103. /**
  71104. * Registers a step in an ordered way in the targeted stage.
  71105. * @param index Defines the position to register the step in
  71106. * @param component Defines the component attached to the step
  71107. * @param action Defines the action to launch during the step
  71108. */
  71109. registerStep(index: number, component: ISceneComponent, action: T): void;
  71110. /**
  71111. * Clears all the steps from the stage.
  71112. */
  71113. clear(): void;
  71114. }
  71115. }
  71116. declare module BABYLON {
  71117. interface Scene {
  71118. /** @hidden */
  71119. _pointerOverSprite: Nullable<Sprite>;
  71120. /** @hidden */
  71121. _pickedDownSprite: Nullable<Sprite>;
  71122. /** @hidden */
  71123. _tempSpritePickingRay: Nullable<Ray>;
  71124. /**
  71125. * All of the sprite managers added to this scene
  71126. * @see http://doc.babylonjs.com/babylon101/sprites
  71127. */
  71128. spriteManagers: Array<ISpriteManager>;
  71129. /**
  71130. * An event triggered when sprites rendering is about to start
  71131. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71132. */
  71133. onBeforeSpritesRenderingObservable: Observable<Scene>;
  71134. /**
  71135. * An event triggered when sprites rendering is done
  71136. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  71137. */
  71138. onAfterSpritesRenderingObservable: Observable<Scene>;
  71139. /** @hidden */
  71140. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71141. /** Launch a ray to try to pick a sprite in the scene
  71142. * @param x position on screen
  71143. * @param y position on screen
  71144. * @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
  71145. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71146. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  71147. * @returns a PickingInfo
  71148. */
  71149. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71150. /** Use the given ray to pick a sprite in the scene
  71151. * @param ray The ray (in world space) to use to pick meshes
  71152. * @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
  71153. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  71154. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  71155. * @returns a PickingInfo
  71156. */
  71157. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  71158. /**
  71159. * Force the sprite under the pointer
  71160. * @param sprite defines the sprite to use
  71161. */
  71162. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  71163. /**
  71164. * Gets the sprite under the pointer
  71165. * @returns a Sprite or null if no sprite is under the pointer
  71166. */
  71167. getPointerOverSprite(): Nullable<Sprite>;
  71168. }
  71169. /**
  71170. * Defines the sprite scene component responsible to manage sprites
  71171. * in a given scene.
  71172. */
  71173. export class SpriteSceneComponent implements ISceneComponent {
  71174. /**
  71175. * The component name helpfull to identify the component in the list of scene components.
  71176. */
  71177. readonly name: string;
  71178. /**
  71179. * The scene the component belongs to.
  71180. */
  71181. scene: Scene;
  71182. /** @hidden */
  71183. private _spritePredicate;
  71184. /**
  71185. * Creates a new instance of the component for the given scene
  71186. * @param scene Defines the scene to register the component in
  71187. */
  71188. constructor(scene: Scene);
  71189. /**
  71190. * Registers the component in a given scene
  71191. */
  71192. register(): void;
  71193. /**
  71194. * Rebuilds the elements related to this component in case of
  71195. * context lost for instance.
  71196. */
  71197. rebuild(): void;
  71198. /**
  71199. * Disposes the component and the associated ressources.
  71200. */
  71201. dispose(): void;
  71202. private _pickSpriteButKeepRay;
  71203. private _pointerMove;
  71204. private _pointerDown;
  71205. private _pointerUp;
  71206. }
  71207. }
  71208. declare module BABYLON {
  71209. /** @hidden */
  71210. export var fogFragmentDeclaration: {
  71211. name: string;
  71212. shader: string;
  71213. };
  71214. }
  71215. declare module BABYLON {
  71216. /** @hidden */
  71217. export var fogFragment: {
  71218. name: string;
  71219. shader: string;
  71220. };
  71221. }
  71222. declare module BABYLON {
  71223. /** @hidden */
  71224. export var spritesPixelShader: {
  71225. name: string;
  71226. shader: string;
  71227. };
  71228. }
  71229. declare module BABYLON {
  71230. /** @hidden */
  71231. export var fogVertexDeclaration: {
  71232. name: string;
  71233. shader: string;
  71234. };
  71235. }
  71236. declare module BABYLON {
  71237. /** @hidden */
  71238. export var spritesVertexShader: {
  71239. name: string;
  71240. shader: string;
  71241. };
  71242. }
  71243. declare module BABYLON {
  71244. /**
  71245. * Defines the minimum interface to fullfil in order to be a sprite manager.
  71246. */
  71247. export interface ISpriteManager extends IDisposable {
  71248. /**
  71249. * Restricts the camera to viewing objects with the same layerMask.
  71250. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  71251. */
  71252. layerMask: number;
  71253. /**
  71254. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  71255. */
  71256. isPickable: boolean;
  71257. /**
  71258. * Specifies the rendering group id for this mesh (0 by default)
  71259. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  71260. */
  71261. renderingGroupId: number;
  71262. /**
  71263. * Defines the list of sprites managed by the manager.
  71264. */
  71265. sprites: Array<Sprite>;
  71266. /**
  71267. * Tests the intersection of a sprite with a specific ray.
  71268. * @param ray The ray we are sending to test the collision
  71269. * @param camera The camera space we are sending rays in
  71270. * @param predicate A predicate allowing excluding sprites from the list of object to test
  71271. * @param fastCheck Is the hit test done in a OOBB or AOBB fashion the faster, the less precise
  71272. * @returns picking info or null.
  71273. */
  71274. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71275. /**
  71276. * Renders the list of sprites on screen.
  71277. */
  71278. render(): void;
  71279. }
  71280. /**
  71281. * Class used to manage multiple sprites on the same spritesheet
  71282. * @see http://doc.babylonjs.com/babylon101/sprites
  71283. */
  71284. export class SpriteManager implements ISpriteManager {
  71285. /** defines the manager's name */
  71286. name: string;
  71287. /** Gets the list of sprites */
  71288. sprites: Sprite[];
  71289. /** Gets or sets the rendering group id (0 by default) */
  71290. renderingGroupId: number;
  71291. /** Gets or sets camera layer mask */
  71292. layerMask: number;
  71293. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  71294. fogEnabled: boolean;
  71295. /** Gets or sets a boolean indicating if the sprites are pickable */
  71296. isPickable: boolean;
  71297. /** Defines the default width of a cell in the spritesheet */
  71298. cellWidth: number;
  71299. /** Defines the default height of a cell in the spritesheet */
  71300. cellHeight: number;
  71301. /**
  71302. * An event triggered when the manager is disposed.
  71303. */
  71304. onDisposeObservable: Observable<SpriteManager>;
  71305. private _onDisposeObserver;
  71306. /**
  71307. * Callback called when the manager is disposed
  71308. */
  71309. onDispose: () => void;
  71310. private _capacity;
  71311. private _spriteTexture;
  71312. private _epsilon;
  71313. private _scene;
  71314. private _vertexData;
  71315. private _buffer;
  71316. private _vertexBuffers;
  71317. private _indexBuffer;
  71318. private _effectBase;
  71319. private _effectFog;
  71320. /**
  71321. * Gets or sets the spritesheet texture
  71322. */
  71323. texture: Texture;
  71324. /**
  71325. * Creates a new sprite manager
  71326. * @param name defines the manager's name
  71327. * @param imgUrl defines the sprite sheet url
  71328. * @param capacity defines the maximum allowed number of sprites
  71329. * @param cellSize defines the size of a sprite cell
  71330. * @param scene defines the hosting scene
  71331. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  71332. * @param samplingMode defines the smapling mode to use with spritesheet
  71333. */
  71334. constructor(
  71335. /** defines the manager's name */
  71336. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number);
  71337. private _appendSpriteVertex;
  71338. /**
  71339. * Intersects the sprites with a ray
  71340. * @param ray defines the ray to intersect with
  71341. * @param camera defines the current active camera
  71342. * @param predicate defines a predicate used to select candidate sprites
  71343. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  71344. * @returns null if no hit or a PickingInfo
  71345. */
  71346. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  71347. /**
  71348. * Render all child sprites
  71349. */
  71350. render(): void;
  71351. /**
  71352. * Release associated resources
  71353. */
  71354. dispose(): void;
  71355. }
  71356. }
  71357. declare module BABYLON {
  71358. /**
  71359. * Class used to represent a sprite
  71360. * @see http://doc.babylonjs.com/babylon101/sprites
  71361. */
  71362. export class Sprite {
  71363. /** defines the name */
  71364. name: string;
  71365. /** Gets or sets the current world position */
  71366. position: Vector3;
  71367. /** Gets or sets the main color */
  71368. color: Color4;
  71369. /** Gets or sets the width */
  71370. width: number;
  71371. /** Gets or sets the height */
  71372. height: number;
  71373. /** Gets or sets rotation angle */
  71374. angle: number;
  71375. /** Gets or sets the cell index in the sprite sheet */
  71376. cellIndex: number;
  71377. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  71378. invertU: number;
  71379. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  71380. invertV: number;
  71381. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  71382. disposeWhenFinishedAnimating: boolean;
  71383. /** Gets the list of attached animations */
  71384. animations: Animation[];
  71385. /** Gets or sets a boolean indicating if the sprite can be picked */
  71386. isPickable: boolean;
  71387. /**
  71388. * Gets or sets the associated action manager
  71389. */
  71390. actionManager: Nullable<ActionManager>;
  71391. private _animationStarted;
  71392. private _loopAnimation;
  71393. private _fromIndex;
  71394. private _toIndex;
  71395. private _delay;
  71396. private _direction;
  71397. private _manager;
  71398. private _time;
  71399. private _onAnimationEnd;
  71400. /**
  71401. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  71402. */
  71403. isVisible: boolean;
  71404. /**
  71405. * Gets or sets the sprite size
  71406. */
  71407. size: number;
  71408. /**
  71409. * Creates a new Sprite
  71410. * @param name defines the name
  71411. * @param manager defines the manager
  71412. */
  71413. constructor(
  71414. /** defines the name */
  71415. name: string, manager: ISpriteManager);
  71416. /**
  71417. * Starts an animation
  71418. * @param from defines the initial key
  71419. * @param to defines the end key
  71420. * @param loop defines if the animation must loop
  71421. * @param delay defines the start delay (in ms)
  71422. * @param onAnimationEnd defines a callback to call when animation ends
  71423. */
  71424. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd: () => void): void;
  71425. /** Stops current animation (if any) */
  71426. stopAnimation(): void;
  71427. /** @hidden */
  71428. _animate(deltaTime: number): void;
  71429. /** Release associated resources */
  71430. dispose(): void;
  71431. }
  71432. }
  71433. declare module BABYLON {
  71434. /**
  71435. * Information about the result of picking within a scene
  71436. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  71437. */
  71438. export class PickingInfo {
  71439. /** @hidden */
  71440. _pickingUnavailable: boolean;
  71441. /**
  71442. * If the pick collided with an object
  71443. */
  71444. hit: boolean;
  71445. /**
  71446. * Distance away where the pick collided
  71447. */
  71448. distance: number;
  71449. /**
  71450. * The location of pick collision
  71451. */
  71452. pickedPoint: Nullable<Vector3>;
  71453. /**
  71454. * The mesh corresponding the the pick collision
  71455. */
  71456. pickedMesh: Nullable<AbstractMesh>;
  71457. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  71458. bu: number;
  71459. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  71460. bv: number;
  71461. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  71462. faceId: number;
  71463. /** Id of the the submesh that was picked */
  71464. subMeshId: number;
  71465. /** If a sprite was picked, this will be the sprite the pick collided with */
  71466. pickedSprite: Nullable<Sprite>;
  71467. /**
  71468. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  71469. */
  71470. originMesh: Nullable<AbstractMesh>;
  71471. /**
  71472. * The ray that was used to perform the picking.
  71473. */
  71474. ray: Nullable<Ray>;
  71475. /**
  71476. * Gets the normal correspodning to the face the pick collided with
  71477. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  71478. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  71479. * @returns The normal correspodning to the face the pick collided with
  71480. */
  71481. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  71482. /**
  71483. * Gets the texture coordinates of where the pick occured
  71484. * @returns the vector containing the coordnates of the texture
  71485. */
  71486. getTextureCoordinates(): Nullable<Vector2>;
  71487. }
  71488. }
  71489. declare module BABYLON {
  71490. /**
  71491. * Gather the list of pointer event types as constants.
  71492. */
  71493. export class PointerEventTypes {
  71494. /**
  71495. * 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.
  71496. */
  71497. static readonly POINTERDOWN: number;
  71498. /**
  71499. * The pointerup event is fired when a pointer is no longer active.
  71500. */
  71501. static readonly POINTERUP: number;
  71502. /**
  71503. * The pointermove event is fired when a pointer changes coordinates.
  71504. */
  71505. static readonly POINTERMOVE: number;
  71506. /**
  71507. * The pointerwheel event is fired when a mouse wheel has been rotated.
  71508. */
  71509. static readonly POINTERWHEEL: number;
  71510. /**
  71511. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  71512. */
  71513. static readonly POINTERPICK: number;
  71514. /**
  71515. * The pointertap event is fired when a the object has been touched and released without drag.
  71516. */
  71517. static readonly POINTERTAP: number;
  71518. /**
  71519. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  71520. */
  71521. static readonly POINTERDOUBLETAP: number;
  71522. }
  71523. /**
  71524. * Base class of pointer info types.
  71525. */
  71526. export class PointerInfoBase {
  71527. /**
  71528. * Defines the type of event (PointerEventTypes)
  71529. */
  71530. type: number;
  71531. /**
  71532. * Defines the related dom event
  71533. */
  71534. event: PointerEvent | MouseWheelEvent;
  71535. /**
  71536. * Instantiates the base class of pointers info.
  71537. * @param type Defines the type of event (PointerEventTypes)
  71538. * @param event Defines the related dom event
  71539. */
  71540. constructor(
  71541. /**
  71542. * Defines the type of event (PointerEventTypes)
  71543. */
  71544. type: number,
  71545. /**
  71546. * Defines the related dom event
  71547. */
  71548. event: PointerEvent | MouseWheelEvent);
  71549. }
  71550. /**
  71551. * This class is used to store pointer related info for the onPrePointerObservable event.
  71552. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  71553. */
  71554. export class PointerInfoPre extends PointerInfoBase {
  71555. /**
  71556. * Ray from a pointer if availible (eg. 6dof controller)
  71557. */
  71558. ray: Nullable<Ray>;
  71559. /**
  71560. * Defines the local position of the pointer on the canvas.
  71561. */
  71562. localPosition: Vector2;
  71563. /**
  71564. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  71565. */
  71566. skipOnPointerObservable: boolean;
  71567. /**
  71568. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  71569. * @param type Defines the type of event (PointerEventTypes)
  71570. * @param event Defines the related dom event
  71571. * @param localX Defines the local x coordinates of the pointer when the event occured
  71572. * @param localY Defines the local y coordinates of the pointer when the event occured
  71573. */
  71574. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  71575. }
  71576. /**
  71577. * This type contains all the data related to a pointer event in Babylon.js.
  71578. * 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.
  71579. */
  71580. export class PointerInfo extends PointerInfoBase {
  71581. /**
  71582. * Defines the picking info associated to the info (if any)\
  71583. */
  71584. pickInfo: Nullable<PickingInfo>;
  71585. /**
  71586. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  71587. * @param type Defines the type of event (PointerEventTypes)
  71588. * @param event Defines the related dom event
  71589. * @param pickInfo Defines the picking info associated to the info (if any)\
  71590. */
  71591. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  71592. /**
  71593. * Defines the picking info associated to the info (if any)\
  71594. */
  71595. pickInfo: Nullable<PickingInfo>);
  71596. }
  71597. /**
  71598. * Data relating to a touch event on the screen.
  71599. */
  71600. export interface PointerTouch {
  71601. /**
  71602. * X coordinate of touch.
  71603. */
  71604. x: number;
  71605. /**
  71606. * Y coordinate of touch.
  71607. */
  71608. y: number;
  71609. /**
  71610. * Id of touch. Unique for each finger.
  71611. */
  71612. pointerId: number;
  71613. /**
  71614. * Event type passed from DOM.
  71615. */
  71616. type: any;
  71617. }
  71618. }
  71619. declare module BABYLON {
  71620. /**
  71621. * Manage the mouse inputs to control the movement of a free camera.
  71622. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71623. */
  71624. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  71625. /**
  71626. * Define if touch is enabled in the mouse input
  71627. */
  71628. touchEnabled: boolean;
  71629. /**
  71630. * Defines the camera the input is attached to.
  71631. */
  71632. camera: FreeCamera;
  71633. /**
  71634. * Defines the buttons associated with the input to handle camera move.
  71635. */
  71636. buttons: number[];
  71637. /**
  71638. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  71639. */
  71640. angularSensibility: number;
  71641. private _pointerInput;
  71642. private _onMouseMove;
  71643. private _observer;
  71644. private previousPosition;
  71645. /**
  71646. * Observable for when a pointer move event occurs containing the move offset
  71647. */
  71648. onPointerMovedObservable: Observable<{
  71649. offsetX: number;
  71650. offsetY: number;
  71651. }>;
  71652. /**
  71653. * @hidden
  71654. * If the camera should be rotated automatically based on pointer movement
  71655. */
  71656. _allowCameraRotation: boolean;
  71657. /**
  71658. * Manage the mouse inputs to control the movement of a free camera.
  71659. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71660. * @param touchEnabled Defines if touch is enabled or not
  71661. */
  71662. constructor(
  71663. /**
  71664. * Define if touch is enabled in the mouse input
  71665. */
  71666. touchEnabled?: boolean);
  71667. /**
  71668. * Attach the input controls to a specific dom element to get the input from.
  71669. * @param element Defines the element the controls should be listened from
  71670. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71671. */
  71672. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71673. /**
  71674. * Called on JS contextmenu event.
  71675. * Override this method to provide functionality.
  71676. */
  71677. protected onContextMenu(evt: PointerEvent): void;
  71678. /**
  71679. * Detach the current controls from the specified dom element.
  71680. * @param element Defines the element to stop listening the inputs from
  71681. */
  71682. detachControl(element: Nullable<HTMLElement>): void;
  71683. /**
  71684. * Gets the class name of the current intput.
  71685. * @returns the class name
  71686. */
  71687. getClassName(): string;
  71688. /**
  71689. * Get the friendly name associated with the input class.
  71690. * @returns the input friendly name
  71691. */
  71692. getSimpleName(): string;
  71693. }
  71694. }
  71695. declare module BABYLON {
  71696. /**
  71697. * Manage the touch inputs to control the movement of a free camera.
  71698. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71699. */
  71700. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  71701. /**
  71702. * Defines the camera the input is attached to.
  71703. */
  71704. camera: FreeCamera;
  71705. /**
  71706. * Defines the touch sensibility for rotation.
  71707. * The higher the faster.
  71708. */
  71709. touchAngularSensibility: number;
  71710. /**
  71711. * Defines the touch sensibility for move.
  71712. * The higher the faster.
  71713. */
  71714. touchMoveSensibility: number;
  71715. private _offsetX;
  71716. private _offsetY;
  71717. private _pointerPressed;
  71718. private _pointerInput;
  71719. private _observer;
  71720. private _onLostFocus;
  71721. /**
  71722. * Attach the input controls to a specific dom element to get the input from.
  71723. * @param element Defines the element the controls should be listened from
  71724. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71725. */
  71726. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71727. /**
  71728. * Detach the current controls from the specified dom element.
  71729. * @param element Defines the element to stop listening the inputs from
  71730. */
  71731. detachControl(element: Nullable<HTMLElement>): void;
  71732. /**
  71733. * Update the current camera state depending on the inputs that have been used this frame.
  71734. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  71735. */
  71736. checkInputs(): void;
  71737. /**
  71738. * Gets the class name of the current intput.
  71739. * @returns the class name
  71740. */
  71741. getClassName(): string;
  71742. /**
  71743. * Get the friendly name associated with the input class.
  71744. * @returns the input friendly name
  71745. */
  71746. getSimpleName(): string;
  71747. }
  71748. }
  71749. declare module BABYLON {
  71750. /**
  71751. * Default Inputs manager for the FreeCamera.
  71752. * It groups all the default supported inputs for ease of use.
  71753. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  71754. */
  71755. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  71756. /**
  71757. * @hidden
  71758. */
  71759. _keyboardInput: Nullable<FreeCameraKeyboardMoveInput>;
  71760. /**
  71761. * @hidden
  71762. */
  71763. _mouseInput: Nullable<FreeCameraMouseInput>;
  71764. /**
  71765. * Instantiates a new FreeCameraInputsManager.
  71766. * @param camera Defines the camera the inputs belong to
  71767. */
  71768. constructor(camera: FreeCamera);
  71769. /**
  71770. * Add keyboard input support to the input manager.
  71771. * @returns the current input manager
  71772. */
  71773. addKeyboard(): FreeCameraInputsManager;
  71774. /**
  71775. * Add mouse input support to the input manager.
  71776. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  71777. * @returns the current input manager
  71778. */
  71779. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  71780. /**
  71781. * Removes the mouse input support from the manager
  71782. * @returns the current input manager
  71783. */
  71784. removeMouse(): FreeCameraInputsManager;
  71785. /**
  71786. * Add touch input support to the input manager.
  71787. * @returns the current input manager
  71788. */
  71789. addTouch(): FreeCameraInputsManager;
  71790. }
  71791. }
  71792. declare module BABYLON {
  71793. /**
  71794. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71795. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  71796. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71797. */
  71798. export class FreeCamera extends TargetCamera {
  71799. /**
  71800. * Define the collision ellipsoid of the camera.
  71801. * This is helpful to simulate a camera body like the player body around the camera
  71802. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  71803. */
  71804. ellipsoid: Vector3;
  71805. /**
  71806. * Define an offset for the position of the ellipsoid around the camera.
  71807. * This can be helpful to determine the center of the body near the gravity center of the body
  71808. * instead of its head.
  71809. */
  71810. ellipsoidOffset: Vector3;
  71811. /**
  71812. * Enable or disable collisions of the camera with the rest of the scene objects.
  71813. */
  71814. checkCollisions: boolean;
  71815. /**
  71816. * Enable or disable gravity on the camera.
  71817. */
  71818. applyGravity: boolean;
  71819. /**
  71820. * Define the input manager associated to the camera.
  71821. */
  71822. inputs: FreeCameraInputsManager;
  71823. /**
  71824. * Gets the input sensibility for a mouse input. (default is 2000.0)
  71825. * Higher values reduce sensitivity.
  71826. */
  71827. /**
  71828. * Sets the input sensibility for a mouse input. (default is 2000.0)
  71829. * Higher values reduce sensitivity.
  71830. */
  71831. angularSensibility: number;
  71832. /**
  71833. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  71834. */
  71835. keysUp: number[];
  71836. /**
  71837. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  71838. */
  71839. keysDown: number[];
  71840. /**
  71841. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  71842. */
  71843. keysLeft: number[];
  71844. /**
  71845. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  71846. */
  71847. keysRight: number[];
  71848. /**
  71849. * Event raised when the camera collide with a mesh in the scene.
  71850. */
  71851. onCollide: (collidedMesh: AbstractMesh) => void;
  71852. private _collider;
  71853. private _needMoveForGravity;
  71854. private _oldPosition;
  71855. private _diffPosition;
  71856. private _newPosition;
  71857. /** @hidden */
  71858. _localDirection: Vector3;
  71859. /** @hidden */
  71860. _transformedDirection: Vector3;
  71861. /**
  71862. * Instantiates a Free Camera.
  71863. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  71864. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  71865. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  71866. * @param name Define the name of the camera in the scene
  71867. * @param position Define the start position of the camera in the scene
  71868. * @param scene Define the scene the camera belongs to
  71869. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  71870. */
  71871. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  71872. /**
  71873. * Attached controls to the current camera.
  71874. * @param element Defines the element the controls should be listened from
  71875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  71876. */
  71877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  71878. /**
  71879. * Detach the current controls from the camera.
  71880. * The camera will stop reacting to inputs.
  71881. * @param element Defines the element to stop listening the inputs from
  71882. */
  71883. detachControl(element: HTMLElement): void;
  71884. private _collisionMask;
  71885. /**
  71886. * Define a collision mask to limit the list of object the camera can collide with
  71887. */
  71888. collisionMask: number;
  71889. /** @hidden */
  71890. _collideWithWorld(displacement: Vector3): void;
  71891. private _onCollisionPositionChange;
  71892. /** @hidden */
  71893. _checkInputs(): void;
  71894. /** @hidden */
  71895. _decideIfNeedsToMove(): boolean;
  71896. /** @hidden */
  71897. _updatePosition(): void;
  71898. /**
  71899. * Destroy the camera and release the current resources hold by it.
  71900. */
  71901. dispose(): void;
  71902. /**
  71903. * Gets the current object class name.
  71904. * @return the class name
  71905. */
  71906. getClassName(): string;
  71907. }
  71908. }
  71909. declare module BABYLON {
  71910. /**
  71911. * Represents a gamepad control stick position
  71912. */
  71913. export class StickValues {
  71914. /**
  71915. * The x component of the control stick
  71916. */
  71917. x: number;
  71918. /**
  71919. * The y component of the control stick
  71920. */
  71921. y: number;
  71922. /**
  71923. * Initializes the gamepad x and y control stick values
  71924. * @param x The x component of the gamepad control stick value
  71925. * @param y The y component of the gamepad control stick value
  71926. */
  71927. constructor(
  71928. /**
  71929. * The x component of the control stick
  71930. */
  71931. x: number,
  71932. /**
  71933. * The y component of the control stick
  71934. */
  71935. y: number);
  71936. }
  71937. /**
  71938. * An interface which manages callbacks for gamepad button changes
  71939. */
  71940. export interface GamepadButtonChanges {
  71941. /**
  71942. * Called when a gamepad has been changed
  71943. */
  71944. changed: boolean;
  71945. /**
  71946. * Called when a gamepad press event has been triggered
  71947. */
  71948. pressChanged: boolean;
  71949. /**
  71950. * Called when a touch event has been triggered
  71951. */
  71952. touchChanged: boolean;
  71953. /**
  71954. * Called when a value has changed
  71955. */
  71956. valueChanged: boolean;
  71957. }
  71958. /**
  71959. * Represents a gamepad
  71960. */
  71961. export class Gamepad {
  71962. /**
  71963. * The id of the gamepad
  71964. */
  71965. id: string;
  71966. /**
  71967. * The index of the gamepad
  71968. */
  71969. index: number;
  71970. /**
  71971. * The browser gamepad
  71972. */
  71973. browserGamepad: any;
  71974. /**
  71975. * Specifies what type of gamepad this represents
  71976. */
  71977. type: number;
  71978. private _leftStick;
  71979. private _rightStick;
  71980. /** @hidden */
  71981. _isConnected: boolean;
  71982. private _leftStickAxisX;
  71983. private _leftStickAxisY;
  71984. private _rightStickAxisX;
  71985. private _rightStickAxisY;
  71986. /**
  71987. * Triggered when the left control stick has been changed
  71988. */
  71989. private _onleftstickchanged;
  71990. /**
  71991. * Triggered when the right control stick has been changed
  71992. */
  71993. private _onrightstickchanged;
  71994. /**
  71995. * Represents a gamepad controller
  71996. */
  71997. static GAMEPAD: number;
  71998. /**
  71999. * Represents a generic controller
  72000. */
  72001. static GENERIC: number;
  72002. /**
  72003. * Represents an XBox controller
  72004. */
  72005. static XBOX: number;
  72006. /**
  72007. * Represents a pose-enabled controller
  72008. */
  72009. static POSE_ENABLED: number;
  72010. /**
  72011. * Specifies whether the left control stick should be Y-inverted
  72012. */
  72013. protected _invertLeftStickY: boolean;
  72014. /**
  72015. * Specifies if the gamepad has been connected
  72016. */
  72017. readonly isConnected: boolean;
  72018. /**
  72019. * Initializes the gamepad
  72020. * @param id The id of the gamepad
  72021. * @param index The index of the gamepad
  72022. * @param browserGamepad The browser gamepad
  72023. * @param leftStickX The x component of the left joystick
  72024. * @param leftStickY The y component of the left joystick
  72025. * @param rightStickX The x component of the right joystick
  72026. * @param rightStickY The y component of the right joystick
  72027. */
  72028. constructor(
  72029. /**
  72030. * The id of the gamepad
  72031. */
  72032. id: string,
  72033. /**
  72034. * The index of the gamepad
  72035. */
  72036. index: number,
  72037. /**
  72038. * The browser gamepad
  72039. */
  72040. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  72041. /**
  72042. * Callback triggered when the left joystick has changed
  72043. * @param callback
  72044. */
  72045. onleftstickchanged(callback: (values: StickValues) => void): void;
  72046. /**
  72047. * Callback triggered when the right joystick has changed
  72048. * @param callback
  72049. */
  72050. onrightstickchanged(callback: (values: StickValues) => void): void;
  72051. /**
  72052. * Gets the left joystick
  72053. */
  72054. /**
  72055. * Sets the left joystick values
  72056. */
  72057. leftStick: StickValues;
  72058. /**
  72059. * Gets the right joystick
  72060. */
  72061. /**
  72062. * Sets the right joystick value
  72063. */
  72064. rightStick: StickValues;
  72065. /**
  72066. * Updates the gamepad joystick positions
  72067. */
  72068. update(): void;
  72069. /**
  72070. * Disposes the gamepad
  72071. */
  72072. dispose(): void;
  72073. }
  72074. /**
  72075. * Represents a generic gamepad
  72076. */
  72077. export class GenericPad extends Gamepad {
  72078. private _buttons;
  72079. private _onbuttondown;
  72080. private _onbuttonup;
  72081. /**
  72082. * Observable triggered when a button has been pressed
  72083. */
  72084. onButtonDownObservable: Observable<number>;
  72085. /**
  72086. * Observable triggered when a button has been released
  72087. */
  72088. onButtonUpObservable: Observable<number>;
  72089. /**
  72090. * Callback triggered when a button has been pressed
  72091. * @param callback Called when a button has been pressed
  72092. */
  72093. onbuttondown(callback: (buttonPressed: number) => void): void;
  72094. /**
  72095. * Callback triggered when a button has been released
  72096. * @param callback Called when a button has been released
  72097. */
  72098. onbuttonup(callback: (buttonReleased: number) => void): void;
  72099. /**
  72100. * Initializes the generic gamepad
  72101. * @param id The id of the generic gamepad
  72102. * @param index The index of the generic gamepad
  72103. * @param browserGamepad The browser gamepad
  72104. */
  72105. constructor(id: string, index: number, browserGamepad: any);
  72106. private _setButtonValue;
  72107. /**
  72108. * Updates the generic gamepad
  72109. */
  72110. update(): void;
  72111. /**
  72112. * Disposes the generic gamepad
  72113. */
  72114. dispose(): void;
  72115. }
  72116. }
  72117. declare module BABYLON {
  72118. /**
  72119. * Defines the types of pose enabled controllers that are supported
  72120. */
  72121. export enum PoseEnabledControllerType {
  72122. /**
  72123. * HTC Vive
  72124. */
  72125. VIVE = 0,
  72126. /**
  72127. * Oculus Rift
  72128. */
  72129. OCULUS = 1,
  72130. /**
  72131. * Windows mixed reality
  72132. */
  72133. WINDOWS = 2,
  72134. /**
  72135. * Samsung gear VR
  72136. */
  72137. GEAR_VR = 3,
  72138. /**
  72139. * Google Daydream
  72140. */
  72141. DAYDREAM = 4,
  72142. /**
  72143. * Generic
  72144. */
  72145. GENERIC = 5
  72146. }
  72147. /**
  72148. * Defines the MutableGamepadButton interface for the state of a gamepad button
  72149. */
  72150. export interface MutableGamepadButton {
  72151. /**
  72152. * Value of the button/trigger
  72153. */
  72154. value: number;
  72155. /**
  72156. * If the button/trigger is currently touched
  72157. */
  72158. touched: boolean;
  72159. /**
  72160. * If the button/trigger is currently pressed
  72161. */
  72162. pressed: boolean;
  72163. }
  72164. /**
  72165. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  72166. * @hidden
  72167. */
  72168. export interface ExtendedGamepadButton extends GamepadButton {
  72169. /**
  72170. * If the button/trigger is currently pressed
  72171. */
  72172. readonly pressed: boolean;
  72173. /**
  72174. * If the button/trigger is currently touched
  72175. */
  72176. readonly touched: boolean;
  72177. /**
  72178. * Value of the button/trigger
  72179. */
  72180. readonly value: number;
  72181. }
  72182. /** @hidden */
  72183. export interface _GamePadFactory {
  72184. /**
  72185. * Returns wether or not the current gamepad can be created for this type of controller.
  72186. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72187. * @returns true if it can be created, otherwise false
  72188. */
  72189. canCreate(gamepadInfo: any): boolean;
  72190. /**
  72191. * Creates a new instance of the Gamepad.
  72192. * @param gamepadInfo Defines the gamepad info as receveid from the controller APIs.
  72193. * @returns the new gamepad instance
  72194. */
  72195. create(gamepadInfo: any): Gamepad;
  72196. }
  72197. /**
  72198. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72199. */
  72200. export class PoseEnabledControllerHelper {
  72201. /** @hidden */
  72202. static _ControllerFactories: _GamePadFactory[];
  72203. /** @hidden */
  72204. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  72205. /**
  72206. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  72207. * @param vrGamepad the gamepad to initialized
  72208. * @returns a vr controller of the type the gamepad identified as
  72209. */
  72210. static InitiateController(vrGamepad: any): Gamepad;
  72211. }
  72212. /**
  72213. * Defines the PoseEnabledController object that contains state of a vr capable controller
  72214. */
  72215. export class PoseEnabledController extends Gamepad implements PoseControlled {
  72216. private _deviceRoomPosition;
  72217. private _deviceRoomRotationQuaternion;
  72218. /**
  72219. * The device position in babylon space
  72220. */
  72221. devicePosition: Vector3;
  72222. /**
  72223. * The device rotation in babylon space
  72224. */
  72225. deviceRotationQuaternion: Quaternion;
  72226. /**
  72227. * The scale factor of the device in babylon space
  72228. */
  72229. deviceScaleFactor: number;
  72230. /**
  72231. * (Likely devicePosition should be used instead) The device position in its room space
  72232. */
  72233. position: Vector3;
  72234. /**
  72235. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  72236. */
  72237. rotationQuaternion: Quaternion;
  72238. /**
  72239. * The type of controller (Eg. Windows mixed reality)
  72240. */
  72241. controllerType: PoseEnabledControllerType;
  72242. protected _calculatedPosition: Vector3;
  72243. private _calculatedRotation;
  72244. /**
  72245. * The raw pose from the device
  72246. */
  72247. rawPose: DevicePose;
  72248. private _trackPosition;
  72249. private _maxRotationDistFromHeadset;
  72250. private _draggedRoomRotation;
  72251. /**
  72252. * @hidden
  72253. */
  72254. _disableTrackPosition(fixedPosition: Vector3): void;
  72255. /**
  72256. * Internal, the mesh attached to the controller
  72257. * @hidden
  72258. */
  72259. _mesh: Nullable<AbstractMesh>;
  72260. private _poseControlledCamera;
  72261. private _leftHandSystemQuaternion;
  72262. /**
  72263. * Internal, matrix used to convert room space to babylon space
  72264. * @hidden
  72265. */
  72266. _deviceToWorld: Matrix;
  72267. /**
  72268. * Node to be used when casting a ray from the controller
  72269. * @hidden
  72270. */
  72271. _pointingPoseNode: Nullable<TransformNode>;
  72272. /**
  72273. * Name of the child mesh that can be used to cast a ray from the controller
  72274. */
  72275. static readonly POINTING_POSE: string;
  72276. /**
  72277. * Creates a new PoseEnabledController from a gamepad
  72278. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  72279. */
  72280. constructor(browserGamepad: any);
  72281. private _workingMatrix;
  72282. /**
  72283. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  72284. */
  72285. update(): void;
  72286. /**
  72287. * Updates only the pose device and mesh without doing any button event checking
  72288. */
  72289. protected _updatePoseAndMesh(): void;
  72290. /**
  72291. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  72292. * @param poseData raw pose fromthe device
  72293. */
  72294. updateFromDevice(poseData: DevicePose): void;
  72295. /**
  72296. * @hidden
  72297. */
  72298. _meshAttachedObservable: Observable<AbstractMesh>;
  72299. /**
  72300. * Attaches a mesh to the controller
  72301. * @param mesh the mesh to be attached
  72302. */
  72303. attachToMesh(mesh: AbstractMesh): void;
  72304. /**
  72305. * Attaches the controllers mesh to a camera
  72306. * @param camera the camera the mesh should be attached to
  72307. */
  72308. attachToPoseControlledCamera(camera: TargetCamera): void;
  72309. /**
  72310. * Disposes of the controller
  72311. */
  72312. dispose(): void;
  72313. /**
  72314. * The mesh that is attached to the controller
  72315. */
  72316. readonly mesh: Nullable<AbstractMesh>;
  72317. /**
  72318. * Gets the ray of the controller in the direction the controller is pointing
  72319. * @param length the length the resulting ray should be
  72320. * @returns a ray in the direction the controller is pointing
  72321. */
  72322. getForwardRay(length?: number): Ray;
  72323. }
  72324. }
  72325. declare module BABYLON {
  72326. /**
  72327. * Defines the WebVRController object that represents controllers tracked in 3D space
  72328. */
  72329. export abstract class WebVRController extends PoseEnabledController {
  72330. /**
  72331. * Internal, the default controller model for the controller
  72332. */
  72333. protected _defaultModel: AbstractMesh;
  72334. /**
  72335. * Fired when the trigger state has changed
  72336. */
  72337. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  72338. /**
  72339. * Fired when the main button state has changed
  72340. */
  72341. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72342. /**
  72343. * Fired when the secondary button state has changed
  72344. */
  72345. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  72346. /**
  72347. * Fired when the pad state has changed
  72348. */
  72349. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  72350. /**
  72351. * Fired when controllers stick values have changed
  72352. */
  72353. onPadValuesChangedObservable: Observable<StickValues>;
  72354. /**
  72355. * Array of button availible on the controller
  72356. */
  72357. protected _buttons: Array<MutableGamepadButton>;
  72358. private _onButtonStateChange;
  72359. /**
  72360. * Fired when a controller button's state has changed
  72361. * @param callback the callback containing the button that was modified
  72362. */
  72363. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  72364. /**
  72365. * X and Y axis corrisponding to the controllers joystick
  72366. */
  72367. pad: StickValues;
  72368. /**
  72369. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  72370. */
  72371. hand: string;
  72372. /**
  72373. * The default controller model for the controller
  72374. */
  72375. readonly defaultModel: AbstractMesh;
  72376. /**
  72377. * Creates a new WebVRController from a gamepad
  72378. * @param vrGamepad the gamepad that the WebVRController should be created from
  72379. */
  72380. constructor(vrGamepad: any);
  72381. /**
  72382. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  72383. */
  72384. update(): void;
  72385. /**
  72386. * Function to be called when a button is modified
  72387. */
  72388. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  72389. /**
  72390. * Loads a mesh and attaches it to the controller
  72391. * @param scene the scene the mesh should be added to
  72392. * @param meshLoaded callback for when the mesh has been loaded
  72393. */
  72394. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  72395. private _setButtonValue;
  72396. private _changes;
  72397. private _checkChanges;
  72398. /**
  72399. * Disposes of th webVRCOntroller
  72400. */
  72401. dispose(): void;
  72402. }
  72403. }
  72404. declare module BABYLON {
  72405. /**
  72406. * The HemisphericLight simulates the ambient environment light,
  72407. * so the passed direction is the light reflection direction, not the incoming direction.
  72408. */
  72409. export class HemisphericLight extends Light {
  72410. /**
  72411. * The groundColor is the light in the opposite direction to the one specified during creation.
  72412. * 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.
  72413. */
  72414. groundColor: Color3;
  72415. /**
  72416. * The light reflection direction, not the incoming direction.
  72417. */
  72418. direction: Vector3;
  72419. /**
  72420. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  72421. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  72422. * The HemisphericLight can't cast shadows.
  72423. * Documentation : https://doc.babylonjs.com/babylon101/lights
  72424. * @param name The friendly name of the light
  72425. * @param direction The direction of the light reflection
  72426. * @param scene The scene the light belongs to
  72427. */
  72428. constructor(name: string, direction: Vector3, scene: Scene);
  72429. protected _buildUniformLayout(): void;
  72430. /**
  72431. * Returns the string "HemisphericLight".
  72432. * @return The class name
  72433. */
  72434. getClassName(): string;
  72435. /**
  72436. * Sets the HemisphericLight direction towards the passed target (Vector3).
  72437. * Returns the updated direction.
  72438. * @param target The target the direction should point to
  72439. * @return The computed direction
  72440. */
  72441. setDirectionToTarget(target: Vector3): Vector3;
  72442. /**
  72443. * Returns the shadow generator associated to the light.
  72444. * @returns Always null for hemispheric lights because it does not support shadows.
  72445. */
  72446. getShadowGenerator(): Nullable<IShadowGenerator>;
  72447. /**
  72448. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  72449. * @param effect The effect to update
  72450. * @param lightIndex The index of the light in the effect to update
  72451. * @returns The hemispheric light
  72452. */
  72453. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  72454. /**
  72455. * Computes the world matrix of the node
  72456. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  72457. * @param useWasUpdatedFlag defines a reserved property
  72458. * @returns the world matrix
  72459. */
  72460. computeWorldMatrix(): Matrix;
  72461. /**
  72462. * Returns the integer 3.
  72463. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  72464. */
  72465. getTypeID(): number;
  72466. /**
  72467. * Prepares the list of defines specific to the light type.
  72468. * @param defines the list of defines
  72469. * @param lightIndex defines the index of the light for the effect
  72470. */
  72471. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  72472. }
  72473. }
  72474. declare module BABYLON {
  72475. /** @hidden */
  72476. export var vrMultiviewToSingleviewPixelShader: {
  72477. name: string;
  72478. shader: string;
  72479. };
  72480. }
  72481. declare module BABYLON {
  72482. /**
  72483. * Renders to multiple views with a single draw call
  72484. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  72485. */
  72486. export class MultiviewRenderTarget extends RenderTargetTexture {
  72487. /**
  72488. * Creates a multiview render target
  72489. * @param scene scene used with the render target
  72490. * @param size the size of the render target (used for each view)
  72491. */
  72492. constructor(scene: Scene, size?: number | {
  72493. width: number;
  72494. height: number;
  72495. } | {
  72496. ratio: number;
  72497. });
  72498. /**
  72499. * @hidden
  72500. * @param faceIndex the face index, if its a cube texture
  72501. */
  72502. _bindFrameBuffer(faceIndex?: number): void;
  72503. /**
  72504. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  72505. * @returns the view count
  72506. */
  72507. getViewCount(): number;
  72508. }
  72509. }
  72510. declare module BABYLON {
  72511. interface Engine {
  72512. /**
  72513. * Creates a new multiview render target
  72514. * @param width defines the width of the texture
  72515. * @param height defines the height of the texture
  72516. * @returns the created multiview texture
  72517. */
  72518. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  72519. /**
  72520. * Binds a multiview framebuffer to be drawn to
  72521. * @param multiviewTexture texture to bind
  72522. */
  72523. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  72524. }
  72525. interface Camera {
  72526. /**
  72527. * @hidden
  72528. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  72529. */
  72530. _useMultiviewToSingleView: boolean;
  72531. /**
  72532. * @hidden
  72533. * For cameras that cannot use multiview images to display directly. (e.g. webVR camera will render to multiview texture, then copy to each eye texture and go from there)
  72534. */
  72535. _multiviewTexture: Nullable<RenderTargetTexture>;
  72536. /**
  72537. * @hidden
  72538. * ensures the multiview texture of the camera exists and has the specified width/height
  72539. * @param width height to set on the multiview texture
  72540. * @param height width to set on the multiview texture
  72541. */
  72542. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  72543. }
  72544. interface Scene {
  72545. /** @hidden */
  72546. _transformMatrixR: Matrix;
  72547. /** @hidden */
  72548. _multiviewSceneUbo: Nullable<UniformBuffer>;
  72549. /** @hidden */
  72550. _createMultiviewUbo(): void;
  72551. /** @hidden */
  72552. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  72553. /** @hidden */
  72554. _renderMultiviewToSingleView(camera: Camera): void;
  72555. }
  72556. }
  72557. declare module BABYLON {
  72558. /**
  72559. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  72560. * This will not be used for webXR as it supports displaying texture arrays directly
  72561. */
  72562. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  72563. /**
  72564. * Initializes a VRMultiviewToSingleview
  72565. * @param name name of the post process
  72566. * @param camera camera to be applied to
  72567. * @param scaleFactor scaling factor to the size of the output texture
  72568. */
  72569. constructor(name: string, camera: Camera, scaleFactor: number);
  72570. }
  72571. }
  72572. declare module BABYLON {
  72573. /**
  72574. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  72575. * IMPORTANT!! The data is right-hand data.
  72576. * @export
  72577. * @interface DevicePose
  72578. */
  72579. export interface DevicePose {
  72580. /**
  72581. * The position of the device, values in array are [x,y,z].
  72582. */
  72583. readonly position: Nullable<Float32Array>;
  72584. /**
  72585. * The linearVelocity of the device, values in array are [x,y,z].
  72586. */
  72587. readonly linearVelocity: Nullable<Float32Array>;
  72588. /**
  72589. * The linearAcceleration of the device, values in array are [x,y,z].
  72590. */
  72591. readonly linearAcceleration: Nullable<Float32Array>;
  72592. /**
  72593. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  72594. */
  72595. readonly orientation: Nullable<Float32Array>;
  72596. /**
  72597. * The angularVelocity of the device, values in array are [x,y,z].
  72598. */
  72599. readonly angularVelocity: Nullable<Float32Array>;
  72600. /**
  72601. * The angularAcceleration of the device, values in array are [x,y,z].
  72602. */
  72603. readonly angularAcceleration: Nullable<Float32Array>;
  72604. }
  72605. /**
  72606. * Interface representing a pose controlled object in Babylon.
  72607. * A pose controlled object has both regular pose values as well as pose values
  72608. * from an external device such as a VR head mounted display
  72609. */
  72610. export interface PoseControlled {
  72611. /**
  72612. * The position of the object in babylon space.
  72613. */
  72614. position: Vector3;
  72615. /**
  72616. * The rotation quaternion of the object in babylon space.
  72617. */
  72618. rotationQuaternion: Quaternion;
  72619. /**
  72620. * The position of the device in babylon space.
  72621. */
  72622. devicePosition?: Vector3;
  72623. /**
  72624. * The rotation quaternion of the device in babylon space.
  72625. */
  72626. deviceRotationQuaternion: Quaternion;
  72627. /**
  72628. * The raw pose coming from the device.
  72629. */
  72630. rawPose: Nullable<DevicePose>;
  72631. /**
  72632. * The scale of the device to be used when translating from device space to babylon space.
  72633. */
  72634. deviceScaleFactor: number;
  72635. /**
  72636. * Updates the poseControlled values based on the input device pose.
  72637. * @param poseData the pose data to update the object with
  72638. */
  72639. updateFromDevice(poseData: DevicePose): void;
  72640. }
  72641. /**
  72642. * Set of options to customize the webVRCamera
  72643. */
  72644. export interface WebVROptions {
  72645. /**
  72646. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  72647. */
  72648. trackPosition?: boolean;
  72649. /**
  72650. * Sets the scale of the vrDevice in babylon space. (default: 1)
  72651. */
  72652. positionScale?: number;
  72653. /**
  72654. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  72655. */
  72656. displayName?: string;
  72657. /**
  72658. * Should the native controller meshes be initialized. (default: true)
  72659. */
  72660. controllerMeshes?: boolean;
  72661. /**
  72662. * Creating a default HemiLight only on controllers. (default: true)
  72663. */
  72664. defaultLightingOnControllers?: boolean;
  72665. /**
  72666. * If you don't want to use the default VR button of the helper. (default: false)
  72667. */
  72668. useCustomVRButton?: boolean;
  72669. /**
  72670. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  72671. */
  72672. customVRButton?: HTMLButtonElement;
  72673. /**
  72674. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  72675. */
  72676. rayLength?: number;
  72677. /**
  72678. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  72679. */
  72680. defaultHeight?: number;
  72681. /**
  72682. * If multiview should be used if availible (default: false)
  72683. */
  72684. useMultiview?: boolean;
  72685. }
  72686. /**
  72687. * This represents a WebVR camera.
  72688. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  72689. * @example http://doc.babylonjs.com/how_to/webvr_camera
  72690. */
  72691. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  72692. private webVROptions;
  72693. /**
  72694. * @hidden
  72695. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  72696. */
  72697. _vrDevice: any;
  72698. /**
  72699. * The rawPose of the vrDevice.
  72700. */
  72701. rawPose: Nullable<DevicePose>;
  72702. private _onVREnabled;
  72703. private _specsVersion;
  72704. private _attached;
  72705. private _frameData;
  72706. protected _descendants: Array<Node>;
  72707. private _deviceRoomPosition;
  72708. /** @hidden */
  72709. _deviceRoomRotationQuaternion: Quaternion;
  72710. private _standingMatrix;
  72711. /**
  72712. * Represents device position in babylon space.
  72713. */
  72714. devicePosition: Vector3;
  72715. /**
  72716. * Represents device rotation in babylon space.
  72717. */
  72718. deviceRotationQuaternion: Quaternion;
  72719. /**
  72720. * The scale of the device to be used when translating from device space to babylon space.
  72721. */
  72722. deviceScaleFactor: number;
  72723. private _deviceToWorld;
  72724. private _worldToDevice;
  72725. /**
  72726. * References to the webVR controllers for the vrDevice.
  72727. */
  72728. controllers: Array<WebVRController>;
  72729. /**
  72730. * Emits an event when a controller is attached.
  72731. */
  72732. onControllersAttachedObservable: Observable<WebVRController[]>;
  72733. /**
  72734. * Emits an event when a controller's mesh has been loaded;
  72735. */
  72736. onControllerMeshLoadedObservable: Observable<WebVRController>;
  72737. /**
  72738. * Emits an event when the HMD's pose has been updated.
  72739. */
  72740. onPoseUpdatedFromDeviceObservable: Observable<any>;
  72741. private _poseSet;
  72742. /**
  72743. * If the rig cameras be used as parent instead of this camera.
  72744. */
  72745. rigParenting: boolean;
  72746. private _lightOnControllers;
  72747. private _defaultHeight?;
  72748. /**
  72749. * Instantiates a WebVRFreeCamera.
  72750. * @param name The name of the WebVRFreeCamera
  72751. * @param position The starting anchor position for the camera
  72752. * @param scene The scene the camera belongs to
  72753. * @param webVROptions a set of customizable options for the webVRCamera
  72754. */
  72755. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  72756. /**
  72757. * Gets the device distance from the ground in meters.
  72758. * @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.
  72759. */
  72760. deviceDistanceToRoomGround(): number;
  72761. /**
  72762. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72763. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  72764. */
  72765. useStandingMatrix(callback?: (bool: boolean) => void): void;
  72766. /**
  72767. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  72768. * @returns A promise with a boolean set to if the standing matrix is supported.
  72769. */
  72770. useStandingMatrixAsync(): Promise<boolean>;
  72771. /**
  72772. * Disposes the camera
  72773. */
  72774. dispose(): void;
  72775. /**
  72776. * Gets a vrController by name.
  72777. * @param name The name of the controller to retreive
  72778. * @returns the controller matching the name specified or null if not found
  72779. */
  72780. getControllerByName(name: string): Nullable<WebVRController>;
  72781. private _leftController;
  72782. /**
  72783. * The controller corrisponding to the users left hand.
  72784. */
  72785. readonly leftController: Nullable<WebVRController>;
  72786. private _rightController;
  72787. /**
  72788. * The controller corrisponding to the users right hand.
  72789. */
  72790. readonly rightController: Nullable<WebVRController>;
  72791. /**
  72792. * Casts a ray forward from the vrCamera's gaze.
  72793. * @param length Length of the ray (default: 100)
  72794. * @returns the ray corrisponding to the gaze
  72795. */
  72796. getForwardRay(length?: number): Ray;
  72797. /**
  72798. * @hidden
  72799. * Updates the camera based on device's frame data
  72800. */
  72801. _checkInputs(): void;
  72802. /**
  72803. * Updates the poseControlled values based on the input device pose.
  72804. * @param poseData Pose coming from the device
  72805. */
  72806. updateFromDevice(poseData: DevicePose): void;
  72807. private _htmlElementAttached;
  72808. private _detachIfAttached;
  72809. /**
  72810. * WebVR's attach control will start broadcasting frames to the device.
  72811. * Note that in certain browsers (chrome for example) this function must be called
  72812. * within a user-interaction callback. Example:
  72813. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  72814. *
  72815. * @param element html element to attach the vrDevice to
  72816. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  72817. */
  72818. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  72819. /**
  72820. * Detaches the camera from the html element and disables VR
  72821. *
  72822. * @param element html element to detach from
  72823. */
  72824. detachControl(element: HTMLElement): void;
  72825. /**
  72826. * @returns the name of this class
  72827. */
  72828. getClassName(): string;
  72829. /**
  72830. * Calls resetPose on the vrDisplay
  72831. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  72832. */
  72833. resetToCurrentRotation(): void;
  72834. /**
  72835. * @hidden
  72836. * Updates the rig cameras (left and right eye)
  72837. */
  72838. _updateRigCameras(): void;
  72839. private _workingVector;
  72840. private _oneVector;
  72841. private _workingMatrix;
  72842. private updateCacheCalled;
  72843. private _correctPositionIfNotTrackPosition;
  72844. /**
  72845. * @hidden
  72846. * Updates the cached values of the camera
  72847. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  72848. */
  72849. _updateCache(ignoreParentClass?: boolean): void;
  72850. /**
  72851. * @hidden
  72852. * Get current device position in babylon world
  72853. */
  72854. _computeDevicePosition(): void;
  72855. /**
  72856. * Updates the current device position and rotation in the babylon world
  72857. */
  72858. update(): void;
  72859. /**
  72860. * @hidden
  72861. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  72862. * @returns an identity matrix
  72863. */
  72864. _getViewMatrix(): Matrix;
  72865. private _tmpMatrix;
  72866. /**
  72867. * This function is called by the two RIG cameras.
  72868. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  72869. * @hidden
  72870. */
  72871. _getWebVRViewMatrix(): Matrix;
  72872. /** @hidden */
  72873. _getWebVRProjectionMatrix(): Matrix;
  72874. private _onGamepadConnectedObserver;
  72875. private _onGamepadDisconnectedObserver;
  72876. private _updateCacheWhenTrackingDisabledObserver;
  72877. /**
  72878. * Initializes the controllers and their meshes
  72879. */
  72880. initControllers(): void;
  72881. }
  72882. }
  72883. declare module BABYLON {
  72884. /**
  72885. * Size options for a post process
  72886. */
  72887. export type PostProcessOptions = {
  72888. width: number;
  72889. height: number;
  72890. };
  72891. /**
  72892. * PostProcess can be used to apply a shader to a texture after it has been rendered
  72893. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  72894. */
  72895. export class PostProcess {
  72896. /** Name of the PostProcess. */
  72897. name: string;
  72898. /**
  72899. * Gets or sets the unique id of the post process
  72900. */
  72901. uniqueId: number;
  72902. /**
  72903. * Width of the texture to apply the post process on
  72904. */
  72905. width: number;
  72906. /**
  72907. * Height of the texture to apply the post process on
  72908. */
  72909. height: number;
  72910. /**
  72911. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  72912. * @hidden
  72913. */
  72914. _outputTexture: Nullable<InternalTexture>;
  72915. /**
  72916. * Sampling mode used by the shader
  72917. * See https://doc.babylonjs.com/classes/3.1/texture
  72918. */
  72919. renderTargetSamplingMode: number;
  72920. /**
  72921. * Clear color to use when screen clearing
  72922. */
  72923. clearColor: Color4;
  72924. /**
  72925. * If the buffer needs to be cleared before applying the post process. (default: true)
  72926. * Should be set to false if shader will overwrite all previous pixels.
  72927. */
  72928. autoClear: boolean;
  72929. /**
  72930. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  72931. */
  72932. alphaMode: number;
  72933. /**
  72934. * Sets the setAlphaBlendConstants of the babylon engine
  72935. */
  72936. alphaConstants: Color4;
  72937. /**
  72938. * Animations to be used for the post processing
  72939. */
  72940. animations: Animation[];
  72941. /**
  72942. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  72943. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  72944. */
  72945. enablePixelPerfectMode: boolean;
  72946. /**
  72947. * Force the postprocess to be applied without taking in account viewport
  72948. */
  72949. forceFullscreenViewport: boolean;
  72950. /**
  72951. * List of inspectable custom properties (used by the Inspector)
  72952. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  72953. */
  72954. inspectableCustomProperties: IInspectable[];
  72955. /**
  72956. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  72957. *
  72958. * | Value | Type | Description |
  72959. * | ----- | ----------------------------------- | ----------- |
  72960. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  72961. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  72962. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  72963. *
  72964. */
  72965. scaleMode: number;
  72966. /**
  72967. * Force textures to be a power of two (default: false)
  72968. */
  72969. alwaysForcePOT: boolean;
  72970. private _samples;
  72971. /**
  72972. * Number of sample textures (default: 1)
  72973. */
  72974. samples: number;
  72975. /**
  72976. * Modify the scale of the post process to be the same as the viewport (default: false)
  72977. */
  72978. adaptScaleToCurrentViewport: boolean;
  72979. private _camera;
  72980. private _scene;
  72981. private _engine;
  72982. private _options;
  72983. private _reusable;
  72984. private _textureType;
  72985. /**
  72986. * Smart array of input and output textures for the post process.
  72987. * @hidden
  72988. */
  72989. _textures: SmartArray<InternalTexture>;
  72990. /**
  72991. * The index in _textures that corresponds to the output texture.
  72992. * @hidden
  72993. */
  72994. _currentRenderTextureInd: number;
  72995. private _effect;
  72996. private _samplers;
  72997. private _fragmentUrl;
  72998. private _vertexUrl;
  72999. private _parameters;
  73000. private _scaleRatio;
  73001. protected _indexParameters: any;
  73002. private _shareOutputWithPostProcess;
  73003. private _texelSize;
  73004. private _forcedOutputTexture;
  73005. /**
  73006. * Returns the fragment url or shader name used in the post process.
  73007. * @returns the fragment url or name in the shader store.
  73008. */
  73009. getEffectName(): string;
  73010. /**
  73011. * An event triggered when the postprocess is activated.
  73012. */
  73013. onActivateObservable: Observable<Camera>;
  73014. private _onActivateObserver;
  73015. /**
  73016. * A function that is added to the onActivateObservable
  73017. */
  73018. onActivate: Nullable<(camera: Camera) => void>;
  73019. /**
  73020. * An event triggered when the postprocess changes its size.
  73021. */
  73022. onSizeChangedObservable: Observable<PostProcess>;
  73023. private _onSizeChangedObserver;
  73024. /**
  73025. * A function that is added to the onSizeChangedObservable
  73026. */
  73027. onSizeChanged: (postProcess: PostProcess) => void;
  73028. /**
  73029. * An event triggered when the postprocess applies its effect.
  73030. */
  73031. onApplyObservable: Observable<Effect>;
  73032. private _onApplyObserver;
  73033. /**
  73034. * A function that is added to the onApplyObservable
  73035. */
  73036. onApply: (effect: Effect) => void;
  73037. /**
  73038. * An event triggered before rendering the postprocess
  73039. */
  73040. onBeforeRenderObservable: Observable<Effect>;
  73041. private _onBeforeRenderObserver;
  73042. /**
  73043. * A function that is added to the onBeforeRenderObservable
  73044. */
  73045. onBeforeRender: (effect: Effect) => void;
  73046. /**
  73047. * An event triggered after rendering the postprocess
  73048. */
  73049. onAfterRenderObservable: Observable<Effect>;
  73050. private _onAfterRenderObserver;
  73051. /**
  73052. * A function that is added to the onAfterRenderObservable
  73053. */
  73054. onAfterRender: (efect: Effect) => void;
  73055. /**
  73056. * 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
  73057. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  73058. */
  73059. inputTexture: InternalTexture;
  73060. /**
  73061. * Gets the camera which post process is applied to.
  73062. * @returns The camera the post process is applied to.
  73063. */
  73064. getCamera(): Camera;
  73065. /**
  73066. * Gets the texel size of the postprocess.
  73067. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  73068. */
  73069. readonly texelSize: Vector2;
  73070. /**
  73071. * Creates a new instance PostProcess
  73072. * @param name The name of the PostProcess.
  73073. * @param fragmentUrl The url of the fragment shader to be used.
  73074. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  73075. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  73076. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  73077. * @param camera The camera to apply the render pass to.
  73078. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73079. * @param engine The engine which the post process will be applied. (default: current engine)
  73080. * @param reusable If the post process can be reused on the same frame. (default: false)
  73081. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  73082. * @param textureType Type of textures used when performing the post process. (default: 0)
  73083. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  73084. * @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
  73085. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  73086. */
  73087. constructor(
  73088. /** Name of the PostProcess. */
  73089. 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);
  73090. /**
  73091. * Gets a string idenfifying the name of the class
  73092. * @returns "PostProcess" string
  73093. */
  73094. getClassName(): string;
  73095. /**
  73096. * Gets the engine which this post process belongs to.
  73097. * @returns The engine the post process was enabled with.
  73098. */
  73099. getEngine(): Engine;
  73100. /**
  73101. * The effect that is created when initializing the post process.
  73102. * @returns The created effect corrisponding the the postprocess.
  73103. */
  73104. getEffect(): Effect;
  73105. /**
  73106. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  73107. * @param postProcess The post process to share the output with.
  73108. * @returns This post process.
  73109. */
  73110. shareOutputWith(postProcess: PostProcess): PostProcess;
  73111. /**
  73112. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  73113. * This should be called if the post process that shares output with this post process is disabled/disposed.
  73114. */
  73115. useOwnOutput(): void;
  73116. /**
  73117. * Updates the effect with the current post process compile time values and recompiles the shader.
  73118. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73119. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73120. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73121. * @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
  73122. * @param onCompiled Called when the shader has been compiled.
  73123. * @param onError Called if there is an error when compiling a shader.
  73124. */
  73125. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73126. /**
  73127. * The post process is reusable if it can be used multiple times within one frame.
  73128. * @returns If the post process is reusable
  73129. */
  73130. isReusable(): boolean;
  73131. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  73132. markTextureDirty(): void;
  73133. /**
  73134. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  73135. * 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.
  73136. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  73137. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  73138. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  73139. * @returns The target texture that was bound to be written to.
  73140. */
  73141. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  73142. /**
  73143. * If the post process is supported.
  73144. */
  73145. readonly isSupported: boolean;
  73146. /**
  73147. * The aspect ratio of the output texture.
  73148. */
  73149. readonly aspectRatio: number;
  73150. /**
  73151. * Get a value indicating if the post-process is ready to be used
  73152. * @returns true if the post-process is ready (shader is compiled)
  73153. */
  73154. isReady(): boolean;
  73155. /**
  73156. * Binds all textures and uniforms to the shader, this will be run on every pass.
  73157. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  73158. */
  73159. apply(): Nullable<Effect>;
  73160. private _disposeTextures;
  73161. /**
  73162. * Disposes the post process.
  73163. * @param camera The camera to dispose the post process on.
  73164. */
  73165. dispose(camera?: Camera): void;
  73166. }
  73167. }
  73168. declare module BABYLON {
  73169. /**
  73170. * PostProcessManager is used to manage one or more post processes or post process pipelines
  73171. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73172. */
  73173. export class PostProcessManager {
  73174. private _scene;
  73175. private _indexBuffer;
  73176. private _vertexBuffers;
  73177. /**
  73178. * Creates a new instance PostProcess
  73179. * @param scene The scene that the post process is associated with.
  73180. */
  73181. constructor(scene: Scene);
  73182. private _prepareBuffers;
  73183. private _buildIndexBuffer;
  73184. /**
  73185. * Rebuilds the vertex buffers of the manager.
  73186. * @hidden
  73187. */
  73188. _rebuild(): void;
  73189. /**
  73190. * Prepares a frame to be run through a post process.
  73191. * @param sourceTexture The input texture to the post procesess. (default: null)
  73192. * @param postProcesses An array of post processes to be run. (default: null)
  73193. * @returns True if the post processes were able to be run.
  73194. * @hidden
  73195. */
  73196. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  73197. /**
  73198. * Manually render a set of post processes to a texture.
  73199. * @param postProcesses An array of post processes to be run.
  73200. * @param targetTexture The target texture to render to.
  73201. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  73202. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  73203. * @param lodLevel defines which lod of the texture to render to
  73204. */
  73205. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number): void;
  73206. /**
  73207. * Finalize the result of the output of the postprocesses.
  73208. * @param doNotPresent If true the result will not be displayed to the screen.
  73209. * @param targetTexture The target texture to render to.
  73210. * @param faceIndex The index of the face to bind the target texture to.
  73211. * @param postProcesses The array of post processes to render.
  73212. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  73213. * @hidden
  73214. */
  73215. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  73216. /**
  73217. * Disposes of the post process manager.
  73218. */
  73219. dispose(): void;
  73220. }
  73221. }
  73222. declare module BABYLON {
  73223. interface AbstractScene {
  73224. /**
  73225. * The list of layers (background and foreground) of the scene
  73226. */
  73227. layers: Array<Layer>;
  73228. }
  73229. /**
  73230. * Defines the layer scene component responsible to manage any layers
  73231. * in a given scene.
  73232. */
  73233. export class LayerSceneComponent implements ISceneComponent {
  73234. /**
  73235. * The component name helpfull to identify the component in the list of scene components.
  73236. */
  73237. readonly name: string;
  73238. /**
  73239. * The scene the component belongs to.
  73240. */
  73241. scene: Scene;
  73242. private _engine;
  73243. /**
  73244. * Creates a new instance of the component for the given scene
  73245. * @param scene Defines the scene to register the component in
  73246. */
  73247. constructor(scene: Scene);
  73248. /**
  73249. * Registers the component in a given scene
  73250. */
  73251. register(): void;
  73252. /**
  73253. * Rebuilds the elements related to this component in case of
  73254. * context lost for instance.
  73255. */
  73256. rebuild(): void;
  73257. /**
  73258. * Disposes the component and the associated ressources.
  73259. */
  73260. dispose(): void;
  73261. private _draw;
  73262. private _drawCameraPredicate;
  73263. private _drawCameraBackground;
  73264. private _drawCameraForeground;
  73265. private _drawRenderTargetPredicate;
  73266. private _drawRenderTargetBackground;
  73267. private _drawRenderTargetForeground;
  73268. }
  73269. }
  73270. declare module BABYLON {
  73271. /** @hidden */
  73272. export var layerPixelShader: {
  73273. name: string;
  73274. shader: string;
  73275. };
  73276. }
  73277. declare module BABYLON {
  73278. /** @hidden */
  73279. export var layerVertexShader: {
  73280. name: string;
  73281. shader: string;
  73282. };
  73283. }
  73284. declare module BABYLON {
  73285. /**
  73286. * This represents a full screen 2d layer.
  73287. * This can be useful to display a picture in the background of your scene for instance.
  73288. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73289. */
  73290. export class Layer {
  73291. /**
  73292. * Define the name of the layer.
  73293. */
  73294. name: string;
  73295. /**
  73296. * Define the texture the layer should display.
  73297. */
  73298. texture: Nullable<Texture>;
  73299. /**
  73300. * Is the layer in background or foreground.
  73301. */
  73302. isBackground: boolean;
  73303. /**
  73304. * Define the color of the layer (instead of texture).
  73305. */
  73306. color: Color4;
  73307. /**
  73308. * Define the scale of the layer in order to zoom in out of the texture.
  73309. */
  73310. scale: Vector2;
  73311. /**
  73312. * Define an offset for the layer in order to shift the texture.
  73313. */
  73314. offset: Vector2;
  73315. /**
  73316. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  73317. */
  73318. alphaBlendingMode: number;
  73319. /**
  73320. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  73321. * Alpha test will not mix with the background color in case of transparency.
  73322. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  73323. */
  73324. alphaTest: boolean;
  73325. /**
  73326. * Define a mask to restrict the layer to only some of the scene cameras.
  73327. */
  73328. layerMask: number;
  73329. /**
  73330. * Define the list of render target the layer is visible into.
  73331. */
  73332. renderTargetTextures: RenderTargetTexture[];
  73333. /**
  73334. * Define if the layer is only used in renderTarget or if it also
  73335. * renders in the main frame buffer of the canvas.
  73336. */
  73337. renderOnlyInRenderTargetTextures: boolean;
  73338. private _scene;
  73339. private _vertexBuffers;
  73340. private _indexBuffer;
  73341. private _effect;
  73342. private _alphaTestEffect;
  73343. /**
  73344. * An event triggered when the layer is disposed.
  73345. */
  73346. onDisposeObservable: Observable<Layer>;
  73347. private _onDisposeObserver;
  73348. /**
  73349. * Back compatibility with callback before the onDisposeObservable existed.
  73350. * The set callback will be triggered when the layer has been disposed.
  73351. */
  73352. onDispose: () => void;
  73353. /**
  73354. * An event triggered before rendering the scene
  73355. */
  73356. onBeforeRenderObservable: Observable<Layer>;
  73357. private _onBeforeRenderObserver;
  73358. /**
  73359. * Back compatibility with callback before the onBeforeRenderObservable existed.
  73360. * The set callback will be triggered just before rendering the layer.
  73361. */
  73362. onBeforeRender: () => void;
  73363. /**
  73364. * An event triggered after rendering the scene
  73365. */
  73366. onAfterRenderObservable: Observable<Layer>;
  73367. private _onAfterRenderObserver;
  73368. /**
  73369. * Back compatibility with callback before the onAfterRenderObservable existed.
  73370. * The set callback will be triggered just after rendering the layer.
  73371. */
  73372. onAfterRender: () => void;
  73373. /**
  73374. * Instantiates a new layer.
  73375. * This represents a full screen 2d layer.
  73376. * This can be useful to display a picture in the background of your scene for instance.
  73377. * @see https://www.babylonjs-playground.com/#08A2BS#1
  73378. * @param name Define the name of the layer in the scene
  73379. * @param imgUrl Define the url of the texture to display in the layer
  73380. * @param scene Define the scene the layer belongs to
  73381. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  73382. * @param color Defines a color for the layer
  73383. */
  73384. constructor(
  73385. /**
  73386. * Define the name of the layer.
  73387. */
  73388. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  73389. private _createIndexBuffer;
  73390. /** @hidden */
  73391. _rebuild(): void;
  73392. /**
  73393. * Renders the layer in the scene.
  73394. */
  73395. render(): void;
  73396. /**
  73397. * Disposes and releases the associated ressources.
  73398. */
  73399. dispose(): void;
  73400. }
  73401. }
  73402. declare module BABYLON {
  73403. interface AbstractScene {
  73404. /**
  73405. * The list of procedural textures added to the scene
  73406. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73407. */
  73408. proceduralTextures: Array<ProceduralTexture>;
  73409. }
  73410. /**
  73411. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  73412. * in a given scene.
  73413. */
  73414. export class ProceduralTextureSceneComponent implements ISceneComponent {
  73415. /**
  73416. * The component name helpfull to identify the component in the list of scene components.
  73417. */
  73418. readonly name: string;
  73419. /**
  73420. * The scene the component belongs to.
  73421. */
  73422. scene: Scene;
  73423. /**
  73424. * Creates a new instance of the component for the given scene
  73425. * @param scene Defines the scene to register the component in
  73426. */
  73427. constructor(scene: Scene);
  73428. /**
  73429. * Registers the component in a given scene
  73430. */
  73431. register(): void;
  73432. /**
  73433. * Rebuilds the elements related to this component in case of
  73434. * context lost for instance.
  73435. */
  73436. rebuild(): void;
  73437. /**
  73438. * Disposes the component and the associated ressources.
  73439. */
  73440. dispose(): void;
  73441. private _beforeClear;
  73442. }
  73443. }
  73444. declare module BABYLON {
  73445. /** @hidden */
  73446. export var proceduralVertexShader: {
  73447. name: string;
  73448. shader: string;
  73449. };
  73450. }
  73451. declare module BABYLON {
  73452. /**
  73453. * 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.
  73454. * This is the base class of any Procedural texture and contains most of the shareable code.
  73455. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73456. */
  73457. export class ProceduralTexture extends Texture {
  73458. isCube: boolean;
  73459. /**
  73460. * Define if the texture is enabled or not (disabled texture will not render)
  73461. */
  73462. isEnabled: boolean;
  73463. /**
  73464. * Define if the texture must be cleared before rendering (default is true)
  73465. */
  73466. autoClear: boolean;
  73467. /**
  73468. * Callback called when the texture is generated
  73469. */
  73470. onGenerated: () => void;
  73471. /**
  73472. * Event raised when the texture is generated
  73473. */
  73474. onGeneratedObservable: Observable<ProceduralTexture>;
  73475. /** @hidden */
  73476. _generateMipMaps: boolean;
  73477. /** @hidden **/
  73478. _effect: Effect;
  73479. /** @hidden */
  73480. _textures: {
  73481. [key: string]: Texture;
  73482. };
  73483. private _size;
  73484. private _currentRefreshId;
  73485. private _refreshRate;
  73486. private _vertexBuffers;
  73487. private _indexBuffer;
  73488. private _uniforms;
  73489. private _samplers;
  73490. private _fragment;
  73491. private _floats;
  73492. private _ints;
  73493. private _floatsArrays;
  73494. private _colors3;
  73495. private _colors4;
  73496. private _vectors2;
  73497. private _vectors3;
  73498. private _matrices;
  73499. private _fallbackTexture;
  73500. private _fallbackTextureUsed;
  73501. private _engine;
  73502. private _cachedDefines;
  73503. private _contentUpdateId;
  73504. private _contentData;
  73505. /**
  73506. * Instantiates a new procedural texture.
  73507. * 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.
  73508. * This is the base class of any Procedural texture and contains most of the shareable code.
  73509. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  73510. * @param name Define the name of the texture
  73511. * @param size Define the size of the texture to create
  73512. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  73513. * @param scene Define the scene the texture belongs to
  73514. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  73515. * @param generateMipMaps Define if the texture should creates mip maps or not
  73516. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  73517. */
  73518. constructor(name: string, size: any, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean);
  73519. /**
  73520. * The effect that is created when initializing the post process.
  73521. * @returns The created effect corrisponding the the postprocess.
  73522. */
  73523. getEffect(): Effect;
  73524. /**
  73525. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  73526. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  73527. */
  73528. getContent(): Nullable<ArrayBufferView>;
  73529. private _createIndexBuffer;
  73530. /** @hidden */
  73531. _rebuild(): void;
  73532. /**
  73533. * Resets the texture in order to recreate its associated resources.
  73534. * This can be called in case of context loss
  73535. */
  73536. reset(): void;
  73537. protected _getDefines(): string;
  73538. /**
  73539. * Is the texture ready to be used ? (rendered at least once)
  73540. * @returns true if ready, otherwise, false.
  73541. */
  73542. isReady(): boolean;
  73543. /**
  73544. * Resets the refresh counter of the texture and start bak from scratch.
  73545. * Could be useful to regenerate the texture if it is setup to render only once.
  73546. */
  73547. resetRefreshCounter(): void;
  73548. /**
  73549. * Set the fragment shader to use in order to render the texture.
  73550. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  73551. */
  73552. setFragment(fragment: any): void;
  73553. /**
  73554. * Define the refresh rate of the texture or the rendering frequency.
  73555. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  73556. */
  73557. refreshRate: number;
  73558. /** @hidden */
  73559. _shouldRender(): boolean;
  73560. /**
  73561. * Get the size the texture is rendering at.
  73562. * @returns the size (texture is always squared)
  73563. */
  73564. getRenderSize(): number;
  73565. /**
  73566. * Resize the texture to new value.
  73567. * @param size Define the new size the texture should have
  73568. * @param generateMipMaps Define whether the new texture should create mip maps
  73569. */
  73570. resize(size: number, generateMipMaps: boolean): void;
  73571. private _checkUniform;
  73572. /**
  73573. * Set a texture in the shader program used to render.
  73574. * @param name Define the name of the uniform samplers as defined in the shader
  73575. * @param texture Define the texture to bind to this sampler
  73576. * @return the texture itself allowing "fluent" like uniform updates
  73577. */
  73578. setTexture(name: string, texture: Texture): ProceduralTexture;
  73579. /**
  73580. * Set a float in the shader.
  73581. * @param name Define the name of the uniform as defined in the shader
  73582. * @param value Define the value to give to the uniform
  73583. * @return the texture itself allowing "fluent" like uniform updates
  73584. */
  73585. setFloat(name: string, value: number): ProceduralTexture;
  73586. /**
  73587. * Set a int in the shader.
  73588. * @param name Define the name of the uniform as defined in the shader
  73589. * @param value Define the value to give to the uniform
  73590. * @return the texture itself allowing "fluent" like uniform updates
  73591. */
  73592. setInt(name: string, value: number): ProceduralTexture;
  73593. /**
  73594. * Set an array of floats in the shader.
  73595. * @param name Define the name of the uniform as defined in the shader
  73596. * @param value Define the value to give to the uniform
  73597. * @return the texture itself allowing "fluent" like uniform updates
  73598. */
  73599. setFloats(name: string, value: number[]): ProceduralTexture;
  73600. /**
  73601. * Set a vec3 in the shader from a Color3.
  73602. * @param name Define the name of the uniform as defined in the shader
  73603. * @param value Define the value to give to the uniform
  73604. * @return the texture itself allowing "fluent" like uniform updates
  73605. */
  73606. setColor3(name: string, value: Color3): ProceduralTexture;
  73607. /**
  73608. * Set a vec4 in the shader from a Color4.
  73609. * @param name Define the name of the uniform as defined in the shader
  73610. * @param value Define the value to give to the uniform
  73611. * @return the texture itself allowing "fluent" like uniform updates
  73612. */
  73613. setColor4(name: string, value: Color4): ProceduralTexture;
  73614. /**
  73615. * Set a vec2 in the shader from a Vector2.
  73616. * @param name Define the name of the uniform as defined in the shader
  73617. * @param value Define the value to give to the uniform
  73618. * @return the texture itself allowing "fluent" like uniform updates
  73619. */
  73620. setVector2(name: string, value: Vector2): ProceduralTexture;
  73621. /**
  73622. * Set a vec3 in the shader from a Vector3.
  73623. * @param name Define the name of the uniform as defined in the shader
  73624. * @param value Define the value to give to the uniform
  73625. * @return the texture itself allowing "fluent" like uniform updates
  73626. */
  73627. setVector3(name: string, value: Vector3): ProceduralTexture;
  73628. /**
  73629. * Set a mat4 in the shader from a MAtrix.
  73630. * @param name Define the name of the uniform as defined in the shader
  73631. * @param value Define the value to give to the uniform
  73632. * @return the texture itself allowing "fluent" like uniform updates
  73633. */
  73634. setMatrix(name: string, value: Matrix): ProceduralTexture;
  73635. /**
  73636. * Render the texture to its associated render target.
  73637. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  73638. */
  73639. render(useCameraPostProcess?: boolean): void;
  73640. /**
  73641. * Clone the texture.
  73642. * @returns the cloned texture
  73643. */
  73644. clone(): ProceduralTexture;
  73645. /**
  73646. * Dispose the texture and release its asoociated resources.
  73647. */
  73648. dispose(): void;
  73649. }
  73650. }
  73651. declare module BABYLON {
  73652. /**
  73653. * This represents the base class for particle system in Babylon.
  73654. * 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.
  73655. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  73656. * @example https://doc.babylonjs.com/babylon101/particles
  73657. */
  73658. export class BaseParticleSystem {
  73659. /**
  73660. * Source color is added to the destination color without alpha affecting the result
  73661. */
  73662. static BLENDMODE_ONEONE: number;
  73663. /**
  73664. * Blend current color and particle color using particle’s alpha
  73665. */
  73666. static BLENDMODE_STANDARD: number;
  73667. /**
  73668. * Add current color and particle color multiplied by particle’s alpha
  73669. */
  73670. static BLENDMODE_ADD: number;
  73671. /**
  73672. * Multiply current color with particle color
  73673. */
  73674. static BLENDMODE_MULTIPLY: number;
  73675. /**
  73676. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  73677. */
  73678. static BLENDMODE_MULTIPLYADD: number;
  73679. /**
  73680. * List of animations used by the particle system.
  73681. */
  73682. animations: Animation[];
  73683. /**
  73684. * The id of the Particle system.
  73685. */
  73686. id: string;
  73687. /**
  73688. * The friendly name of the Particle system.
  73689. */
  73690. name: string;
  73691. /**
  73692. * The rendering group used by the Particle system to chose when to render.
  73693. */
  73694. renderingGroupId: number;
  73695. /**
  73696. * The emitter represents the Mesh or position we are attaching the particle system to.
  73697. */
  73698. emitter: Nullable<AbstractMesh | Vector3>;
  73699. /**
  73700. * The maximum number of particles to emit per frame
  73701. */
  73702. emitRate: number;
  73703. /**
  73704. * If you want to launch only a few particles at once, that can be done, as well.
  73705. */
  73706. manualEmitCount: number;
  73707. /**
  73708. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  73709. */
  73710. updateSpeed: number;
  73711. /**
  73712. * The amount of time the particle system is running (depends of the overall update speed).
  73713. */
  73714. targetStopDuration: number;
  73715. /**
  73716. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  73717. */
  73718. disposeOnStop: boolean;
  73719. /**
  73720. * Minimum power of emitting particles.
  73721. */
  73722. minEmitPower: number;
  73723. /**
  73724. * Maximum power of emitting particles.
  73725. */
  73726. maxEmitPower: number;
  73727. /**
  73728. * Minimum life time of emitting particles.
  73729. */
  73730. minLifeTime: number;
  73731. /**
  73732. * Maximum life time of emitting particles.
  73733. */
  73734. maxLifeTime: number;
  73735. /**
  73736. * Minimum Size of emitting particles.
  73737. */
  73738. minSize: number;
  73739. /**
  73740. * Maximum Size of emitting particles.
  73741. */
  73742. maxSize: number;
  73743. /**
  73744. * Minimum scale of emitting particles on X axis.
  73745. */
  73746. minScaleX: number;
  73747. /**
  73748. * Maximum scale of emitting particles on X axis.
  73749. */
  73750. maxScaleX: number;
  73751. /**
  73752. * Minimum scale of emitting particles on Y axis.
  73753. */
  73754. minScaleY: number;
  73755. /**
  73756. * Maximum scale of emitting particles on Y axis.
  73757. */
  73758. maxScaleY: number;
  73759. /**
  73760. * Gets or sets the minimal initial rotation in radians.
  73761. */
  73762. minInitialRotation: number;
  73763. /**
  73764. * Gets or sets the maximal initial rotation in radians.
  73765. */
  73766. maxInitialRotation: number;
  73767. /**
  73768. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  73769. */
  73770. minAngularSpeed: number;
  73771. /**
  73772. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  73773. */
  73774. maxAngularSpeed: number;
  73775. /**
  73776. * The texture used to render each particle. (this can be a spritesheet)
  73777. */
  73778. particleTexture: Nullable<Texture>;
  73779. /**
  73780. * The layer mask we are rendering the particles through.
  73781. */
  73782. layerMask: number;
  73783. /**
  73784. * This can help using your own shader to render the particle system.
  73785. * The according effect will be created
  73786. */
  73787. customShader: any;
  73788. /**
  73789. * By default particle system starts as soon as they are created. This prevents the
  73790. * automatic start to happen and let you decide when to start emitting particles.
  73791. */
  73792. preventAutoStart: boolean;
  73793. private _noiseTexture;
  73794. /**
  73795. * Gets or sets a texture used to add random noise to particle positions
  73796. */
  73797. noiseTexture: Nullable<ProceduralTexture>;
  73798. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  73799. noiseStrength: Vector3;
  73800. /**
  73801. * Callback triggered when the particle animation is ending.
  73802. */
  73803. onAnimationEnd: Nullable<() => void>;
  73804. /**
  73805. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  73806. */
  73807. blendMode: number;
  73808. /**
  73809. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  73810. * to override the particles.
  73811. */
  73812. forceDepthWrite: boolean;
  73813. /** 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 */
  73814. preWarmCycles: number;
  73815. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  73816. preWarmStepOffset: number;
  73817. /**
  73818. * 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)
  73819. */
  73820. spriteCellChangeSpeed: number;
  73821. /**
  73822. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  73823. */
  73824. startSpriteCellID: number;
  73825. /**
  73826. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  73827. */
  73828. endSpriteCellID: number;
  73829. /**
  73830. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  73831. */
  73832. spriteCellWidth: number;
  73833. /**
  73834. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  73835. */
  73836. spriteCellHeight: number;
  73837. /**
  73838. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  73839. */
  73840. spriteRandomStartCell: boolean;
  73841. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  73842. translationPivot: Vector2;
  73843. /** @hidden */
  73844. protected _isAnimationSheetEnabled: boolean;
  73845. /**
  73846. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  73847. */
  73848. beginAnimationOnStart: boolean;
  73849. /**
  73850. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  73851. */
  73852. beginAnimationFrom: number;
  73853. /**
  73854. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  73855. */
  73856. beginAnimationTo: number;
  73857. /**
  73858. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  73859. */
  73860. beginAnimationLoop: boolean;
  73861. /**
  73862. * Gets or sets a world offset applied to all particles
  73863. */
  73864. worldOffset: Vector3;
  73865. /**
  73866. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  73867. */
  73868. isAnimationSheetEnabled: boolean;
  73869. /**
  73870. * Get hosting scene
  73871. * @returns the scene
  73872. */
  73873. getScene(): Scene;
  73874. /**
  73875. * You can use gravity if you want to give an orientation to your particles.
  73876. */
  73877. gravity: Vector3;
  73878. protected _colorGradients: Nullable<Array<ColorGradient>>;
  73879. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  73880. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  73881. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  73882. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  73883. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  73884. protected _dragGradients: Nullable<Array<FactorGradient>>;
  73885. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  73886. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  73887. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  73888. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  73889. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  73890. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  73891. /**
  73892. * Defines the delay in milliseconds before starting the system (0 by default)
  73893. */
  73894. startDelay: number;
  73895. /**
  73896. * Gets the current list of drag gradients.
  73897. * You must use addDragGradient and removeDragGradient to udpate this list
  73898. * @returns the list of drag gradients
  73899. */
  73900. getDragGradients(): Nullable<Array<FactorGradient>>;
  73901. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  73902. limitVelocityDamping: number;
  73903. /**
  73904. * Gets the current list of limit velocity gradients.
  73905. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  73906. * @returns the list of limit velocity gradients
  73907. */
  73908. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  73909. /**
  73910. * Gets the current list of color gradients.
  73911. * You must use addColorGradient and removeColorGradient to udpate this list
  73912. * @returns the list of color gradients
  73913. */
  73914. getColorGradients(): Nullable<Array<ColorGradient>>;
  73915. /**
  73916. * Gets the current list of size gradients.
  73917. * You must use addSizeGradient and removeSizeGradient to udpate this list
  73918. * @returns the list of size gradients
  73919. */
  73920. getSizeGradients(): Nullable<Array<FactorGradient>>;
  73921. /**
  73922. * Gets the current list of color remap gradients.
  73923. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  73924. * @returns the list of color remap gradients
  73925. */
  73926. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  73927. /**
  73928. * Gets the current list of alpha remap gradients.
  73929. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  73930. * @returns the list of alpha remap gradients
  73931. */
  73932. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  73933. /**
  73934. * Gets the current list of life time gradients.
  73935. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  73936. * @returns the list of life time gradients
  73937. */
  73938. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  73939. /**
  73940. * Gets the current list of angular speed gradients.
  73941. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  73942. * @returns the list of angular speed gradients
  73943. */
  73944. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  73945. /**
  73946. * Gets the current list of velocity gradients.
  73947. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  73948. * @returns the list of velocity gradients
  73949. */
  73950. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  73951. /**
  73952. * Gets the current list of start size gradients.
  73953. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  73954. * @returns the list of start size gradients
  73955. */
  73956. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  73957. /**
  73958. * Gets the current list of emit rate gradients.
  73959. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  73960. * @returns the list of emit rate gradients
  73961. */
  73962. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  73963. /**
  73964. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73965. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73966. */
  73967. direction1: Vector3;
  73968. /**
  73969. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  73970. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73971. */
  73972. direction2: Vector3;
  73973. /**
  73974. * 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.
  73975. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73976. */
  73977. minEmitBox: Vector3;
  73978. /**
  73979. * 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.
  73980. * This only works when particleEmitterTyps is a BoxParticleEmitter
  73981. */
  73982. maxEmitBox: Vector3;
  73983. /**
  73984. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73985. */
  73986. color1: Color4;
  73987. /**
  73988. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  73989. */
  73990. color2: Color4;
  73991. /**
  73992. * Color the particle will have at the end of its lifetime
  73993. */
  73994. colorDead: Color4;
  73995. /**
  73996. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  73997. */
  73998. textureMask: Color4;
  73999. /**
  74000. * The particle emitter type defines the emitter used by the particle system.
  74001. * It can be for example box, sphere, or cone...
  74002. */
  74003. particleEmitterType: IParticleEmitterType;
  74004. /** @hidden */
  74005. _isSubEmitter: boolean;
  74006. /**
  74007. * Gets or sets the billboard mode to use when isBillboardBased = true.
  74008. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  74009. */
  74010. billboardMode: number;
  74011. protected _isBillboardBased: boolean;
  74012. /**
  74013. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  74014. */
  74015. isBillboardBased: boolean;
  74016. /**
  74017. * The scene the particle system belongs to.
  74018. */
  74019. protected _scene: Scene;
  74020. /**
  74021. * Local cache of defines for image processing.
  74022. */
  74023. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  74024. /**
  74025. * Default configuration related to image processing available in the standard Material.
  74026. */
  74027. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  74028. /**
  74029. * Gets the image processing configuration used either in this material.
  74030. */
  74031. /**
  74032. * Sets the Default image processing configuration used either in the this material.
  74033. *
  74034. * If sets to null, the scene one is in use.
  74035. */
  74036. imageProcessingConfiguration: ImageProcessingConfiguration;
  74037. /**
  74038. * Attaches a new image processing configuration to the Standard Material.
  74039. * @param configuration
  74040. */
  74041. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  74042. /** @hidden */
  74043. protected _reset(): void;
  74044. /** @hidden */
  74045. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  74046. /**
  74047. * Instantiates a particle system.
  74048. * 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.
  74049. * @param name The name of the particle system
  74050. */
  74051. constructor(name: string);
  74052. /**
  74053. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  74054. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74055. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74056. * @returns the emitter
  74057. */
  74058. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  74059. /**
  74060. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  74061. * @param radius The radius of the hemisphere to emit from
  74062. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74063. * @returns the emitter
  74064. */
  74065. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  74066. /**
  74067. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  74068. * @param radius The radius of the sphere to emit from
  74069. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  74070. * @returns the emitter
  74071. */
  74072. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  74073. /**
  74074. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  74075. * @param radius The radius of the sphere to emit from
  74076. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  74077. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  74078. * @returns the emitter
  74079. */
  74080. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  74081. /**
  74082. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  74083. * @param radius The radius of the emission cylinder
  74084. * @param height The height of the emission cylinder
  74085. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  74086. * @param directionRandomizer How much to randomize the particle direction [0-1]
  74087. * @returns the emitter
  74088. */
  74089. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  74090. /**
  74091. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  74092. * @param radius The radius of the cylinder to emit from
  74093. * @param height The height of the emission cylinder
  74094. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  74095. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  74096. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  74097. * @returns the emitter
  74098. */
  74099. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  74100. /**
  74101. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  74102. * @param radius The radius of the cone to emit from
  74103. * @param angle The base angle of the cone
  74104. * @returns the emitter
  74105. */
  74106. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  74107. /**
  74108. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  74109. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  74110. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  74111. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74112. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  74113. * @returns the emitter
  74114. */
  74115. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  74116. }
  74117. }
  74118. declare module BABYLON {
  74119. /**
  74120. * Type of sub emitter
  74121. */
  74122. export enum SubEmitterType {
  74123. /**
  74124. * Attached to the particle over it's lifetime
  74125. */
  74126. ATTACHED = 0,
  74127. /**
  74128. * Created when the particle dies
  74129. */
  74130. END = 1
  74131. }
  74132. /**
  74133. * Sub emitter class used to emit particles from an existing particle
  74134. */
  74135. export class SubEmitter {
  74136. /**
  74137. * the particle system to be used by the sub emitter
  74138. */
  74139. particleSystem: ParticleSystem;
  74140. /**
  74141. * Type of the submitter (Default: END)
  74142. */
  74143. type: SubEmitterType;
  74144. /**
  74145. * 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)
  74146. * Note: This only is supported when using an emitter of type Mesh
  74147. */
  74148. inheritDirection: boolean;
  74149. /**
  74150. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  74151. */
  74152. inheritedVelocityAmount: number;
  74153. /**
  74154. * Creates a sub emitter
  74155. * @param particleSystem the particle system to be used by the sub emitter
  74156. */
  74157. constructor(
  74158. /**
  74159. * the particle system to be used by the sub emitter
  74160. */
  74161. particleSystem: ParticleSystem);
  74162. /**
  74163. * Clones the sub emitter
  74164. * @returns the cloned sub emitter
  74165. */
  74166. clone(): SubEmitter;
  74167. /**
  74168. * Serialize current object to a JSON object
  74169. * @returns the serialized object
  74170. */
  74171. serialize(): any;
  74172. /** @hidden */
  74173. static _ParseParticleSystem(system: any, scene: Scene, rootUrl: string): ParticleSystem;
  74174. /**
  74175. * Creates a new SubEmitter from a serialized JSON version
  74176. * @param serializationObject defines the JSON object to read from
  74177. * @param scene defines the hosting scene
  74178. * @param rootUrl defines the rootUrl for data loading
  74179. * @returns a new SubEmitter
  74180. */
  74181. static Parse(serializationObject: any, scene: Scene, rootUrl: string): SubEmitter;
  74182. /** Release associated resources */
  74183. dispose(): void;
  74184. }
  74185. }
  74186. declare module BABYLON {
  74187. /** @hidden */
  74188. export var clipPlaneFragmentDeclaration: {
  74189. name: string;
  74190. shader: string;
  74191. };
  74192. }
  74193. declare module BABYLON {
  74194. /** @hidden */
  74195. export var imageProcessingDeclaration: {
  74196. name: string;
  74197. shader: string;
  74198. };
  74199. }
  74200. declare module BABYLON {
  74201. /** @hidden */
  74202. export var imageProcessingFunctions: {
  74203. name: string;
  74204. shader: string;
  74205. };
  74206. }
  74207. declare module BABYLON {
  74208. /** @hidden */
  74209. export var clipPlaneFragment: {
  74210. name: string;
  74211. shader: string;
  74212. };
  74213. }
  74214. declare module BABYLON {
  74215. /** @hidden */
  74216. export var particlesPixelShader: {
  74217. name: string;
  74218. shader: string;
  74219. };
  74220. }
  74221. declare module BABYLON {
  74222. /** @hidden */
  74223. export var clipPlaneVertexDeclaration: {
  74224. name: string;
  74225. shader: string;
  74226. };
  74227. }
  74228. declare module BABYLON {
  74229. /** @hidden */
  74230. export var clipPlaneVertex: {
  74231. name: string;
  74232. shader: string;
  74233. };
  74234. }
  74235. declare module BABYLON {
  74236. /** @hidden */
  74237. export var particlesVertexShader: {
  74238. name: string;
  74239. shader: string;
  74240. };
  74241. }
  74242. declare module BABYLON {
  74243. /**
  74244. * This represents a particle system in Babylon.
  74245. * 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.
  74246. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  74247. * @example https://doc.babylonjs.com/babylon101/particles
  74248. */
  74249. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  74250. /**
  74251. * Billboard mode will only apply to Y axis
  74252. */
  74253. static readonly BILLBOARDMODE_Y: number;
  74254. /**
  74255. * Billboard mode will apply to all axes
  74256. */
  74257. static readonly BILLBOARDMODE_ALL: number;
  74258. /**
  74259. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  74260. */
  74261. static readonly BILLBOARDMODE_STRETCHED: number;
  74262. /**
  74263. * This function can be defined to provide custom update for active particles.
  74264. * This function will be called instead of regular update (age, position, color, etc.).
  74265. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  74266. */
  74267. updateFunction: (particles: Particle[]) => void;
  74268. private _emitterWorldMatrix;
  74269. /**
  74270. * This function can be defined to specify initial direction for every new particle.
  74271. * It by default use the emitterType defined function
  74272. */
  74273. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle) => void;
  74274. /**
  74275. * This function can be defined to specify initial position for every new particle.
  74276. * It by default use the emitterType defined function
  74277. */
  74278. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle) => void;
  74279. /**
  74280. * @hidden
  74281. */
  74282. _inheritedVelocityOffset: Vector3;
  74283. /**
  74284. * An event triggered when the system is disposed
  74285. */
  74286. onDisposeObservable: Observable<ParticleSystem>;
  74287. private _onDisposeObserver;
  74288. /**
  74289. * Sets a callback that will be triggered when the system is disposed
  74290. */
  74291. onDispose: () => void;
  74292. private _particles;
  74293. private _epsilon;
  74294. private _capacity;
  74295. private _stockParticles;
  74296. private _newPartsExcess;
  74297. private _vertexData;
  74298. private _vertexBuffer;
  74299. private _vertexBuffers;
  74300. private _spriteBuffer;
  74301. private _indexBuffer;
  74302. private _effect;
  74303. private _customEffect;
  74304. private _cachedDefines;
  74305. private _scaledColorStep;
  74306. private _colorDiff;
  74307. private _scaledDirection;
  74308. private _scaledGravity;
  74309. private _currentRenderId;
  74310. private _alive;
  74311. private _useInstancing;
  74312. private _started;
  74313. private _stopped;
  74314. private _actualFrame;
  74315. private _scaledUpdateSpeed;
  74316. private _vertexBufferSize;
  74317. /** @hidden */
  74318. _currentEmitRateGradient: Nullable<FactorGradient>;
  74319. /** @hidden */
  74320. _currentEmitRate1: number;
  74321. /** @hidden */
  74322. _currentEmitRate2: number;
  74323. /** @hidden */
  74324. _currentStartSizeGradient: Nullable<FactorGradient>;
  74325. /** @hidden */
  74326. _currentStartSize1: number;
  74327. /** @hidden */
  74328. _currentStartSize2: number;
  74329. private readonly _rawTextureWidth;
  74330. private _rampGradientsTexture;
  74331. private _useRampGradients;
  74332. /** Gets or sets a boolean indicating that ramp gradients must be used
  74333. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  74334. */
  74335. useRampGradients: boolean;
  74336. /**
  74337. * 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.
  74338. * 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: [])
  74339. */
  74340. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  74341. private _subEmitters;
  74342. /**
  74343. * @hidden
  74344. * If the particle systems emitter should be disposed when the particle system is disposed
  74345. */
  74346. _disposeEmitterOnDispose: boolean;
  74347. /**
  74348. * The current active Sub-systems, this property is used by the root particle system only.
  74349. */
  74350. activeSubSystems: Array<ParticleSystem>;
  74351. private _rootParticleSystem;
  74352. /**
  74353. * Gets the current list of active particles
  74354. */
  74355. readonly particles: Particle[];
  74356. /**
  74357. * Returns the string "ParticleSystem"
  74358. * @returns a string containing the class name
  74359. */
  74360. getClassName(): string;
  74361. /**
  74362. * Instantiates a particle system.
  74363. * 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.
  74364. * @param name The name of the particle system
  74365. * @param capacity The max number of particles alive at the same time
  74366. * @param scene The scene the particle system belongs to
  74367. * @param customEffect a custom effect used to change the way particles are rendered by default
  74368. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  74369. * @param epsilon Offset used to render the particles
  74370. */
  74371. constructor(name: string, capacity: number, scene: Scene, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  74372. private _addFactorGradient;
  74373. private _removeFactorGradient;
  74374. /**
  74375. * Adds a new life time gradient
  74376. * @param gradient defines the gradient to use (between 0 and 1)
  74377. * @param factor defines the life time factor to affect to the specified gradient
  74378. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74379. * @returns the current particle system
  74380. */
  74381. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74382. /**
  74383. * Remove a specific life time gradient
  74384. * @param gradient defines the gradient to remove
  74385. * @returns the current particle system
  74386. */
  74387. removeLifeTimeGradient(gradient: number): IParticleSystem;
  74388. /**
  74389. * Adds a new size gradient
  74390. * @param gradient defines the gradient to use (between 0 and 1)
  74391. * @param factor defines the size factor to affect to the specified gradient
  74392. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74393. * @returns the current particle system
  74394. */
  74395. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74396. /**
  74397. * Remove a specific size gradient
  74398. * @param gradient defines the gradient to remove
  74399. * @returns the current particle system
  74400. */
  74401. removeSizeGradient(gradient: number): IParticleSystem;
  74402. /**
  74403. * Adds a new color remap gradient
  74404. * @param gradient defines the gradient to use (between 0 and 1)
  74405. * @param min defines the color remap minimal range
  74406. * @param max defines the color remap maximal range
  74407. * @returns the current particle system
  74408. */
  74409. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74410. /**
  74411. * Remove a specific color remap gradient
  74412. * @param gradient defines the gradient to remove
  74413. * @returns the current particle system
  74414. */
  74415. removeColorRemapGradient(gradient: number): IParticleSystem;
  74416. /**
  74417. * Adds a new alpha remap gradient
  74418. * @param gradient defines the gradient to use (between 0 and 1)
  74419. * @param min defines the alpha remap minimal range
  74420. * @param max defines the alpha remap maximal range
  74421. * @returns the current particle system
  74422. */
  74423. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  74424. /**
  74425. * Remove a specific alpha remap gradient
  74426. * @param gradient defines the gradient to remove
  74427. * @returns the current particle system
  74428. */
  74429. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  74430. /**
  74431. * Adds a new angular speed gradient
  74432. * @param gradient defines the gradient to use (between 0 and 1)
  74433. * @param factor defines the angular speed to affect to the specified gradient
  74434. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74435. * @returns the current particle system
  74436. */
  74437. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74438. /**
  74439. * Remove a specific angular speed gradient
  74440. * @param gradient defines the gradient to remove
  74441. * @returns the current particle system
  74442. */
  74443. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  74444. /**
  74445. * Adds a new velocity gradient
  74446. * @param gradient defines the gradient to use (between 0 and 1)
  74447. * @param factor defines the velocity to affect to the specified gradient
  74448. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74449. * @returns the current particle system
  74450. */
  74451. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74452. /**
  74453. * Remove a specific velocity gradient
  74454. * @param gradient defines the gradient to remove
  74455. * @returns the current particle system
  74456. */
  74457. removeVelocityGradient(gradient: number): IParticleSystem;
  74458. /**
  74459. * Adds a new limit velocity gradient
  74460. * @param gradient defines the gradient to use (between 0 and 1)
  74461. * @param factor defines the limit velocity value to affect to the specified gradient
  74462. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74463. * @returns the current particle system
  74464. */
  74465. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74466. /**
  74467. * Remove a specific limit velocity gradient
  74468. * @param gradient defines the gradient to remove
  74469. * @returns the current particle system
  74470. */
  74471. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  74472. /**
  74473. * Adds a new drag gradient
  74474. * @param gradient defines the gradient to use (between 0 and 1)
  74475. * @param factor defines the drag value to affect to the specified gradient
  74476. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74477. * @returns the current particle system
  74478. */
  74479. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74480. /**
  74481. * Remove a specific drag gradient
  74482. * @param gradient defines the gradient to remove
  74483. * @returns the current particle system
  74484. */
  74485. removeDragGradient(gradient: number): IParticleSystem;
  74486. /**
  74487. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  74488. * @param gradient defines the gradient to use (between 0 and 1)
  74489. * @param factor defines the emit rate value to affect to the specified gradient
  74490. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74491. * @returns the current particle system
  74492. */
  74493. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74494. /**
  74495. * Remove a specific emit rate gradient
  74496. * @param gradient defines the gradient to remove
  74497. * @returns the current particle system
  74498. */
  74499. removeEmitRateGradient(gradient: number): IParticleSystem;
  74500. /**
  74501. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  74502. * @param gradient defines the gradient to use (between 0 and 1)
  74503. * @param factor defines the start size value to affect to the specified gradient
  74504. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  74505. * @returns the current particle system
  74506. */
  74507. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  74508. /**
  74509. * Remove a specific start size gradient
  74510. * @param gradient defines the gradient to remove
  74511. * @returns the current particle system
  74512. */
  74513. removeStartSizeGradient(gradient: number): IParticleSystem;
  74514. private _createRampGradientTexture;
  74515. /**
  74516. * Gets the current list of ramp gradients.
  74517. * You must use addRampGradient and removeRampGradient to udpate this list
  74518. * @returns the list of ramp gradients
  74519. */
  74520. getRampGradients(): Nullable<Array<Color3Gradient>>;
  74521. /**
  74522. * Adds a new ramp gradient used to remap particle colors
  74523. * @param gradient defines the gradient to use (between 0 and 1)
  74524. * @param color defines the color to affect to the specified gradient
  74525. * @returns the current particle system
  74526. */
  74527. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  74528. /**
  74529. * Remove a specific ramp gradient
  74530. * @param gradient defines the gradient to remove
  74531. * @returns the current particle system
  74532. */
  74533. removeRampGradient(gradient: number): ParticleSystem;
  74534. /**
  74535. * Adds a new color gradient
  74536. * @param gradient defines the gradient to use (between 0 and 1)
  74537. * @param color1 defines the color to affect to the specified gradient
  74538. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  74539. * @returns this particle system
  74540. */
  74541. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  74542. /**
  74543. * Remove a specific color gradient
  74544. * @param gradient defines the gradient to remove
  74545. * @returns this particle system
  74546. */
  74547. removeColorGradient(gradient: number): IParticleSystem;
  74548. private _fetchR;
  74549. protected _reset(): void;
  74550. private _resetEffect;
  74551. private _createVertexBuffers;
  74552. private _createIndexBuffer;
  74553. /**
  74554. * Gets the maximum number of particles active at the same time.
  74555. * @returns The max number of active particles.
  74556. */
  74557. getCapacity(): number;
  74558. /**
  74559. * Gets whether there are still active particles in the system.
  74560. * @returns True if it is alive, otherwise false.
  74561. */
  74562. isAlive(): boolean;
  74563. /**
  74564. * Gets if the system has been started. (Note: this will still be true after stop is called)
  74565. * @returns True if it has been started, otherwise false.
  74566. */
  74567. isStarted(): boolean;
  74568. private _prepareSubEmitterInternalArray;
  74569. /**
  74570. * Starts the particle system and begins to emit
  74571. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  74572. */
  74573. start(delay?: number): void;
  74574. /**
  74575. * Stops the particle system.
  74576. * @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.
  74577. */
  74578. stop(stopSubEmitters?: boolean): void;
  74579. /**
  74580. * Remove all active particles
  74581. */
  74582. reset(): void;
  74583. /**
  74584. * @hidden (for internal use only)
  74585. */
  74586. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  74587. /**
  74588. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  74589. * Its lifetime will start back at 0.
  74590. */
  74591. recycleParticle: (particle: Particle) => void;
  74592. private _stopSubEmitters;
  74593. private _createParticle;
  74594. private _removeFromRoot;
  74595. private _emitFromParticle;
  74596. private _update;
  74597. /** @hidden */
  74598. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  74599. /** @hidden */
  74600. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  74601. /** @hidden */
  74602. private _getEffect;
  74603. /**
  74604. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  74605. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  74606. */
  74607. animate(preWarmOnly?: boolean): void;
  74608. private _appendParticleVertices;
  74609. /**
  74610. * Rebuilds the particle system.
  74611. */
  74612. rebuild(): void;
  74613. /**
  74614. * Is this system ready to be used/rendered
  74615. * @return true if the system is ready
  74616. */
  74617. isReady(): boolean;
  74618. private _render;
  74619. /**
  74620. * Renders the particle system in its current state.
  74621. * @returns the current number of particles
  74622. */
  74623. render(): number;
  74624. /**
  74625. * Disposes the particle system and free the associated resources
  74626. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  74627. */
  74628. dispose(disposeTexture?: boolean): void;
  74629. /**
  74630. * Clones the particle system.
  74631. * @param name The name of the cloned object
  74632. * @param newEmitter The new emitter to use
  74633. * @returns the cloned particle system
  74634. */
  74635. clone(name: string, newEmitter: any): ParticleSystem;
  74636. /**
  74637. * Serializes the particle system to a JSON object.
  74638. * @returns the JSON object
  74639. */
  74640. serialize(): any;
  74641. /** @hidden */
  74642. static _Serialize(serializationObject: any, particleSystem: IParticleSystem): void;
  74643. /** @hidden */
  74644. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, scene: Scene, rootUrl: string): void;
  74645. /**
  74646. * Parses a JSON object to create a particle system.
  74647. * @param parsedParticleSystem The JSON object to parse
  74648. * @param scene The scene to create the particle system in
  74649. * @param rootUrl The root url to use to load external dependencies like texture
  74650. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  74651. * @returns the Parsed particle system
  74652. */
  74653. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  74654. }
  74655. }
  74656. declare module BABYLON {
  74657. /**
  74658. * A particle represents one of the element emitted by a particle system.
  74659. * This is mainly define by its coordinates, direction, velocity and age.
  74660. */
  74661. export class Particle {
  74662. /**
  74663. * The particle system the particle belongs to.
  74664. */
  74665. particleSystem: ParticleSystem;
  74666. private static _Count;
  74667. /**
  74668. * Unique ID of the particle
  74669. */
  74670. id: number;
  74671. /**
  74672. * The world position of the particle in the scene.
  74673. */
  74674. position: Vector3;
  74675. /**
  74676. * The world direction of the particle in the scene.
  74677. */
  74678. direction: Vector3;
  74679. /**
  74680. * The color of the particle.
  74681. */
  74682. color: Color4;
  74683. /**
  74684. * The color change of the particle per step.
  74685. */
  74686. colorStep: Color4;
  74687. /**
  74688. * Defines how long will the life of the particle be.
  74689. */
  74690. lifeTime: number;
  74691. /**
  74692. * The current age of the particle.
  74693. */
  74694. age: number;
  74695. /**
  74696. * The current size of the particle.
  74697. */
  74698. size: number;
  74699. /**
  74700. * The current scale of the particle.
  74701. */
  74702. scale: Vector2;
  74703. /**
  74704. * The current angle of the particle.
  74705. */
  74706. angle: number;
  74707. /**
  74708. * Defines how fast is the angle changing.
  74709. */
  74710. angularSpeed: number;
  74711. /**
  74712. * Defines the cell index used by the particle to be rendered from a sprite.
  74713. */
  74714. cellIndex: number;
  74715. /**
  74716. * The information required to support color remapping
  74717. */
  74718. remapData: Vector4;
  74719. /** @hidden */
  74720. _randomCellOffset?: number;
  74721. /** @hidden */
  74722. _initialDirection: Nullable<Vector3>;
  74723. /** @hidden */
  74724. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  74725. /** @hidden */
  74726. _initialStartSpriteCellID: number;
  74727. /** @hidden */
  74728. _initialEndSpriteCellID: number;
  74729. /** @hidden */
  74730. _currentColorGradient: Nullable<ColorGradient>;
  74731. /** @hidden */
  74732. _currentColor1: Color4;
  74733. /** @hidden */
  74734. _currentColor2: Color4;
  74735. /** @hidden */
  74736. _currentSizeGradient: Nullable<FactorGradient>;
  74737. /** @hidden */
  74738. _currentSize1: number;
  74739. /** @hidden */
  74740. _currentSize2: number;
  74741. /** @hidden */
  74742. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  74743. /** @hidden */
  74744. _currentAngularSpeed1: number;
  74745. /** @hidden */
  74746. _currentAngularSpeed2: number;
  74747. /** @hidden */
  74748. _currentVelocityGradient: Nullable<FactorGradient>;
  74749. /** @hidden */
  74750. _currentVelocity1: number;
  74751. /** @hidden */
  74752. _currentVelocity2: number;
  74753. /** @hidden */
  74754. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  74755. /** @hidden */
  74756. _currentLimitVelocity1: number;
  74757. /** @hidden */
  74758. _currentLimitVelocity2: number;
  74759. /** @hidden */
  74760. _currentDragGradient: Nullable<FactorGradient>;
  74761. /** @hidden */
  74762. _currentDrag1: number;
  74763. /** @hidden */
  74764. _currentDrag2: number;
  74765. /** @hidden */
  74766. _randomNoiseCoordinates1: Vector3;
  74767. /** @hidden */
  74768. _randomNoiseCoordinates2: Vector3;
  74769. /**
  74770. * Creates a new instance Particle
  74771. * @param particleSystem the particle system the particle belongs to
  74772. */
  74773. constructor(
  74774. /**
  74775. * The particle system the particle belongs to.
  74776. */
  74777. particleSystem: ParticleSystem);
  74778. private updateCellInfoFromSystem;
  74779. /**
  74780. * Defines how the sprite cell index is updated for the particle
  74781. */
  74782. updateCellIndex(): void;
  74783. /** @hidden */
  74784. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  74785. /** @hidden */
  74786. _inheritParticleInfoToSubEmitters(): void;
  74787. /** @hidden */
  74788. _reset(): void;
  74789. /**
  74790. * Copy the properties of particle to another one.
  74791. * @param other the particle to copy the information to.
  74792. */
  74793. copyTo(other: Particle): void;
  74794. }
  74795. }
  74796. declare module BABYLON {
  74797. /**
  74798. * Particle emitter represents a volume emitting particles.
  74799. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  74800. */
  74801. export interface IParticleEmitterType {
  74802. /**
  74803. * Called by the particle System when the direction is computed for the created particle.
  74804. * @param worldMatrix is the world matrix of the particle system
  74805. * @param directionToUpdate is the direction vector to update with the result
  74806. * @param particle is the particle we are computed the direction for
  74807. */
  74808. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74809. /**
  74810. * Called by the particle System when the position is computed for the created particle.
  74811. * @param worldMatrix is the world matrix of the particle system
  74812. * @param positionToUpdate is the position vector to update with the result
  74813. * @param particle is the particle we are computed the position for
  74814. */
  74815. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74816. /**
  74817. * Clones the current emitter and returns a copy of it
  74818. * @returns the new emitter
  74819. */
  74820. clone(): IParticleEmitterType;
  74821. /**
  74822. * Called by the GPUParticleSystem to setup the update shader
  74823. * @param effect defines the update shader
  74824. */
  74825. applyToShader(effect: Effect): void;
  74826. /**
  74827. * Returns a string to use to update the GPU particles update shader
  74828. * @returns the effect defines string
  74829. */
  74830. getEffectDefines(): string;
  74831. /**
  74832. * Returns a string representing the class name
  74833. * @returns a string containing the class name
  74834. */
  74835. getClassName(): string;
  74836. /**
  74837. * Serializes the particle system to a JSON object.
  74838. * @returns the JSON object
  74839. */
  74840. serialize(): any;
  74841. /**
  74842. * Parse properties from a JSON object
  74843. * @param serializationObject defines the JSON object
  74844. */
  74845. parse(serializationObject: any): void;
  74846. }
  74847. }
  74848. declare module BABYLON {
  74849. /**
  74850. * Particle emitter emitting particles from the inside of a box.
  74851. * It emits the particles randomly between 2 given directions.
  74852. */
  74853. export class BoxParticleEmitter implements IParticleEmitterType {
  74854. /**
  74855. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74856. */
  74857. direction1: Vector3;
  74858. /**
  74859. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  74860. */
  74861. direction2: Vector3;
  74862. /**
  74863. * 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.
  74864. */
  74865. minEmitBox: Vector3;
  74866. /**
  74867. * 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.
  74868. */
  74869. maxEmitBox: Vector3;
  74870. /**
  74871. * Creates a new instance BoxParticleEmitter
  74872. */
  74873. constructor();
  74874. /**
  74875. * Called by the particle System when the direction is computed for the created particle.
  74876. * @param worldMatrix is the world matrix of the particle system
  74877. * @param directionToUpdate is the direction vector to update with the result
  74878. * @param particle is the particle we are computed the direction for
  74879. */
  74880. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74881. /**
  74882. * Called by the particle System when the position is computed for the created particle.
  74883. * @param worldMatrix is the world matrix of the particle system
  74884. * @param positionToUpdate is the position vector to update with the result
  74885. * @param particle is the particle we are computed the position for
  74886. */
  74887. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74888. /**
  74889. * Clones the current emitter and returns a copy of it
  74890. * @returns the new emitter
  74891. */
  74892. clone(): BoxParticleEmitter;
  74893. /**
  74894. * Called by the GPUParticleSystem to setup the update shader
  74895. * @param effect defines the update shader
  74896. */
  74897. applyToShader(effect: Effect): void;
  74898. /**
  74899. * Returns a string to use to update the GPU particles update shader
  74900. * @returns a string containng the defines string
  74901. */
  74902. getEffectDefines(): string;
  74903. /**
  74904. * Returns the string "BoxParticleEmitter"
  74905. * @returns a string containing the class name
  74906. */
  74907. getClassName(): string;
  74908. /**
  74909. * Serializes the particle system to a JSON object.
  74910. * @returns the JSON object
  74911. */
  74912. serialize(): any;
  74913. /**
  74914. * Parse properties from a JSON object
  74915. * @param serializationObject defines the JSON object
  74916. */
  74917. parse(serializationObject: any): void;
  74918. }
  74919. }
  74920. declare module BABYLON {
  74921. /**
  74922. * Particle emitter emitting particles from the inside of a cone.
  74923. * It emits the particles alongside the cone volume from the base to the particle.
  74924. * The emission direction might be randomized.
  74925. */
  74926. export class ConeParticleEmitter implements IParticleEmitterType {
  74927. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74928. directionRandomizer: number;
  74929. private _radius;
  74930. private _angle;
  74931. private _height;
  74932. /**
  74933. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  74934. */
  74935. radiusRange: number;
  74936. /**
  74937. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  74938. */
  74939. heightRange: number;
  74940. /**
  74941. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  74942. */
  74943. emitFromSpawnPointOnly: boolean;
  74944. /**
  74945. * Gets or sets the radius of the emission cone
  74946. */
  74947. radius: number;
  74948. /**
  74949. * Gets or sets the angle of the emission cone
  74950. */
  74951. angle: number;
  74952. private _buildHeight;
  74953. /**
  74954. * Creates a new instance ConeParticleEmitter
  74955. * @param radius the radius of the emission cone (1 by default)
  74956. * @param angle the cone base angle (PI by default)
  74957. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  74958. */
  74959. constructor(radius?: number, angle?: number,
  74960. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  74961. directionRandomizer?: number);
  74962. /**
  74963. * Called by the particle System when the direction is computed for the created particle.
  74964. * @param worldMatrix is the world matrix of the particle system
  74965. * @param directionToUpdate is the direction vector to update with the result
  74966. * @param particle is the particle we are computed the direction for
  74967. */
  74968. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  74969. /**
  74970. * Called by the particle System when the position is computed for the created particle.
  74971. * @param worldMatrix is the world matrix of the particle system
  74972. * @param positionToUpdate is the position vector to update with the result
  74973. * @param particle is the particle we are computed the position for
  74974. */
  74975. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  74976. /**
  74977. * Clones the current emitter and returns a copy of it
  74978. * @returns the new emitter
  74979. */
  74980. clone(): ConeParticleEmitter;
  74981. /**
  74982. * Called by the GPUParticleSystem to setup the update shader
  74983. * @param effect defines the update shader
  74984. */
  74985. applyToShader(effect: Effect): void;
  74986. /**
  74987. * Returns a string to use to update the GPU particles update shader
  74988. * @returns a string containng the defines string
  74989. */
  74990. getEffectDefines(): string;
  74991. /**
  74992. * Returns the string "ConeParticleEmitter"
  74993. * @returns a string containing the class name
  74994. */
  74995. getClassName(): string;
  74996. /**
  74997. * Serializes the particle system to a JSON object.
  74998. * @returns the JSON object
  74999. */
  75000. serialize(): any;
  75001. /**
  75002. * Parse properties from a JSON object
  75003. * @param serializationObject defines the JSON object
  75004. */
  75005. parse(serializationObject: any): void;
  75006. }
  75007. }
  75008. declare module BABYLON {
  75009. /**
  75010. * Particle emitter emitting particles from the inside of a cylinder.
  75011. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  75012. */
  75013. export class CylinderParticleEmitter implements IParticleEmitterType {
  75014. /**
  75015. * The radius of the emission cylinder.
  75016. */
  75017. radius: number;
  75018. /**
  75019. * The height of the emission cylinder.
  75020. */
  75021. height: number;
  75022. /**
  75023. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75024. */
  75025. radiusRange: number;
  75026. /**
  75027. * How much to randomize the particle direction [0-1].
  75028. */
  75029. directionRandomizer: number;
  75030. /**
  75031. * Creates a new instance CylinderParticleEmitter
  75032. * @param radius the radius of the emission cylinder (1 by default)
  75033. * @param height the height of the emission cylinder (1 by default)
  75034. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75035. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75036. */
  75037. constructor(
  75038. /**
  75039. * The radius of the emission cylinder.
  75040. */
  75041. radius?: number,
  75042. /**
  75043. * The height of the emission cylinder.
  75044. */
  75045. height?: number,
  75046. /**
  75047. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75048. */
  75049. radiusRange?: number,
  75050. /**
  75051. * How much to randomize the particle direction [0-1].
  75052. */
  75053. directionRandomizer?: number);
  75054. /**
  75055. * Called by the particle System when the direction is computed for the created particle.
  75056. * @param worldMatrix is the world matrix of the particle system
  75057. * @param directionToUpdate is the direction vector to update with the result
  75058. * @param particle is the particle we are computed the direction for
  75059. */
  75060. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75061. /**
  75062. * Called by the particle System when the position is computed for the created particle.
  75063. * @param worldMatrix is the world matrix of the particle system
  75064. * @param positionToUpdate is the position vector to update with the result
  75065. * @param particle is the particle we are computed the position for
  75066. */
  75067. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75068. /**
  75069. * Clones the current emitter and returns a copy of it
  75070. * @returns the new emitter
  75071. */
  75072. clone(): CylinderParticleEmitter;
  75073. /**
  75074. * Called by the GPUParticleSystem to setup the update shader
  75075. * @param effect defines the update shader
  75076. */
  75077. applyToShader(effect: Effect): void;
  75078. /**
  75079. * Returns a string to use to update the GPU particles update shader
  75080. * @returns a string containng the defines string
  75081. */
  75082. getEffectDefines(): string;
  75083. /**
  75084. * Returns the string "CylinderParticleEmitter"
  75085. * @returns a string containing the class name
  75086. */
  75087. getClassName(): string;
  75088. /**
  75089. * Serializes the particle system to a JSON object.
  75090. * @returns the JSON object
  75091. */
  75092. serialize(): any;
  75093. /**
  75094. * Parse properties from a JSON object
  75095. * @param serializationObject defines the JSON object
  75096. */
  75097. parse(serializationObject: any): void;
  75098. }
  75099. /**
  75100. * Particle emitter emitting particles from the inside of a cylinder.
  75101. * It emits the particles randomly between two vectors.
  75102. */
  75103. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  75104. /**
  75105. * The min limit of the emission direction.
  75106. */
  75107. direction1: Vector3;
  75108. /**
  75109. * The max limit of the emission direction.
  75110. */
  75111. direction2: Vector3;
  75112. /**
  75113. * Creates a new instance CylinderDirectedParticleEmitter
  75114. * @param radius the radius of the emission cylinder (1 by default)
  75115. * @param height the height of the emission cylinder (1 by default)
  75116. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75117. * @param direction1 the min limit of the emission direction (up vector by default)
  75118. * @param direction2 the max limit of the emission direction (up vector by default)
  75119. */
  75120. constructor(radius?: number, height?: number, radiusRange?: number,
  75121. /**
  75122. * The min limit of the emission direction.
  75123. */
  75124. direction1?: Vector3,
  75125. /**
  75126. * The max limit of the emission direction.
  75127. */
  75128. direction2?: Vector3);
  75129. /**
  75130. * Called by the particle System when the direction is computed for the created particle.
  75131. * @param worldMatrix is the world matrix of the particle system
  75132. * @param directionToUpdate is the direction vector to update with the result
  75133. * @param particle is the particle we are computed the direction for
  75134. */
  75135. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75136. /**
  75137. * Clones the current emitter and returns a copy of it
  75138. * @returns the new emitter
  75139. */
  75140. clone(): CylinderDirectedParticleEmitter;
  75141. /**
  75142. * Called by the GPUParticleSystem to setup the update shader
  75143. * @param effect defines the update shader
  75144. */
  75145. applyToShader(effect: Effect): void;
  75146. /**
  75147. * Returns a string to use to update the GPU particles update shader
  75148. * @returns a string containng the defines string
  75149. */
  75150. getEffectDefines(): string;
  75151. /**
  75152. * Returns the string "CylinderDirectedParticleEmitter"
  75153. * @returns a string containing the class name
  75154. */
  75155. getClassName(): string;
  75156. /**
  75157. * Serializes the particle system to a JSON object.
  75158. * @returns the JSON object
  75159. */
  75160. serialize(): any;
  75161. /**
  75162. * Parse properties from a JSON object
  75163. * @param serializationObject defines the JSON object
  75164. */
  75165. parse(serializationObject: any): void;
  75166. }
  75167. }
  75168. declare module BABYLON {
  75169. /**
  75170. * Particle emitter emitting particles from the inside of a hemisphere.
  75171. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  75172. */
  75173. export class HemisphericParticleEmitter implements IParticleEmitterType {
  75174. /**
  75175. * The radius of the emission hemisphere.
  75176. */
  75177. radius: number;
  75178. /**
  75179. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75180. */
  75181. radiusRange: number;
  75182. /**
  75183. * How much to randomize the particle direction [0-1].
  75184. */
  75185. directionRandomizer: number;
  75186. /**
  75187. * Creates a new instance HemisphericParticleEmitter
  75188. * @param radius the radius of the emission hemisphere (1 by default)
  75189. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75190. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75191. */
  75192. constructor(
  75193. /**
  75194. * The radius of the emission hemisphere.
  75195. */
  75196. radius?: number,
  75197. /**
  75198. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75199. */
  75200. radiusRange?: number,
  75201. /**
  75202. * How much to randomize the particle direction [0-1].
  75203. */
  75204. directionRandomizer?: number);
  75205. /**
  75206. * Called by the particle System when the direction is computed for the created particle.
  75207. * @param worldMatrix is the world matrix of the particle system
  75208. * @param directionToUpdate is the direction vector to update with the result
  75209. * @param particle is the particle we are computed the direction for
  75210. */
  75211. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75212. /**
  75213. * Called by the particle System when the position is computed for the created particle.
  75214. * @param worldMatrix is the world matrix of the particle system
  75215. * @param positionToUpdate is the position vector to update with the result
  75216. * @param particle is the particle we are computed the position for
  75217. */
  75218. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75219. /**
  75220. * Clones the current emitter and returns a copy of it
  75221. * @returns the new emitter
  75222. */
  75223. clone(): HemisphericParticleEmitter;
  75224. /**
  75225. * Called by the GPUParticleSystem to setup the update shader
  75226. * @param effect defines the update shader
  75227. */
  75228. applyToShader(effect: Effect): void;
  75229. /**
  75230. * Returns a string to use to update the GPU particles update shader
  75231. * @returns a string containng the defines string
  75232. */
  75233. getEffectDefines(): string;
  75234. /**
  75235. * Returns the string "HemisphericParticleEmitter"
  75236. * @returns a string containing the class name
  75237. */
  75238. getClassName(): string;
  75239. /**
  75240. * Serializes the particle system to a JSON object.
  75241. * @returns the JSON object
  75242. */
  75243. serialize(): any;
  75244. /**
  75245. * Parse properties from a JSON object
  75246. * @param serializationObject defines the JSON object
  75247. */
  75248. parse(serializationObject: any): void;
  75249. }
  75250. }
  75251. declare module BABYLON {
  75252. /**
  75253. * Particle emitter emitting particles from a point.
  75254. * It emits the particles randomly between 2 given directions.
  75255. */
  75256. export class PointParticleEmitter implements IParticleEmitterType {
  75257. /**
  75258. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75259. */
  75260. direction1: Vector3;
  75261. /**
  75262. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  75263. */
  75264. direction2: Vector3;
  75265. /**
  75266. * Creates a new instance PointParticleEmitter
  75267. */
  75268. constructor();
  75269. /**
  75270. * Called by the particle System when the direction is computed for the created particle.
  75271. * @param worldMatrix is the world matrix of the particle system
  75272. * @param directionToUpdate is the direction vector to update with the result
  75273. * @param particle is the particle we are computed the direction for
  75274. */
  75275. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75276. /**
  75277. * Called by the particle System when the position is computed for the created particle.
  75278. * @param worldMatrix is the world matrix of the particle system
  75279. * @param positionToUpdate is the position vector to update with the result
  75280. * @param particle is the particle we are computed the position for
  75281. */
  75282. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75283. /**
  75284. * Clones the current emitter and returns a copy of it
  75285. * @returns the new emitter
  75286. */
  75287. clone(): PointParticleEmitter;
  75288. /**
  75289. * Called by the GPUParticleSystem to setup the update shader
  75290. * @param effect defines the update shader
  75291. */
  75292. applyToShader(effect: Effect): void;
  75293. /**
  75294. * Returns a string to use to update the GPU particles update shader
  75295. * @returns a string containng the defines string
  75296. */
  75297. getEffectDefines(): string;
  75298. /**
  75299. * Returns the string "PointParticleEmitter"
  75300. * @returns a string containing the class name
  75301. */
  75302. getClassName(): string;
  75303. /**
  75304. * Serializes the particle system to a JSON object.
  75305. * @returns the JSON object
  75306. */
  75307. serialize(): any;
  75308. /**
  75309. * Parse properties from a JSON object
  75310. * @param serializationObject defines the JSON object
  75311. */
  75312. parse(serializationObject: any): void;
  75313. }
  75314. }
  75315. declare module BABYLON {
  75316. /**
  75317. * Particle emitter emitting particles from the inside of a sphere.
  75318. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  75319. */
  75320. export class SphereParticleEmitter implements IParticleEmitterType {
  75321. /**
  75322. * The radius of the emission sphere.
  75323. */
  75324. radius: number;
  75325. /**
  75326. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75327. */
  75328. radiusRange: number;
  75329. /**
  75330. * How much to randomize the particle direction [0-1].
  75331. */
  75332. directionRandomizer: number;
  75333. /**
  75334. * Creates a new instance SphereParticleEmitter
  75335. * @param radius the radius of the emission sphere (1 by default)
  75336. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  75337. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  75338. */
  75339. constructor(
  75340. /**
  75341. * The radius of the emission sphere.
  75342. */
  75343. radius?: number,
  75344. /**
  75345. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  75346. */
  75347. radiusRange?: number,
  75348. /**
  75349. * How much to randomize the particle direction [0-1].
  75350. */
  75351. directionRandomizer?: number);
  75352. /**
  75353. * Called by the particle System when the direction is computed for the created particle.
  75354. * @param worldMatrix is the world matrix of the particle system
  75355. * @param directionToUpdate is the direction vector to update with the result
  75356. * @param particle is the particle we are computed the direction for
  75357. */
  75358. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75359. /**
  75360. * Called by the particle System when the position is computed for the created particle.
  75361. * @param worldMatrix is the world matrix of the particle system
  75362. * @param positionToUpdate is the position vector to update with the result
  75363. * @param particle is the particle we are computed the position for
  75364. */
  75365. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle): void;
  75366. /**
  75367. * Clones the current emitter and returns a copy of it
  75368. * @returns the new emitter
  75369. */
  75370. clone(): SphereParticleEmitter;
  75371. /**
  75372. * Called by the GPUParticleSystem to setup the update shader
  75373. * @param effect defines the update shader
  75374. */
  75375. applyToShader(effect: Effect): void;
  75376. /**
  75377. * Returns a string to use to update the GPU particles update shader
  75378. * @returns a string containng the defines string
  75379. */
  75380. getEffectDefines(): string;
  75381. /**
  75382. * Returns the string "SphereParticleEmitter"
  75383. * @returns a string containing the class name
  75384. */
  75385. getClassName(): string;
  75386. /**
  75387. * Serializes the particle system to a JSON object.
  75388. * @returns the JSON object
  75389. */
  75390. serialize(): any;
  75391. /**
  75392. * Parse properties from a JSON object
  75393. * @param serializationObject defines the JSON object
  75394. */
  75395. parse(serializationObject: any): void;
  75396. }
  75397. /**
  75398. * Particle emitter emitting particles from the inside of a sphere.
  75399. * It emits the particles randomly between two vectors.
  75400. */
  75401. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  75402. /**
  75403. * The min limit of the emission direction.
  75404. */
  75405. direction1: Vector3;
  75406. /**
  75407. * The max limit of the emission direction.
  75408. */
  75409. direction2: Vector3;
  75410. /**
  75411. * Creates a new instance SphereDirectedParticleEmitter
  75412. * @param radius the radius of the emission sphere (1 by default)
  75413. * @param direction1 the min limit of the emission direction (up vector by default)
  75414. * @param direction2 the max limit of the emission direction (up vector by default)
  75415. */
  75416. constructor(radius?: number,
  75417. /**
  75418. * The min limit of the emission direction.
  75419. */
  75420. direction1?: Vector3,
  75421. /**
  75422. * The max limit of the emission direction.
  75423. */
  75424. direction2?: Vector3);
  75425. /**
  75426. * Called by the particle System when the direction is computed for the created particle.
  75427. * @param worldMatrix is the world matrix of the particle system
  75428. * @param directionToUpdate is the direction vector to update with the result
  75429. * @param particle is the particle we are computed the direction for
  75430. */
  75431. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  75432. /**
  75433. * Clones the current emitter and returns a copy of it
  75434. * @returns the new emitter
  75435. */
  75436. clone(): SphereDirectedParticleEmitter;
  75437. /**
  75438. * Called by the GPUParticleSystem to setup the update shader
  75439. * @param effect defines the update shader
  75440. */
  75441. applyToShader(effect: Effect): void;
  75442. /**
  75443. * Returns a string to use to update the GPU particles update shader
  75444. * @returns a string containng the defines string
  75445. */
  75446. getEffectDefines(): string;
  75447. /**
  75448. * Returns the string "SphereDirectedParticleEmitter"
  75449. * @returns a string containing the class name
  75450. */
  75451. getClassName(): string;
  75452. /**
  75453. * Serializes the particle system to a JSON object.
  75454. * @returns the JSON object
  75455. */
  75456. serialize(): any;
  75457. /**
  75458. * Parse properties from a JSON object
  75459. * @param serializationObject defines the JSON object
  75460. */
  75461. parse(serializationObject: any): void;
  75462. }
  75463. }
  75464. declare module BABYLON {
  75465. /**
  75466. * Interface representing a particle system in Babylon.js.
  75467. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  75468. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  75469. */
  75470. export interface IParticleSystem {
  75471. /**
  75472. * List of animations used by the particle system.
  75473. */
  75474. animations: Animation[];
  75475. /**
  75476. * The id of the Particle system.
  75477. */
  75478. id: string;
  75479. /**
  75480. * The name of the Particle system.
  75481. */
  75482. name: string;
  75483. /**
  75484. * The emitter represents the Mesh or position we are attaching the particle system to.
  75485. */
  75486. emitter: Nullable<AbstractMesh | Vector3>;
  75487. /**
  75488. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  75489. */
  75490. isBillboardBased: boolean;
  75491. /**
  75492. * The rendering group used by the Particle system to chose when to render.
  75493. */
  75494. renderingGroupId: number;
  75495. /**
  75496. * The layer mask we are rendering the particles through.
  75497. */
  75498. layerMask: number;
  75499. /**
  75500. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  75501. */
  75502. updateSpeed: number;
  75503. /**
  75504. * The amount of time the particle system is running (depends of the overall update speed).
  75505. */
  75506. targetStopDuration: number;
  75507. /**
  75508. * The texture used to render each particle. (this can be a spritesheet)
  75509. */
  75510. particleTexture: Nullable<Texture>;
  75511. /**
  75512. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  75513. */
  75514. blendMode: number;
  75515. /**
  75516. * Minimum life time of emitting particles.
  75517. */
  75518. minLifeTime: number;
  75519. /**
  75520. * Maximum life time of emitting particles.
  75521. */
  75522. maxLifeTime: number;
  75523. /**
  75524. * Minimum Size of emitting particles.
  75525. */
  75526. minSize: number;
  75527. /**
  75528. * Maximum Size of emitting particles.
  75529. */
  75530. maxSize: number;
  75531. /**
  75532. * Minimum scale of emitting particles on X axis.
  75533. */
  75534. minScaleX: number;
  75535. /**
  75536. * Maximum scale of emitting particles on X axis.
  75537. */
  75538. maxScaleX: number;
  75539. /**
  75540. * Minimum scale of emitting particles on Y axis.
  75541. */
  75542. minScaleY: number;
  75543. /**
  75544. * Maximum scale of emitting particles on Y axis.
  75545. */
  75546. maxScaleY: number;
  75547. /**
  75548. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75549. */
  75550. color1: Color4;
  75551. /**
  75552. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  75553. */
  75554. color2: Color4;
  75555. /**
  75556. * Color the particle will have at the end of its lifetime.
  75557. */
  75558. colorDead: Color4;
  75559. /**
  75560. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  75561. */
  75562. emitRate: number;
  75563. /**
  75564. * You can use gravity if you want to give an orientation to your particles.
  75565. */
  75566. gravity: Vector3;
  75567. /**
  75568. * Minimum power of emitting particles.
  75569. */
  75570. minEmitPower: number;
  75571. /**
  75572. * Maximum power of emitting particles.
  75573. */
  75574. maxEmitPower: number;
  75575. /**
  75576. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  75577. */
  75578. minAngularSpeed: number;
  75579. /**
  75580. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  75581. */
  75582. maxAngularSpeed: number;
  75583. /**
  75584. * Gets or sets the minimal initial rotation in radians.
  75585. */
  75586. minInitialRotation: number;
  75587. /**
  75588. * Gets or sets the maximal initial rotation in radians.
  75589. */
  75590. maxInitialRotation: number;
  75591. /**
  75592. * The particle emitter type defines the emitter used by the particle system.
  75593. * It can be for example box, sphere, or cone...
  75594. */
  75595. particleEmitterType: Nullable<IParticleEmitterType>;
  75596. /**
  75597. * Defines the delay in milliseconds before starting the system (0 by default)
  75598. */
  75599. startDelay: number;
  75600. /**
  75601. * 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
  75602. */
  75603. preWarmCycles: number;
  75604. /**
  75605. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  75606. */
  75607. preWarmStepOffset: number;
  75608. /**
  75609. * 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)
  75610. */
  75611. spriteCellChangeSpeed: number;
  75612. /**
  75613. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  75614. */
  75615. startSpriteCellID: number;
  75616. /**
  75617. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  75618. */
  75619. endSpriteCellID: number;
  75620. /**
  75621. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  75622. */
  75623. spriteCellWidth: number;
  75624. /**
  75625. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  75626. */
  75627. spriteCellHeight: number;
  75628. /**
  75629. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  75630. */
  75631. spriteRandomStartCell: boolean;
  75632. /**
  75633. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  75634. */
  75635. isAnimationSheetEnabled: boolean;
  75636. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  75637. translationPivot: Vector2;
  75638. /**
  75639. * Gets or sets a texture used to add random noise to particle positions
  75640. */
  75641. noiseTexture: Nullable<BaseTexture>;
  75642. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  75643. noiseStrength: Vector3;
  75644. /**
  75645. * Gets or sets the billboard mode to use when isBillboardBased = true.
  75646. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  75647. */
  75648. billboardMode: number;
  75649. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  75650. limitVelocityDamping: number;
  75651. /**
  75652. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  75653. */
  75654. beginAnimationOnStart: boolean;
  75655. /**
  75656. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  75657. */
  75658. beginAnimationFrom: number;
  75659. /**
  75660. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  75661. */
  75662. beginAnimationTo: number;
  75663. /**
  75664. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  75665. */
  75666. beginAnimationLoop: boolean;
  75667. /**
  75668. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  75669. */
  75670. disposeOnStop: boolean;
  75671. /**
  75672. * Gets the maximum number of particles active at the same time.
  75673. * @returns The max number of active particles.
  75674. */
  75675. getCapacity(): number;
  75676. /**
  75677. * Gets if the system has been started. (Note: this will still be true after stop is called)
  75678. * @returns True if it has been started, otherwise false.
  75679. */
  75680. isStarted(): boolean;
  75681. /**
  75682. * Animates the particle system for this frame.
  75683. */
  75684. animate(): void;
  75685. /**
  75686. * Renders the particle system in its current state.
  75687. * @returns the current number of particles
  75688. */
  75689. render(): number;
  75690. /**
  75691. * Dispose the particle system and frees its associated resources.
  75692. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  75693. */
  75694. dispose(disposeTexture?: boolean): void;
  75695. /**
  75696. * Clones the particle system.
  75697. * @param name The name of the cloned object
  75698. * @param newEmitter The new emitter to use
  75699. * @returns the cloned particle system
  75700. */
  75701. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  75702. /**
  75703. * Serializes the particle system to a JSON object.
  75704. * @returns the JSON object
  75705. */
  75706. serialize(): any;
  75707. /**
  75708. * Rebuild the particle system
  75709. */
  75710. rebuild(): void;
  75711. /**
  75712. * Starts the particle system and begins to emit
  75713. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  75714. */
  75715. start(delay?: number): void;
  75716. /**
  75717. * Stops the particle system.
  75718. */
  75719. stop(): void;
  75720. /**
  75721. * Remove all active particles
  75722. */
  75723. reset(): void;
  75724. /**
  75725. * Is this system ready to be used/rendered
  75726. * @return true if the system is ready
  75727. */
  75728. isReady(): boolean;
  75729. /**
  75730. * Adds a new color gradient
  75731. * @param gradient defines the gradient to use (between 0 and 1)
  75732. * @param color1 defines the color to affect to the specified gradient
  75733. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  75734. * @returns the current particle system
  75735. */
  75736. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  75737. /**
  75738. * Remove a specific color gradient
  75739. * @param gradient defines the gradient to remove
  75740. * @returns the current particle system
  75741. */
  75742. removeColorGradient(gradient: number): IParticleSystem;
  75743. /**
  75744. * Adds a new size gradient
  75745. * @param gradient defines the gradient to use (between 0 and 1)
  75746. * @param factor defines the size factor to affect to the specified gradient
  75747. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75748. * @returns the current particle system
  75749. */
  75750. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75751. /**
  75752. * Remove a specific size gradient
  75753. * @param gradient defines the gradient to remove
  75754. * @returns the current particle system
  75755. */
  75756. removeSizeGradient(gradient: number): IParticleSystem;
  75757. /**
  75758. * Gets the current list of color gradients.
  75759. * You must use addColorGradient and removeColorGradient to udpate this list
  75760. * @returns the list of color gradients
  75761. */
  75762. getColorGradients(): Nullable<Array<ColorGradient>>;
  75763. /**
  75764. * Gets the current list of size gradients.
  75765. * You must use addSizeGradient and removeSizeGradient to udpate this list
  75766. * @returns the list of size gradients
  75767. */
  75768. getSizeGradients(): Nullable<Array<FactorGradient>>;
  75769. /**
  75770. * Gets the current list of angular speed gradients.
  75771. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  75772. * @returns the list of angular speed gradients
  75773. */
  75774. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  75775. /**
  75776. * Adds a new angular speed gradient
  75777. * @param gradient defines the gradient to use (between 0 and 1)
  75778. * @param factor defines the angular speed to affect to the specified gradient
  75779. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75780. * @returns the current particle system
  75781. */
  75782. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75783. /**
  75784. * Remove a specific angular speed gradient
  75785. * @param gradient defines the gradient to remove
  75786. * @returns the current particle system
  75787. */
  75788. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  75789. /**
  75790. * Gets the current list of velocity gradients.
  75791. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  75792. * @returns the list of velocity gradients
  75793. */
  75794. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  75795. /**
  75796. * Adds a new velocity gradient
  75797. * @param gradient defines the gradient to use (between 0 and 1)
  75798. * @param factor defines the velocity to affect to the specified gradient
  75799. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75800. * @returns the current particle system
  75801. */
  75802. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75803. /**
  75804. * Remove a specific velocity gradient
  75805. * @param gradient defines the gradient to remove
  75806. * @returns the current particle system
  75807. */
  75808. removeVelocityGradient(gradient: number): IParticleSystem;
  75809. /**
  75810. * Gets the current list of limit velocity gradients.
  75811. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  75812. * @returns the list of limit velocity gradients
  75813. */
  75814. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  75815. /**
  75816. * Adds a new limit velocity gradient
  75817. * @param gradient defines the gradient to use (between 0 and 1)
  75818. * @param factor defines the limit velocity to affect to the specified gradient
  75819. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75820. * @returns the current particle system
  75821. */
  75822. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75823. /**
  75824. * Remove a specific limit velocity gradient
  75825. * @param gradient defines the gradient to remove
  75826. * @returns the current particle system
  75827. */
  75828. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  75829. /**
  75830. * Adds a new drag gradient
  75831. * @param gradient defines the gradient to use (between 0 and 1)
  75832. * @param factor defines the drag to affect to the specified gradient
  75833. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75834. * @returns the current particle system
  75835. */
  75836. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75837. /**
  75838. * Remove a specific drag gradient
  75839. * @param gradient defines the gradient to remove
  75840. * @returns the current particle system
  75841. */
  75842. removeDragGradient(gradient: number): IParticleSystem;
  75843. /**
  75844. * Gets the current list of drag gradients.
  75845. * You must use addDragGradient and removeDragGradient to udpate this list
  75846. * @returns the list of drag gradients
  75847. */
  75848. getDragGradients(): Nullable<Array<FactorGradient>>;
  75849. /**
  75850. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  75851. * @param gradient defines the gradient to use (between 0 and 1)
  75852. * @param factor defines the emit rate to affect to the specified gradient
  75853. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75854. * @returns the current particle system
  75855. */
  75856. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75857. /**
  75858. * Remove a specific emit rate gradient
  75859. * @param gradient defines the gradient to remove
  75860. * @returns the current particle system
  75861. */
  75862. removeEmitRateGradient(gradient: number): IParticleSystem;
  75863. /**
  75864. * Gets the current list of emit rate gradients.
  75865. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  75866. * @returns the list of emit rate gradients
  75867. */
  75868. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  75869. /**
  75870. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  75871. * @param gradient defines the gradient to use (between 0 and 1)
  75872. * @param factor defines the start size to affect to the specified gradient
  75873. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75874. * @returns the current particle system
  75875. */
  75876. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75877. /**
  75878. * Remove a specific start size gradient
  75879. * @param gradient defines the gradient to remove
  75880. * @returns the current particle system
  75881. */
  75882. removeStartSizeGradient(gradient: number): IParticleSystem;
  75883. /**
  75884. * Gets the current list of start size gradients.
  75885. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  75886. * @returns the list of start size gradients
  75887. */
  75888. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  75889. /**
  75890. * Adds a new life time gradient
  75891. * @param gradient defines the gradient to use (between 0 and 1)
  75892. * @param factor defines the life time factor to affect to the specified gradient
  75893. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  75894. * @returns the current particle system
  75895. */
  75896. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  75897. /**
  75898. * Remove a specific life time gradient
  75899. * @param gradient defines the gradient to remove
  75900. * @returns the current particle system
  75901. */
  75902. removeLifeTimeGradient(gradient: number): IParticleSystem;
  75903. /**
  75904. * Gets the current list of life time gradients.
  75905. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  75906. * @returns the list of life time gradients
  75907. */
  75908. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  75909. /**
  75910. * Gets the current list of color gradients.
  75911. * You must use addColorGradient and removeColorGradient to udpate this list
  75912. * @returns the list of color gradients
  75913. */
  75914. getColorGradients(): Nullable<Array<ColorGradient>>;
  75915. /**
  75916. * Adds a new ramp gradient used to remap particle colors
  75917. * @param gradient defines the gradient to use (between 0 and 1)
  75918. * @param color defines the color to affect to the specified gradient
  75919. * @returns the current particle system
  75920. */
  75921. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  75922. /**
  75923. * Gets the current list of ramp gradients.
  75924. * You must use addRampGradient and removeRampGradient to udpate this list
  75925. * @returns the list of ramp gradients
  75926. */
  75927. getRampGradients(): Nullable<Array<Color3Gradient>>;
  75928. /** Gets or sets a boolean indicating that ramp gradients must be used
  75929. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  75930. */
  75931. useRampGradients: boolean;
  75932. /**
  75933. * Adds a new color remap gradient
  75934. * @param gradient defines the gradient to use (between 0 and 1)
  75935. * @param min defines the color remap minimal range
  75936. * @param max defines the color remap maximal range
  75937. * @returns the current particle system
  75938. */
  75939. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75940. /**
  75941. * Gets the current list of color remap gradients.
  75942. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  75943. * @returns the list of color remap gradients
  75944. */
  75945. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  75946. /**
  75947. * Adds a new alpha remap gradient
  75948. * @param gradient defines the gradient to use (between 0 and 1)
  75949. * @param min defines the alpha remap minimal range
  75950. * @param max defines the alpha remap maximal range
  75951. * @returns the current particle system
  75952. */
  75953. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  75954. /**
  75955. * Gets the current list of alpha remap gradients.
  75956. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  75957. * @returns the list of alpha remap gradients
  75958. */
  75959. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  75960. /**
  75961. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  75962. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  75963. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  75964. * @returns the emitter
  75965. */
  75966. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  75967. /**
  75968. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  75969. * @param radius The radius of the hemisphere to emit from
  75970. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75971. * @returns the emitter
  75972. */
  75973. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  75974. /**
  75975. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  75976. * @param radius The radius of the sphere to emit from
  75977. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  75978. * @returns the emitter
  75979. */
  75980. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  75981. /**
  75982. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  75983. * @param radius The radius of the sphere to emit from
  75984. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  75985. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  75986. * @returns the emitter
  75987. */
  75988. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  75989. /**
  75990. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  75991. * @param radius The radius of the emission cylinder
  75992. * @param height The height of the emission cylinder
  75993. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  75994. * @param directionRandomizer How much to randomize the particle direction [0-1]
  75995. * @returns the emitter
  75996. */
  75997. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  75998. /**
  75999. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  76000. * @param radius The radius of the cylinder to emit from
  76001. * @param height The height of the emission cylinder
  76002. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  76003. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  76004. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  76005. * @returns the emitter
  76006. */
  76007. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  76008. /**
  76009. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  76010. * @param radius The radius of the cone to emit from
  76011. * @param angle The base angle of the cone
  76012. * @returns the emitter
  76013. */
  76014. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  76015. /**
  76016. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  76017. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  76018. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  76019. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76020. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  76021. * @returns the emitter
  76022. */
  76023. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  76024. /**
  76025. * Get hosting scene
  76026. * @returns the scene
  76027. */
  76028. getScene(): Scene;
  76029. }
  76030. }
  76031. declare module BABYLON {
  76032. /**
  76033. * Creates an instance based on a source mesh.
  76034. */
  76035. export class InstancedMesh extends AbstractMesh {
  76036. private _sourceMesh;
  76037. private _currentLOD;
  76038. /** @hidden */
  76039. _indexInSourceMeshInstanceArray: number;
  76040. constructor(name: string, source: Mesh);
  76041. /**
  76042. * Returns the string "InstancedMesh".
  76043. */
  76044. getClassName(): string;
  76045. /**
  76046. * If the source mesh receives shadows
  76047. */
  76048. readonly receiveShadows: boolean;
  76049. /**
  76050. * The material of the source mesh
  76051. */
  76052. readonly material: Nullable<Material>;
  76053. /**
  76054. * Visibility of the source mesh
  76055. */
  76056. readonly visibility: number;
  76057. /**
  76058. * Skeleton of the source mesh
  76059. */
  76060. readonly skeleton: Nullable<Skeleton>;
  76061. /**
  76062. * Rendering ground id of the source mesh
  76063. */
  76064. renderingGroupId: number;
  76065. /**
  76066. * Returns the total number of vertices (integer).
  76067. */
  76068. getTotalVertices(): number;
  76069. /**
  76070. * Returns a positive integer : the total number of indices in this mesh geometry.
  76071. * @returns the numner of indices or zero if the mesh has no geometry.
  76072. */
  76073. getTotalIndices(): number;
  76074. /**
  76075. * The source mesh of the instance
  76076. */
  76077. readonly sourceMesh: Mesh;
  76078. /**
  76079. * Is this node ready to be used/rendered
  76080. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  76081. * @return {boolean} is it ready
  76082. */
  76083. isReady(completeCheck?: boolean): boolean;
  76084. /**
  76085. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  76086. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  76087. * @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.
  76088. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  76089. */
  76090. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  76091. /**
  76092. * Sets the vertex data of the mesh geometry for the requested `kind`.
  76093. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  76094. * The `data` are either a numeric array either a Float32Array.
  76095. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  76096. * 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).
  76097. * Note that a new underlying VertexBuffer object is created each call.
  76098. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  76099. *
  76100. * Possible `kind` values :
  76101. * - VertexBuffer.PositionKind
  76102. * - VertexBuffer.UVKind
  76103. * - VertexBuffer.UV2Kind
  76104. * - VertexBuffer.UV3Kind
  76105. * - VertexBuffer.UV4Kind
  76106. * - VertexBuffer.UV5Kind
  76107. * - VertexBuffer.UV6Kind
  76108. * - VertexBuffer.ColorKind
  76109. * - VertexBuffer.MatricesIndicesKind
  76110. * - VertexBuffer.MatricesIndicesExtraKind
  76111. * - VertexBuffer.MatricesWeightsKind
  76112. * - VertexBuffer.MatricesWeightsExtraKind
  76113. *
  76114. * Returns the Mesh.
  76115. */
  76116. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  76117. /**
  76118. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  76119. * If the mesh has no geometry, it is simply returned as it is.
  76120. * The `data` are either a numeric array either a Float32Array.
  76121. * No new underlying VertexBuffer object is created.
  76122. * 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.
  76123. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  76124. *
  76125. * Possible `kind` values :
  76126. * - VertexBuffer.PositionKind
  76127. * - VertexBuffer.UVKind
  76128. * - VertexBuffer.UV2Kind
  76129. * - VertexBuffer.UV3Kind
  76130. * - VertexBuffer.UV4Kind
  76131. * - VertexBuffer.UV5Kind
  76132. * - VertexBuffer.UV6Kind
  76133. * - VertexBuffer.ColorKind
  76134. * - VertexBuffer.MatricesIndicesKind
  76135. * - VertexBuffer.MatricesIndicesExtraKind
  76136. * - VertexBuffer.MatricesWeightsKind
  76137. * - VertexBuffer.MatricesWeightsExtraKind
  76138. *
  76139. * Returns the Mesh.
  76140. */
  76141. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  76142. /**
  76143. * Sets the mesh indices.
  76144. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  76145. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  76146. * This method creates a new index buffer each call.
  76147. * Returns the Mesh.
  76148. */
  76149. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  76150. /**
  76151. * Boolean : True if the mesh owns the requested kind of data.
  76152. */
  76153. isVerticesDataPresent(kind: string): boolean;
  76154. /**
  76155. * Returns an array of indices (IndicesArray).
  76156. */
  76157. getIndices(): Nullable<IndicesArray>;
  76158. readonly _positions: Nullable<Vector3[]>;
  76159. /**
  76160. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  76161. * This means the mesh underlying bounding box and sphere are recomputed.
  76162. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  76163. * @returns the current mesh
  76164. */
  76165. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  76166. /** @hidden */
  76167. _preActivate(): InstancedMesh;
  76168. /** @hidden */
  76169. _activate(renderId: number): boolean;
  76170. /**
  76171. * Returns the current associated LOD AbstractMesh.
  76172. */
  76173. getLOD(camera: Camera): AbstractMesh;
  76174. /** @hidden */
  76175. _syncSubMeshes(): InstancedMesh;
  76176. /** @hidden */
  76177. _generatePointsArray(): boolean;
  76178. /**
  76179. * Creates a new InstancedMesh from the current mesh.
  76180. * - name (string) : the cloned mesh name
  76181. * - newParent (optional Node) : the optional Node to parent the clone to.
  76182. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  76183. *
  76184. * Returns the clone.
  76185. */
  76186. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): InstancedMesh;
  76187. /**
  76188. * Disposes the InstancedMesh.
  76189. * Returns nothing.
  76190. */
  76191. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  76192. }
  76193. }
  76194. declare module BABYLON {
  76195. /**
  76196. * Defines the options associated with the creation of a shader material.
  76197. */
  76198. export interface IShaderMaterialOptions {
  76199. /**
  76200. * Does the material work in alpha blend mode
  76201. */
  76202. needAlphaBlending: boolean;
  76203. /**
  76204. * Does the material work in alpha test mode
  76205. */
  76206. needAlphaTesting: boolean;
  76207. /**
  76208. * The list of attribute names used in the shader
  76209. */
  76210. attributes: string[];
  76211. /**
  76212. * The list of unifrom names used in the shader
  76213. */
  76214. uniforms: string[];
  76215. /**
  76216. * The list of UBO names used in the shader
  76217. */
  76218. uniformBuffers: string[];
  76219. /**
  76220. * The list of sampler names used in the shader
  76221. */
  76222. samplers: string[];
  76223. /**
  76224. * The list of defines used in the shader
  76225. */
  76226. defines: string[];
  76227. }
  76228. /**
  76229. * 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.
  76230. *
  76231. * This returned material effects how the mesh will look based on the code in the shaders.
  76232. *
  76233. * @see http://doc.babylonjs.com/how_to/shader_material
  76234. */
  76235. export class ShaderMaterial extends Material {
  76236. private _shaderPath;
  76237. private _options;
  76238. private _textures;
  76239. private _textureArrays;
  76240. private _floats;
  76241. private _ints;
  76242. private _floatsArrays;
  76243. private _colors3;
  76244. private _colors3Arrays;
  76245. private _colors4;
  76246. private _vectors2;
  76247. private _vectors3;
  76248. private _vectors4;
  76249. private _matrices;
  76250. private _matrices3x3;
  76251. private _matrices2x2;
  76252. private _vectors2Arrays;
  76253. private _vectors3Arrays;
  76254. private _cachedWorldViewMatrix;
  76255. private _renderId;
  76256. /**
  76257. * Instantiate a new shader material.
  76258. * 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.
  76259. * This returned material effects how the mesh will look based on the code in the shaders.
  76260. * @see http://doc.babylonjs.com/how_to/shader_material
  76261. * @param name Define the name of the material in the scene
  76262. * @param scene Define the scene the material belongs to
  76263. * @param shaderPath Defines the route to the shader code in one of three ways:
  76264. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  76265. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  76266. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  76267. * @param options Define the options used to create the shader
  76268. */
  76269. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  76270. /**
  76271. * Gets the options used to compile the shader.
  76272. * They can be modified to trigger a new compilation
  76273. */
  76274. readonly options: IShaderMaterialOptions;
  76275. /**
  76276. * Gets the current class name of the material e.g. "ShaderMaterial"
  76277. * Mainly use in serialization.
  76278. * @returns the class name
  76279. */
  76280. getClassName(): string;
  76281. /**
  76282. * Specifies if the material will require alpha blending
  76283. * @returns a boolean specifying if alpha blending is needed
  76284. */
  76285. needAlphaBlending(): boolean;
  76286. /**
  76287. * Specifies if this material should be rendered in alpha test mode
  76288. * @returns a boolean specifying if an alpha test is needed.
  76289. */
  76290. needAlphaTesting(): boolean;
  76291. private _checkUniform;
  76292. /**
  76293. * Set a texture in the shader.
  76294. * @param name Define the name of the uniform samplers as defined in the shader
  76295. * @param texture Define the texture to bind to this sampler
  76296. * @return the material itself allowing "fluent" like uniform updates
  76297. */
  76298. setTexture(name: string, texture: Texture): ShaderMaterial;
  76299. /**
  76300. * Set a texture array in the shader.
  76301. * @param name Define the name of the uniform sampler array as defined in the shader
  76302. * @param textures Define the list of textures to bind to this sampler
  76303. * @return the material itself allowing "fluent" like uniform updates
  76304. */
  76305. setTextureArray(name: string, textures: Texture[]): ShaderMaterial;
  76306. /**
  76307. * Set a float in the shader.
  76308. * @param name Define the name of the uniform as defined in the shader
  76309. * @param value Define the value to give to the uniform
  76310. * @return the material itself allowing "fluent" like uniform updates
  76311. */
  76312. setFloat(name: string, value: number): ShaderMaterial;
  76313. /**
  76314. * Set a int in the shader.
  76315. * @param name Define the name of the uniform as defined in the shader
  76316. * @param value Define the value to give to the uniform
  76317. * @return the material itself allowing "fluent" like uniform updates
  76318. */
  76319. setInt(name: string, value: number): ShaderMaterial;
  76320. /**
  76321. * Set an array of floats in the shader.
  76322. * @param name Define the name of the uniform as defined in the shader
  76323. * @param value Define the value to give to the uniform
  76324. * @return the material itself allowing "fluent" like uniform updates
  76325. */
  76326. setFloats(name: string, value: number[]): ShaderMaterial;
  76327. /**
  76328. * Set a vec3 in the shader from a Color3.
  76329. * @param name Define the name of the uniform as defined in the shader
  76330. * @param value Define the value to give to the uniform
  76331. * @return the material itself allowing "fluent" like uniform updates
  76332. */
  76333. setColor3(name: string, value: Color3): ShaderMaterial;
  76334. /**
  76335. * Set a vec3 array in the shader from a Color3 array.
  76336. * @param name Define the name of the uniform as defined in the shader
  76337. * @param value Define the value to give to the uniform
  76338. * @return the material itself allowing "fluent" like uniform updates
  76339. */
  76340. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  76341. /**
  76342. * Set a vec4 in the shader from a Color4.
  76343. * @param name Define the name of the uniform as defined in the shader
  76344. * @param value Define the value to give to the uniform
  76345. * @return the material itself allowing "fluent" like uniform updates
  76346. */
  76347. setColor4(name: string, value: Color4): ShaderMaterial;
  76348. /**
  76349. * Set a vec2 in the shader from a Vector2.
  76350. * @param name Define the name of the uniform as defined in the shader
  76351. * @param value Define the value to give to the uniform
  76352. * @return the material itself allowing "fluent" like uniform updates
  76353. */
  76354. setVector2(name: string, value: Vector2): ShaderMaterial;
  76355. /**
  76356. * Set a vec3 in the shader from a Vector3.
  76357. * @param name Define the name of the uniform as defined in the shader
  76358. * @param value Define the value to give to the uniform
  76359. * @return the material itself allowing "fluent" like uniform updates
  76360. */
  76361. setVector3(name: string, value: Vector3): ShaderMaterial;
  76362. /**
  76363. * Set a vec4 in the shader from a Vector4.
  76364. * @param name Define the name of the uniform as defined in the shader
  76365. * @param value Define the value to give to the uniform
  76366. * @return the material itself allowing "fluent" like uniform updates
  76367. */
  76368. setVector4(name: string, value: Vector4): ShaderMaterial;
  76369. /**
  76370. * Set a mat4 in the shader from a Matrix.
  76371. * @param name Define the name of the uniform as defined in the shader
  76372. * @param value Define the value to give to the uniform
  76373. * @return the material itself allowing "fluent" like uniform updates
  76374. */
  76375. setMatrix(name: string, value: Matrix): ShaderMaterial;
  76376. /**
  76377. * Set a mat3 in the shader from a Float32Array.
  76378. * @param name Define the name of the uniform as defined in the shader
  76379. * @param value Define the value to give to the uniform
  76380. * @return the material itself allowing "fluent" like uniform updates
  76381. */
  76382. setMatrix3x3(name: string, value: Float32Array): ShaderMaterial;
  76383. /**
  76384. * Set a mat2 in the shader from a Float32Array.
  76385. * @param name Define the name of the uniform as defined in the shader
  76386. * @param value Define the value to give to the uniform
  76387. * @return the material itself allowing "fluent" like uniform updates
  76388. */
  76389. setMatrix2x2(name: string, value: Float32Array): ShaderMaterial;
  76390. /**
  76391. * Set a vec2 array in the shader from a number array.
  76392. * @param name Define the name of the uniform as defined in the shader
  76393. * @param value Define the value to give to the uniform
  76394. * @return the material itself allowing "fluent" like uniform updates
  76395. */
  76396. setArray2(name: string, value: number[]): ShaderMaterial;
  76397. /**
  76398. * Set a vec3 array in the shader from a number array.
  76399. * @param name Define the name of the uniform as defined in the shader
  76400. * @param value Define the value to give to the uniform
  76401. * @return the material itself allowing "fluent" like uniform updates
  76402. */
  76403. setArray3(name: string, value: number[]): ShaderMaterial;
  76404. private _checkCache;
  76405. /**
  76406. * Specifies that the submesh is ready to be used
  76407. * @param mesh defines the mesh to check
  76408. * @param subMesh defines which submesh to check
  76409. * @param useInstances specifies that instances should be used
  76410. * @returns a boolean indicating that the submesh is ready or not
  76411. */
  76412. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  76413. /**
  76414. * Checks if the material is ready to render the requested mesh
  76415. * @param mesh Define the mesh to render
  76416. * @param useInstances Define whether or not the material is used with instances
  76417. * @returns true if ready, otherwise false
  76418. */
  76419. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  76420. /**
  76421. * Binds the world matrix to the material
  76422. * @param world defines the world transformation matrix
  76423. */
  76424. bindOnlyWorldMatrix(world: Matrix): void;
  76425. /**
  76426. * Binds the material to the mesh
  76427. * @param world defines the world transformation matrix
  76428. * @param mesh defines the mesh to bind the material to
  76429. */
  76430. bind(world: Matrix, mesh?: Mesh): void;
  76431. /**
  76432. * Gets the active textures from the material
  76433. * @returns an array of textures
  76434. */
  76435. getActiveTextures(): BaseTexture[];
  76436. /**
  76437. * Specifies if the material uses a texture
  76438. * @param texture defines the texture to check against the material
  76439. * @returns a boolean specifying if the material uses the texture
  76440. */
  76441. hasTexture(texture: BaseTexture): boolean;
  76442. /**
  76443. * Makes a duplicate of the material, and gives it a new name
  76444. * @param name defines the new name for the duplicated material
  76445. * @returns the cloned material
  76446. */
  76447. clone(name: string): ShaderMaterial;
  76448. /**
  76449. * Disposes the material
  76450. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  76451. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  76452. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  76453. */
  76454. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  76455. /**
  76456. * Serializes this material in a JSON representation
  76457. * @returns the serialized material object
  76458. */
  76459. serialize(): any;
  76460. /**
  76461. * Creates a shader material from parsed shader material data
  76462. * @param source defines the JSON represnetation of the material
  76463. * @param scene defines the hosting scene
  76464. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  76465. * @returns a new material
  76466. */
  76467. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  76468. }
  76469. }
  76470. declare module BABYLON {
  76471. /** @hidden */
  76472. export var colorPixelShader: {
  76473. name: string;
  76474. shader: string;
  76475. };
  76476. }
  76477. declare module BABYLON {
  76478. /** @hidden */
  76479. export var colorVertexShader: {
  76480. name: string;
  76481. shader: string;
  76482. };
  76483. }
  76484. declare module BABYLON {
  76485. /**
  76486. * Line mesh
  76487. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  76488. */
  76489. export class LinesMesh extends Mesh {
  76490. /**
  76491. * If vertex color should be applied to the mesh
  76492. */
  76493. useVertexColor?: boolean | undefined;
  76494. /**
  76495. * If vertex alpha should be applied to the mesh
  76496. */
  76497. useVertexAlpha?: boolean | undefined;
  76498. /**
  76499. * Color of the line (Default: White)
  76500. */
  76501. color: Color3;
  76502. /**
  76503. * Alpha of the line (Default: 1)
  76504. */
  76505. alpha: number;
  76506. /**
  76507. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76508. * This margin is expressed in world space coordinates, so its value may vary.
  76509. * Default value is 0.1
  76510. */
  76511. intersectionThreshold: number;
  76512. private _colorShader;
  76513. /**
  76514. * Creates a new LinesMesh
  76515. * @param name defines the name
  76516. * @param scene defines the hosting scene
  76517. * @param parent defines the parent mesh if any
  76518. * @param source defines the optional source LinesMesh used to clone data from
  76519. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  76520. * When false, achieved by calling a clone(), also passing False.
  76521. * This will make creation of children, recursive.
  76522. * @param useVertexColor defines if this LinesMesh supports vertex color
  76523. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  76524. */
  76525. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: LinesMesh, doNotCloneChildren?: boolean,
  76526. /**
  76527. * If vertex color should be applied to the mesh
  76528. */
  76529. useVertexColor?: boolean | undefined,
  76530. /**
  76531. * If vertex alpha should be applied to the mesh
  76532. */
  76533. useVertexAlpha?: boolean | undefined);
  76534. private _addClipPlaneDefine;
  76535. private _removeClipPlaneDefine;
  76536. isReady(): boolean;
  76537. /**
  76538. * Returns the string "LineMesh"
  76539. */
  76540. getClassName(): string;
  76541. /**
  76542. * @hidden
  76543. */
  76544. /**
  76545. * @hidden
  76546. */
  76547. material: Material;
  76548. /**
  76549. * @hidden
  76550. */
  76551. readonly checkCollisions: boolean;
  76552. /** @hidden */
  76553. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): LinesMesh;
  76554. /** @hidden */
  76555. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): LinesMesh;
  76556. /**
  76557. * Disposes of the line mesh
  76558. * @param doNotRecurse If children should be disposed
  76559. */
  76560. dispose(doNotRecurse?: boolean): void;
  76561. /**
  76562. * Returns a new LineMesh object cloned from the current one.
  76563. */
  76564. clone(name: string, newParent?: Node, doNotCloneChildren?: boolean): LinesMesh;
  76565. /**
  76566. * Creates a new InstancedLinesMesh object from the mesh model.
  76567. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  76568. * @param name defines the name of the new instance
  76569. * @returns a new InstancedLinesMesh
  76570. */
  76571. createInstance(name: string): InstancedLinesMesh;
  76572. }
  76573. /**
  76574. * Creates an instance based on a source LinesMesh
  76575. */
  76576. export class InstancedLinesMesh extends InstancedMesh {
  76577. /**
  76578. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  76579. * This margin is expressed in world space coordinates, so its value may vary.
  76580. * Initilized with the intersectionThreshold value of the source LinesMesh
  76581. */
  76582. intersectionThreshold: number;
  76583. constructor(name: string, source: LinesMesh);
  76584. /**
  76585. * Returns the string "InstancedLinesMesh".
  76586. */
  76587. getClassName(): string;
  76588. }
  76589. }
  76590. declare module BABYLON {
  76591. /** @hidden */
  76592. export var linePixelShader: {
  76593. name: string;
  76594. shader: string;
  76595. };
  76596. }
  76597. declare module BABYLON {
  76598. /** @hidden */
  76599. export var lineVertexShader: {
  76600. name: string;
  76601. shader: string;
  76602. };
  76603. }
  76604. declare module BABYLON {
  76605. interface AbstractMesh {
  76606. /**
  76607. * Disables the mesh edge rendering mode
  76608. * @returns the currentAbstractMesh
  76609. */
  76610. disableEdgesRendering(): AbstractMesh;
  76611. /**
  76612. * Enables the edge rendering mode on the mesh.
  76613. * This mode makes the mesh edges visible
  76614. * @param epsilon defines the maximal distance between two angles to detect a face
  76615. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76616. * @returns the currentAbstractMesh
  76617. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76618. */
  76619. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76620. /**
  76621. * Gets the edgesRenderer associated with the mesh
  76622. */
  76623. edgesRenderer: Nullable<EdgesRenderer>;
  76624. }
  76625. interface LinesMesh {
  76626. /**
  76627. * Enables the edge rendering mode on the mesh.
  76628. * This mode makes the mesh edges visible
  76629. * @param epsilon defines the maximal distance between two angles to detect a face
  76630. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76631. * @returns the currentAbstractMesh
  76632. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76633. */
  76634. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  76635. }
  76636. interface InstancedLinesMesh {
  76637. /**
  76638. * Enables the edge rendering mode on the mesh.
  76639. * This mode makes the mesh edges visible
  76640. * @param epsilon defines the maximal distance between two angles to detect a face
  76641. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  76642. * @returns the current InstancedLinesMesh
  76643. * @see https://www.babylonjs-playground.com/#19O9TU#0
  76644. */
  76645. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  76646. }
  76647. /**
  76648. * Defines the minimum contract an Edges renderer should follow.
  76649. */
  76650. export interface IEdgesRenderer extends IDisposable {
  76651. /**
  76652. * Gets or sets a boolean indicating if the edgesRenderer is active
  76653. */
  76654. isEnabled: boolean;
  76655. /**
  76656. * Renders the edges of the attached mesh,
  76657. */
  76658. render(): void;
  76659. /**
  76660. * Checks wether or not the edges renderer is ready to render.
  76661. * @return true if ready, otherwise false.
  76662. */
  76663. isReady(): boolean;
  76664. }
  76665. /**
  76666. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  76667. */
  76668. export class EdgesRenderer implements IEdgesRenderer {
  76669. /**
  76670. * Define the size of the edges with an orthographic camera
  76671. */
  76672. edgesWidthScalerForOrthographic: number;
  76673. /**
  76674. * Define the size of the edges with a perspective camera
  76675. */
  76676. edgesWidthScalerForPerspective: number;
  76677. protected _source: AbstractMesh;
  76678. protected _linesPositions: number[];
  76679. protected _linesNormals: number[];
  76680. protected _linesIndices: number[];
  76681. protected _epsilon: number;
  76682. protected _indicesCount: number;
  76683. protected _lineShader: ShaderMaterial;
  76684. protected _ib: WebGLBuffer;
  76685. protected _buffers: {
  76686. [key: string]: Nullable<VertexBuffer>;
  76687. };
  76688. protected _checkVerticesInsteadOfIndices: boolean;
  76689. private _meshRebuildObserver;
  76690. private _meshDisposeObserver;
  76691. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  76692. isEnabled: boolean;
  76693. /**
  76694. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  76695. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  76696. * @param source Mesh used to create edges
  76697. * @param epsilon sum of angles in adjacency to check for edge
  76698. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  76699. * @param generateEdgesLines - should generate Lines or only prepare resources.
  76700. */
  76701. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean);
  76702. protected _prepareRessources(): void;
  76703. /** @hidden */
  76704. _rebuild(): void;
  76705. /**
  76706. * Releases the required resources for the edges renderer
  76707. */
  76708. dispose(): void;
  76709. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  76710. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  76711. /**
  76712. * Checks if the pair of p0 and p1 is en edge
  76713. * @param faceIndex
  76714. * @param edge
  76715. * @param faceNormals
  76716. * @param p0
  76717. * @param p1
  76718. * @private
  76719. */
  76720. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  76721. /**
  76722. * push line into the position, normal and index buffer
  76723. * @protected
  76724. */
  76725. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  76726. /**
  76727. * Generates lines edges from adjacencjes
  76728. * @private
  76729. */
  76730. _generateEdgesLines(): void;
  76731. /**
  76732. * Checks wether or not the edges renderer is ready to render.
  76733. * @return true if ready, otherwise false.
  76734. */
  76735. isReady(): boolean;
  76736. /**
  76737. * Renders the edges of the attached mesh,
  76738. */
  76739. render(): void;
  76740. }
  76741. /**
  76742. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  76743. */
  76744. export class LineEdgesRenderer extends EdgesRenderer {
  76745. /**
  76746. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  76747. * @param source LineMesh used to generate edges
  76748. * @param epsilon not important (specified angle for edge detection)
  76749. * @param checkVerticesInsteadOfIndices not important for LineMesh
  76750. */
  76751. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  76752. /**
  76753. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  76754. */
  76755. _generateEdgesLines(): void;
  76756. }
  76757. }
  76758. declare module BABYLON {
  76759. /**
  76760. * This represents the object necessary to create a rendering group.
  76761. * This is exclusively used and created by the rendering manager.
  76762. * To modify the behavior, you use the available helpers in your scene or meshes.
  76763. * @hidden
  76764. */
  76765. export class RenderingGroup {
  76766. index: number;
  76767. private _scene;
  76768. private _opaqueSubMeshes;
  76769. private _transparentSubMeshes;
  76770. private _alphaTestSubMeshes;
  76771. private _depthOnlySubMeshes;
  76772. private _particleSystems;
  76773. private _spriteManagers;
  76774. private _opaqueSortCompareFn;
  76775. private _alphaTestSortCompareFn;
  76776. private _transparentSortCompareFn;
  76777. private _renderOpaque;
  76778. private _renderAlphaTest;
  76779. private _renderTransparent;
  76780. /** @hidden */
  76781. _edgesRenderers: SmartArray<IEdgesRenderer>;
  76782. onBeforeTransparentRendering: () => void;
  76783. /**
  76784. * Set the opaque sort comparison function.
  76785. * If null the sub meshes will be render in the order they were created
  76786. */
  76787. opaqueSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76788. /**
  76789. * Set the alpha test sort comparison function.
  76790. * If null the sub meshes will be render in the order they were created
  76791. */
  76792. alphaTestSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76793. /**
  76794. * Set the transparent sort comparison function.
  76795. * If null the sub meshes will be render in the order they were created
  76796. */
  76797. transparentSortCompareFn: Nullable<(a: SubMesh, b: SubMesh) => number>;
  76798. /**
  76799. * Creates a new rendering group.
  76800. * @param index The rendering group index
  76801. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  76802. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  76803. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  76804. */
  76805. 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>);
  76806. /**
  76807. * Render all the sub meshes contained in the group.
  76808. * @param customRenderFunction Used to override the default render behaviour of the group.
  76809. * @returns true if rendered some submeshes.
  76810. */
  76811. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  76812. /**
  76813. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  76814. * @param subMeshes The submeshes to render
  76815. */
  76816. private renderOpaqueSorted;
  76817. /**
  76818. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  76819. * @param subMeshes The submeshes to render
  76820. */
  76821. private renderAlphaTestSorted;
  76822. /**
  76823. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  76824. * @param subMeshes The submeshes to render
  76825. */
  76826. private renderTransparentSorted;
  76827. /**
  76828. * Renders the submeshes in a specified order.
  76829. * @param subMeshes The submeshes to sort before render
  76830. * @param sortCompareFn The comparison function use to sort
  76831. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  76832. * @param transparent Specifies to activate blending if true
  76833. */
  76834. private static renderSorted;
  76835. /**
  76836. * Renders the submeshes in the order they were dispatched (no sort applied).
  76837. * @param subMeshes The submeshes to render
  76838. */
  76839. private static renderUnsorted;
  76840. /**
  76841. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76842. * are rendered back to front if in the same alpha index.
  76843. *
  76844. * @param a The first submesh
  76845. * @param b The second submesh
  76846. * @returns The result of the comparison
  76847. */
  76848. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  76849. /**
  76850. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76851. * are rendered back to front.
  76852. *
  76853. * @param a The first submesh
  76854. * @param b The second submesh
  76855. * @returns The result of the comparison
  76856. */
  76857. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  76858. /**
  76859. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  76860. * are rendered front to back (prevent overdraw).
  76861. *
  76862. * @param a The first submesh
  76863. * @param b The second submesh
  76864. * @returns The result of the comparison
  76865. */
  76866. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  76867. /**
  76868. * Resets the different lists of submeshes to prepare a new frame.
  76869. */
  76870. prepare(): void;
  76871. dispose(): void;
  76872. /**
  76873. * Inserts the submesh in its correct queue depending on its material.
  76874. * @param subMesh The submesh to dispatch
  76875. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76876. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76877. */
  76878. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76879. dispatchSprites(spriteManager: ISpriteManager): void;
  76880. dispatchParticles(particleSystem: IParticleSystem): void;
  76881. private _renderParticles;
  76882. private _renderSprites;
  76883. }
  76884. }
  76885. declare module BABYLON {
  76886. /**
  76887. * Interface describing the different options available in the rendering manager
  76888. * regarding Auto Clear between groups.
  76889. */
  76890. export interface IRenderingManagerAutoClearSetup {
  76891. /**
  76892. * Defines whether or not autoclear is enable.
  76893. */
  76894. autoClear: boolean;
  76895. /**
  76896. * Defines whether or not to autoclear the depth buffer.
  76897. */
  76898. depth: boolean;
  76899. /**
  76900. * Defines whether or not to autoclear the stencil buffer.
  76901. */
  76902. stencil: boolean;
  76903. }
  76904. /**
  76905. * This class is used by the onRenderingGroupObservable
  76906. */
  76907. export class RenderingGroupInfo {
  76908. /**
  76909. * The Scene that being rendered
  76910. */
  76911. scene: Scene;
  76912. /**
  76913. * The camera currently used for the rendering pass
  76914. */
  76915. camera: Nullable<Camera>;
  76916. /**
  76917. * The ID of the renderingGroup being processed
  76918. */
  76919. renderingGroupId: number;
  76920. }
  76921. /**
  76922. * This is the manager responsible of all the rendering for meshes sprites and particles.
  76923. * It is enable to manage the different groups as well as the different necessary sort functions.
  76924. * This should not be used directly aside of the few static configurations
  76925. */
  76926. export class RenderingManager {
  76927. /**
  76928. * The max id used for rendering groups (not included)
  76929. */
  76930. static MAX_RENDERINGGROUPS: number;
  76931. /**
  76932. * The min id used for rendering groups (included)
  76933. */
  76934. static MIN_RENDERINGGROUPS: number;
  76935. /**
  76936. * Used to globally prevent autoclearing scenes.
  76937. */
  76938. static AUTOCLEAR: boolean;
  76939. /**
  76940. * @hidden
  76941. */
  76942. _useSceneAutoClearSetup: boolean;
  76943. private _scene;
  76944. private _renderingGroups;
  76945. private _depthStencilBufferAlreadyCleaned;
  76946. private _autoClearDepthStencil;
  76947. private _customOpaqueSortCompareFn;
  76948. private _customAlphaTestSortCompareFn;
  76949. private _customTransparentSortCompareFn;
  76950. private _renderingGroupInfo;
  76951. /**
  76952. * Instantiates a new rendering group for a particular scene
  76953. * @param scene Defines the scene the groups belongs to
  76954. */
  76955. constructor(scene: Scene);
  76956. private _clearDepthStencilBuffer;
  76957. /**
  76958. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  76959. * @hidden
  76960. */
  76961. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  76962. /**
  76963. * Resets the different information of the group to prepare a new frame
  76964. * @hidden
  76965. */
  76966. reset(): void;
  76967. /**
  76968. * Dispose and release the group and its associated resources.
  76969. * @hidden
  76970. */
  76971. dispose(): void;
  76972. /**
  76973. * Clear the info related to rendering groups preventing retention points during dispose.
  76974. */
  76975. freeRenderingGroups(): void;
  76976. private _prepareRenderingGroup;
  76977. /**
  76978. * Add a sprite manager to the rendering manager in order to render it this frame.
  76979. * @param spriteManager Define the sprite manager to render
  76980. */
  76981. dispatchSprites(spriteManager: ISpriteManager): void;
  76982. /**
  76983. * Add a particle system to the rendering manager in order to render it this frame.
  76984. * @param particleSystem Define the particle system to render
  76985. */
  76986. dispatchParticles(particleSystem: IParticleSystem): void;
  76987. /**
  76988. * Add a submesh to the manager in order to render it this frame
  76989. * @param subMesh The submesh to dispatch
  76990. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  76991. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  76992. */
  76993. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  76994. /**
  76995. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  76996. * This allowed control for front to back rendering or reversly depending of the special needs.
  76997. *
  76998. * @param renderingGroupId The rendering group id corresponding to its index
  76999. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77000. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77001. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77002. */
  77003. 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;
  77004. /**
  77005. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77006. *
  77007. * @param renderingGroupId The rendering group id corresponding to its index
  77008. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77009. * @param depth Automatically clears depth between groups if true and autoClear is true.
  77010. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  77011. */
  77012. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  77013. /**
  77014. * Gets the current auto clear configuration for one rendering group of the rendering
  77015. * manager.
  77016. * @param index the rendering group index to get the information for
  77017. * @returns The auto clear setup for the requested rendering group
  77018. */
  77019. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  77020. }
  77021. }
  77022. declare module BABYLON {
  77023. /**
  77024. * This Helps creating a texture that will be created from a camera in your scene.
  77025. * It is basically a dynamic texture that could be used to create special effects for instance.
  77026. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  77027. */
  77028. export class RenderTargetTexture extends Texture {
  77029. isCube: boolean;
  77030. /**
  77031. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  77032. */
  77033. static readonly REFRESHRATE_RENDER_ONCE: number;
  77034. /**
  77035. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  77036. */
  77037. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  77038. /**
  77039. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  77040. * the central point of your effect and can save a lot of performances.
  77041. */
  77042. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  77043. /**
  77044. * Use this predicate to dynamically define the list of mesh you want to render.
  77045. * If set, the renderList property will be overwritten.
  77046. */
  77047. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  77048. private _renderList;
  77049. /**
  77050. * Use this list to define the list of mesh you want to render.
  77051. */
  77052. renderList: Nullable<Array<AbstractMesh>>;
  77053. private _hookArray;
  77054. /**
  77055. * Define if particles should be rendered in your texture.
  77056. */
  77057. renderParticles: boolean;
  77058. /**
  77059. * Define if sprites should be rendered in your texture.
  77060. */
  77061. renderSprites: boolean;
  77062. /**
  77063. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  77064. */
  77065. coordinatesMode: number;
  77066. /**
  77067. * Define the camera used to render the texture.
  77068. */
  77069. activeCamera: Nullable<Camera>;
  77070. /**
  77071. * Override the render function of the texture with your own one.
  77072. */
  77073. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  77074. /**
  77075. * Define if camera post processes should be use while rendering the texture.
  77076. */
  77077. useCameraPostProcesses: boolean;
  77078. /**
  77079. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  77080. */
  77081. ignoreCameraViewport: boolean;
  77082. private _postProcessManager;
  77083. private _postProcesses;
  77084. private _resizeObserver;
  77085. /**
  77086. * An event triggered when the texture is unbind.
  77087. */
  77088. onBeforeBindObservable: Observable<RenderTargetTexture>;
  77089. /**
  77090. * An event triggered when the texture is unbind.
  77091. */
  77092. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  77093. private _onAfterUnbindObserver;
  77094. /**
  77095. * Set a after unbind callback in the texture.
  77096. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  77097. */
  77098. onAfterUnbind: () => void;
  77099. /**
  77100. * An event triggered before rendering the texture
  77101. */
  77102. onBeforeRenderObservable: Observable<number>;
  77103. private _onBeforeRenderObserver;
  77104. /**
  77105. * Set a before render callback in the texture.
  77106. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  77107. */
  77108. onBeforeRender: (faceIndex: number) => void;
  77109. /**
  77110. * An event triggered after rendering the texture
  77111. */
  77112. onAfterRenderObservable: Observable<number>;
  77113. private _onAfterRenderObserver;
  77114. /**
  77115. * Set a after render callback in the texture.
  77116. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  77117. */
  77118. onAfterRender: (faceIndex: number) => void;
  77119. /**
  77120. * An event triggered after the texture clear
  77121. */
  77122. onClearObservable: Observable<Engine>;
  77123. private _onClearObserver;
  77124. /**
  77125. * Set a clear callback in the texture.
  77126. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  77127. */
  77128. onClear: (Engine: Engine) => void;
  77129. /**
  77130. * Define the clear color of the Render Target if it should be different from the scene.
  77131. */
  77132. clearColor: Color4;
  77133. protected _size: number | {
  77134. width: number;
  77135. height: number;
  77136. };
  77137. protected _initialSizeParameter: number | {
  77138. width: number;
  77139. height: number;
  77140. } | {
  77141. ratio: number;
  77142. };
  77143. protected _sizeRatio: Nullable<number>;
  77144. /** @hidden */
  77145. _generateMipMaps: boolean;
  77146. protected _renderingManager: RenderingManager;
  77147. /** @hidden */
  77148. _waitingRenderList: string[];
  77149. protected _doNotChangeAspectRatio: boolean;
  77150. protected _currentRefreshId: number;
  77151. protected _refreshRate: number;
  77152. protected _textureMatrix: Matrix;
  77153. protected _samples: number;
  77154. protected _renderTargetOptions: RenderTargetCreationOptions;
  77155. /**
  77156. * Gets render target creation options that were used.
  77157. */
  77158. readonly renderTargetOptions: RenderTargetCreationOptions;
  77159. protected _engine: Engine;
  77160. protected _onRatioRescale(): void;
  77161. /**
  77162. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  77163. * It must define where the camera used to render the texture is set
  77164. */
  77165. boundingBoxPosition: Vector3;
  77166. private _boundingBoxSize;
  77167. /**
  77168. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  77169. * When defined, the cubemap will switch to local mode
  77170. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  77171. * @example https://www.babylonjs-playground.com/#RNASML
  77172. */
  77173. boundingBoxSize: Vector3;
  77174. /**
  77175. * In case the RTT has been created with a depth texture, get the associated
  77176. * depth texture.
  77177. * Otherwise, return null.
  77178. */
  77179. depthStencilTexture: Nullable<InternalTexture>;
  77180. /**
  77181. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  77182. * or used a shadow, depth texture...
  77183. * @param name The friendly name of the texture
  77184. * @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)
  77185. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  77186. * @param generateMipMaps True if mip maps need to be generated after render.
  77187. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  77188. * @param type The type of the buffer in the RTT (int, half float, float...)
  77189. * @param isCube True if a cube texture needs to be created
  77190. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  77191. * @param generateDepthBuffer True to generate a depth buffer
  77192. * @param generateStencilBuffer True to generate a stencil buffer
  77193. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  77194. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  77195. * @param delayAllocation if the texture allocation should be delayed (default: false)
  77196. */
  77197. constructor(name: string, size: number | {
  77198. width: number;
  77199. height: number;
  77200. } | {
  77201. ratio: number;
  77202. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  77203. /**
  77204. * Creates a depth stencil texture.
  77205. * This is only available in WebGL 2 or with the depth texture extension available.
  77206. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  77207. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  77208. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  77209. */
  77210. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  77211. private _processSizeParameter;
  77212. /**
  77213. * Define the number of samples to use in case of MSAA.
  77214. * It defaults to one meaning no MSAA has been enabled.
  77215. */
  77216. samples: number;
  77217. /**
  77218. * Resets the refresh counter of the texture and start bak from scratch.
  77219. * Could be useful to regenerate the texture if it is setup to render only once.
  77220. */
  77221. resetRefreshCounter(): void;
  77222. /**
  77223. * Define the refresh rate of the texture or the rendering frequency.
  77224. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  77225. */
  77226. refreshRate: number;
  77227. /**
  77228. * Adds a post process to the render target rendering passes.
  77229. * @param postProcess define the post process to add
  77230. */
  77231. addPostProcess(postProcess: PostProcess): void;
  77232. /**
  77233. * Clear all the post processes attached to the render target
  77234. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  77235. */
  77236. clearPostProcesses(dispose?: boolean): void;
  77237. /**
  77238. * Remove one of the post process from the list of attached post processes to the texture
  77239. * @param postProcess define the post process to remove from the list
  77240. */
  77241. removePostProcess(postProcess: PostProcess): void;
  77242. /** @hidden */
  77243. _shouldRender(): boolean;
  77244. /**
  77245. * Gets the actual render size of the texture.
  77246. * @returns the width of the render size
  77247. */
  77248. getRenderSize(): number;
  77249. /**
  77250. * Gets the actual render width of the texture.
  77251. * @returns the width of the render size
  77252. */
  77253. getRenderWidth(): number;
  77254. /**
  77255. * Gets the actual render height of the texture.
  77256. * @returns the height of the render size
  77257. */
  77258. getRenderHeight(): number;
  77259. /**
  77260. * Get if the texture can be rescaled or not.
  77261. */
  77262. readonly canRescale: boolean;
  77263. /**
  77264. * Resize the texture using a ratio.
  77265. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  77266. */
  77267. scale(ratio: number): void;
  77268. /**
  77269. * Get the texture reflection matrix used to rotate/transform the reflection.
  77270. * @returns the reflection matrix
  77271. */
  77272. getReflectionTextureMatrix(): Matrix;
  77273. /**
  77274. * Resize the texture to a new desired size.
  77275. * Be carrefull as it will recreate all the data in the new texture.
  77276. * @param size Define the new size. It can be:
  77277. * - a number for squared texture,
  77278. * - an object containing { width: number, height: number }
  77279. * - or an object containing a ratio { ratio: number }
  77280. */
  77281. resize(size: number | {
  77282. width: number;
  77283. height: number;
  77284. } | {
  77285. ratio: number;
  77286. }): void;
  77287. /**
  77288. * Renders all the objects from the render list into the texture.
  77289. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  77290. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  77291. */
  77292. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  77293. private _bestReflectionRenderTargetDimension;
  77294. /**
  77295. * @hidden
  77296. * @param faceIndex face index to bind to if this is a cubetexture
  77297. */
  77298. _bindFrameBuffer(faceIndex?: number): void;
  77299. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  77300. private renderToTarget;
  77301. /**
  77302. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  77303. * This allowed control for front to back rendering or reversly depending of the special needs.
  77304. *
  77305. * @param renderingGroupId The rendering group id corresponding to its index
  77306. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  77307. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  77308. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  77309. */
  77310. 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;
  77311. /**
  77312. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  77313. *
  77314. * @param renderingGroupId The rendering group id corresponding to its index
  77315. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  77316. */
  77317. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  77318. /**
  77319. * Clones the texture.
  77320. * @returns the cloned texture
  77321. */
  77322. clone(): RenderTargetTexture;
  77323. /**
  77324. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77325. * @returns The JSON representation of the texture
  77326. */
  77327. serialize(): any;
  77328. /**
  77329. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  77330. */
  77331. disposeFramebufferObjects(): void;
  77332. /**
  77333. * Dispose the texture and release its associated resources.
  77334. */
  77335. dispose(): void;
  77336. /** @hidden */
  77337. _rebuild(): void;
  77338. /**
  77339. * Clear the info related to rendering groups preventing retention point in material dispose.
  77340. */
  77341. freeRenderingGroups(): void;
  77342. /**
  77343. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  77344. * @returns the view count
  77345. */
  77346. getViewCount(): number;
  77347. }
  77348. }
  77349. declare module BABYLON {
  77350. /**
  77351. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77352. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77353. * You can then easily use it as a reflectionTexture on a flat surface.
  77354. * In case the surface is not a plane, please consider relying on reflection probes.
  77355. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77356. */
  77357. export class MirrorTexture extends RenderTargetTexture {
  77358. private scene;
  77359. /**
  77360. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  77361. * 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.
  77362. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77363. */
  77364. mirrorPlane: Plane;
  77365. /**
  77366. * Define the blur ratio used to blur the reflection if needed.
  77367. */
  77368. blurRatio: number;
  77369. /**
  77370. * Define the adaptive blur kernel used to blur the reflection if needed.
  77371. * This will autocompute the closest best match for the `blurKernel`
  77372. */
  77373. adaptiveBlurKernel: number;
  77374. /**
  77375. * Define the blur kernel used to blur the reflection if needed.
  77376. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77377. */
  77378. blurKernel: number;
  77379. /**
  77380. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  77381. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77382. */
  77383. blurKernelX: number;
  77384. /**
  77385. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  77386. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  77387. */
  77388. blurKernelY: number;
  77389. private _autoComputeBlurKernel;
  77390. protected _onRatioRescale(): void;
  77391. private _updateGammaSpace;
  77392. private _imageProcessingConfigChangeObserver;
  77393. private _transformMatrix;
  77394. private _mirrorMatrix;
  77395. private _savedViewMatrix;
  77396. private _blurX;
  77397. private _blurY;
  77398. private _adaptiveBlurKernel;
  77399. private _blurKernelX;
  77400. private _blurKernelY;
  77401. private _blurRatio;
  77402. /**
  77403. * Instantiates a Mirror Texture.
  77404. * Mirror texture can be used to simulate the view from a mirror in a scene.
  77405. * It will dynamically be rendered every frame to adapt to the camera point of view.
  77406. * You can then easily use it as a reflectionTexture on a flat surface.
  77407. * In case the surface is not a plane, please consider relying on reflection probes.
  77408. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  77409. * @param name
  77410. * @param size
  77411. * @param scene
  77412. * @param generateMipMaps
  77413. * @param type
  77414. * @param samplingMode
  77415. * @param generateDepthBuffer
  77416. */
  77417. constructor(name: string, size: number | {
  77418. width: number;
  77419. height: number;
  77420. } | {
  77421. ratio: number;
  77422. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  77423. private _preparePostProcesses;
  77424. /**
  77425. * Clone the mirror texture.
  77426. * @returns the cloned texture
  77427. */
  77428. clone(): MirrorTexture;
  77429. /**
  77430. * Serialize the texture to a JSON representation you could use in Parse later on
  77431. * @returns the serialized JSON representation
  77432. */
  77433. serialize(): any;
  77434. /**
  77435. * Dispose the texture and release its associated resources.
  77436. */
  77437. dispose(): void;
  77438. }
  77439. }
  77440. declare module BABYLON {
  77441. /**
  77442. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77443. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77444. */
  77445. export class Texture extends BaseTexture {
  77446. /** @hidden */
  77447. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  77448. /** @hidden */
  77449. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  77450. /** @hidden */
  77451. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  77452. /** nearest is mag = nearest and min = nearest and mip = linear */
  77453. static readonly NEAREST_SAMPLINGMODE: number;
  77454. /** nearest is mag = nearest and min = nearest and mip = linear */
  77455. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  77456. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77457. static readonly BILINEAR_SAMPLINGMODE: number;
  77458. /** Bilinear is mag = linear and min = linear and mip = nearest */
  77459. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  77460. /** Trilinear is mag = linear and min = linear and mip = linear */
  77461. static readonly TRILINEAR_SAMPLINGMODE: number;
  77462. /** Trilinear is mag = linear and min = linear and mip = linear */
  77463. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  77464. /** mag = nearest and min = nearest and mip = nearest */
  77465. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  77466. /** mag = nearest and min = linear and mip = nearest */
  77467. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  77468. /** mag = nearest and min = linear and mip = linear */
  77469. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  77470. /** mag = nearest and min = linear and mip = none */
  77471. static readonly NEAREST_LINEAR: number;
  77472. /** mag = nearest and min = nearest and mip = none */
  77473. static readonly NEAREST_NEAREST: number;
  77474. /** mag = linear and min = nearest and mip = nearest */
  77475. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  77476. /** mag = linear and min = nearest and mip = linear */
  77477. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  77478. /** mag = linear and min = linear and mip = none */
  77479. static readonly LINEAR_LINEAR: number;
  77480. /** mag = linear and min = nearest and mip = none */
  77481. static readonly LINEAR_NEAREST: number;
  77482. /** Explicit coordinates mode */
  77483. static readonly EXPLICIT_MODE: number;
  77484. /** Spherical coordinates mode */
  77485. static readonly SPHERICAL_MODE: number;
  77486. /** Planar coordinates mode */
  77487. static readonly PLANAR_MODE: number;
  77488. /** Cubic coordinates mode */
  77489. static readonly CUBIC_MODE: number;
  77490. /** Projection coordinates mode */
  77491. static readonly PROJECTION_MODE: number;
  77492. /** Inverse Cubic coordinates mode */
  77493. static readonly SKYBOX_MODE: number;
  77494. /** Inverse Cubic coordinates mode */
  77495. static readonly INVCUBIC_MODE: number;
  77496. /** Equirectangular coordinates mode */
  77497. static readonly EQUIRECTANGULAR_MODE: number;
  77498. /** Equirectangular Fixed coordinates mode */
  77499. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  77500. /** Equirectangular Fixed Mirrored coordinates mode */
  77501. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  77502. /** Texture is not repeating outside of 0..1 UVs */
  77503. static readonly CLAMP_ADDRESSMODE: number;
  77504. /** Texture is repeating outside of 0..1 UVs */
  77505. static readonly WRAP_ADDRESSMODE: number;
  77506. /** Texture is repeating and mirrored */
  77507. static readonly MIRROR_ADDRESSMODE: number;
  77508. /**
  77509. * 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
  77510. */
  77511. static UseSerializedUrlIfAny: boolean;
  77512. /**
  77513. * Define the url of the texture.
  77514. */
  77515. url: Nullable<string>;
  77516. /**
  77517. * Define an offset on the texture to offset the u coordinates of the UVs
  77518. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77519. */
  77520. uOffset: number;
  77521. /**
  77522. * Define an offset on the texture to offset the v coordinates of the UVs
  77523. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  77524. */
  77525. vOffset: number;
  77526. /**
  77527. * Define an offset on the texture to scale the u coordinates of the UVs
  77528. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77529. */
  77530. uScale: number;
  77531. /**
  77532. * Define an offset on the texture to scale the v coordinates of the UVs
  77533. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  77534. */
  77535. vScale: number;
  77536. /**
  77537. * Define an offset on the texture to rotate around the u coordinates of the UVs
  77538. * @see http://doc.babylonjs.com/how_to/more_materials
  77539. */
  77540. uAng: number;
  77541. /**
  77542. * Define an offset on the texture to rotate around the v coordinates of the UVs
  77543. * @see http://doc.babylonjs.com/how_to/more_materials
  77544. */
  77545. vAng: number;
  77546. /**
  77547. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  77548. * @see http://doc.babylonjs.com/how_to/more_materials
  77549. */
  77550. wAng: number;
  77551. /**
  77552. * Defines the center of rotation (U)
  77553. */
  77554. uRotationCenter: number;
  77555. /**
  77556. * Defines the center of rotation (V)
  77557. */
  77558. vRotationCenter: number;
  77559. /**
  77560. * Defines the center of rotation (W)
  77561. */
  77562. wRotationCenter: number;
  77563. /**
  77564. * Are mip maps generated for this texture or not.
  77565. */
  77566. readonly noMipmap: boolean;
  77567. /**
  77568. * List of inspectable custom properties (used by the Inspector)
  77569. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  77570. */
  77571. inspectableCustomProperties: Nullable<IInspectable[]>;
  77572. private _noMipmap;
  77573. /** @hidden */
  77574. _invertY: boolean;
  77575. private _rowGenerationMatrix;
  77576. private _cachedTextureMatrix;
  77577. private _projectionModeMatrix;
  77578. private _t0;
  77579. private _t1;
  77580. private _t2;
  77581. private _cachedUOffset;
  77582. private _cachedVOffset;
  77583. private _cachedUScale;
  77584. private _cachedVScale;
  77585. private _cachedUAng;
  77586. private _cachedVAng;
  77587. private _cachedWAng;
  77588. private _cachedProjectionMatrixId;
  77589. private _cachedCoordinatesMode;
  77590. /** @hidden */
  77591. protected _initialSamplingMode: number;
  77592. /** @hidden */
  77593. _buffer: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>;
  77594. private _deleteBuffer;
  77595. protected _format: Nullable<number>;
  77596. private _delayedOnLoad;
  77597. private _delayedOnError;
  77598. /**
  77599. * Observable triggered once the texture has been loaded.
  77600. */
  77601. onLoadObservable: Observable<Texture>;
  77602. protected _isBlocking: boolean;
  77603. /**
  77604. * Is the texture preventing material to render while loading.
  77605. * If false, a default texture will be used instead of the loading one during the preparation step.
  77606. */
  77607. isBlocking: boolean;
  77608. /**
  77609. * Get the current sampling mode associated with the texture.
  77610. */
  77611. readonly samplingMode: number;
  77612. /**
  77613. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  77614. */
  77615. readonly invertY: boolean;
  77616. /**
  77617. * Instantiates a new texture.
  77618. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  77619. * @see http://doc.babylonjs.com/babylon101/materials#texture
  77620. * @param url define the url of the picture to load as a texture
  77621. * @param scene define the scene the texture will belong to
  77622. * @param noMipmap define if the texture will require mip maps or not
  77623. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77624. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77625. * @param onLoad define a callback triggered when the texture has been loaded
  77626. * @param onError define a callback triggered when an error occurred during the loading session
  77627. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77628. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77629. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77630. */
  77631. 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);
  77632. /**
  77633. * Update the url (and optional buffer) of this texture if url was null during construction.
  77634. * @param url the url of the texture
  77635. * @param buffer the buffer of the texture (defaults to null)
  77636. * @param onLoad callback called when the texture is loaded (defaults to null)
  77637. */
  77638. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | HTMLImageElement | Blob>, onLoad?: () => void): void;
  77639. /**
  77640. * Finish the loading sequence of a texture flagged as delayed load.
  77641. * @hidden
  77642. */
  77643. delayLoad(): void;
  77644. private _prepareRowForTextureGeneration;
  77645. /**
  77646. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  77647. * @returns the transform matrix of the texture.
  77648. */
  77649. getTextureMatrix(): Matrix;
  77650. /**
  77651. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  77652. * @returns The reflection texture transform
  77653. */
  77654. getReflectionTextureMatrix(): Matrix;
  77655. /**
  77656. * Clones the texture.
  77657. * @returns the cloned texture
  77658. */
  77659. clone(): Texture;
  77660. /**
  77661. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  77662. * @returns The JSON representation of the texture
  77663. */
  77664. serialize(): any;
  77665. /**
  77666. * Get the current class name of the texture useful for serialization or dynamic coding.
  77667. * @returns "Texture"
  77668. */
  77669. getClassName(): string;
  77670. /**
  77671. * Dispose the texture and release its associated resources.
  77672. */
  77673. dispose(): void;
  77674. /**
  77675. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  77676. * @param parsedTexture Define the JSON representation of the texture
  77677. * @param scene Define the scene the parsed texture should be instantiated in
  77678. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  77679. * @returns The parsed texture if successful
  77680. */
  77681. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  77682. /**
  77683. * Creates a texture from its base 64 representation.
  77684. * @param data Define the base64 payload without the data: prefix
  77685. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77686. * @param scene Define the scene the texture should belong to
  77687. * @param noMipmap Forces the texture to not create mip map information if true
  77688. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77689. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77690. * @param onLoad define a callback triggered when the texture has been loaded
  77691. * @param onError define a callback triggered when an error occurred during the loading session
  77692. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77693. * @returns the created texture
  77694. */
  77695. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  77696. /**
  77697. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  77698. * @param data Define the base64 payload without the data: prefix
  77699. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  77700. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  77701. * @param scene Define the scene the texture should belong to
  77702. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  77703. * @param noMipmap Forces the texture to not create mip map information if true
  77704. * @param invertY define if the texture needs to be inverted on the y axis during loading
  77705. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  77706. * @param onLoad define a callback triggered when the texture has been loaded
  77707. * @param onError define a callback triggered when an error occurred during the loading session
  77708. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  77709. * @returns the created texture
  77710. */
  77711. 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;
  77712. }
  77713. }
  77714. declare module BABYLON {
  77715. interface Engine {
  77716. /**
  77717. * Creates a raw texture
  77718. * @param data defines the data to store in the texture
  77719. * @param width defines the width of the texture
  77720. * @param height defines the height of the texture
  77721. * @param format defines the format of the data
  77722. * @param generateMipMaps defines if the engine should generate the mip levels
  77723. * @param invertY defines if data must be stored with Y axis inverted
  77724. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  77725. * @param compression defines the compression used (null by default)
  77726. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77727. * @returns the raw texture inside an InternalTexture
  77728. */
  77729. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  77730. /**
  77731. * Update a raw texture
  77732. * @param texture defines the texture to update
  77733. * @param data defines the data to store in the texture
  77734. * @param format defines the format of the data
  77735. * @param invertY defines if data must be stored with Y axis inverted
  77736. */
  77737. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77738. /**
  77739. * Update a raw texture
  77740. * @param texture defines the texture to update
  77741. * @param data defines the data to store in the texture
  77742. * @param format defines the format of the data
  77743. * @param invertY defines if data must be stored with Y axis inverted
  77744. * @param compression defines the compression used (null by default)
  77745. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77746. */
  77747. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  77748. /**
  77749. * Creates a new raw cube texture
  77750. * @param data defines the array of data to use to create each face
  77751. * @param size defines the size of the textures
  77752. * @param format defines the format of the data
  77753. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77754. * @param generateMipMaps defines if the engine should generate the mip levels
  77755. * @param invertY defines if data must be stored with Y axis inverted
  77756. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77757. * @param compression defines the compression used (null by default)
  77758. * @returns the cube texture as an InternalTexture
  77759. */
  77760. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  77761. /**
  77762. * Update a raw cube texture
  77763. * @param texture defines the texture to udpdate
  77764. * @param data defines the data to store
  77765. * @param format defines the data format
  77766. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77767. * @param invertY defines if data must be stored with Y axis inverted
  77768. */
  77769. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  77770. /**
  77771. * Update a raw cube texture
  77772. * @param texture defines the texture to udpdate
  77773. * @param data defines the data to store
  77774. * @param format defines the data format
  77775. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77776. * @param invertY defines if data must be stored with Y axis inverted
  77777. * @param compression defines the compression used (null by default)
  77778. */
  77779. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  77780. /**
  77781. * Update a raw cube texture
  77782. * @param texture defines the texture to udpdate
  77783. * @param data defines the data to store
  77784. * @param format defines the data format
  77785. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  77786. * @param invertY defines if data must be stored with Y axis inverted
  77787. * @param compression defines the compression used (null by default)
  77788. * @param level defines which level of the texture to update
  77789. */
  77790. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  77791. /**
  77792. * Creates a new raw cube texture from a specified url
  77793. * @param url defines the url where the data is located
  77794. * @param scene defines the current scene
  77795. * @param size defines the size of the textures
  77796. * @param format defines the format of the data
  77797. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77798. * @param noMipmap defines if the engine should avoid generating the mip levels
  77799. * @param callback defines a callback used to extract texture data from loaded data
  77800. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77801. * @param onLoad defines a callback called when texture is loaded
  77802. * @param onError defines a callback called if there is an error
  77803. * @returns the cube texture as an InternalTexture
  77804. */
  77805. createRawCubeTextureFromUrl(url: string, scene: Scene, size: number, format: number, type: number, noMipmap: boolean, callback: (ArrayBuffer: ArrayBuffer) => Nullable<ArrayBufferView[]>, mipmapGenerator: Nullable<((faces: ArrayBufferView[]) => ArrayBufferView[][])>, onLoad: Nullable<() => void>, onError: Nullable<(message?: string, exception?: any) => void>): InternalTexture;
  77806. /**
  77807. * Creates a new raw cube texture from a specified url
  77808. * @param url defines the url where the data is located
  77809. * @param scene defines the current scene
  77810. * @param size defines the size of the textures
  77811. * @param format defines the format of the data
  77812. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  77813. * @param noMipmap defines if the engine should avoid generating the mip levels
  77814. * @param callback defines a callback used to extract texture data from loaded data
  77815. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  77816. * @param onLoad defines a callback called when texture is loaded
  77817. * @param onError defines a callback called if there is an error
  77818. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77819. * @param invertY defines if data must be stored with Y axis inverted
  77820. * @returns the cube texture as an InternalTexture
  77821. */
  77822. 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;
  77823. /**
  77824. * Creates a new raw 3D texture
  77825. * @param data defines the data used to create the texture
  77826. * @param width defines the width of the texture
  77827. * @param height defines the height of the texture
  77828. * @param depth defines the depth of the texture
  77829. * @param format defines the format of the texture
  77830. * @param generateMipMaps defines if the engine must generate mip levels
  77831. * @param invertY defines if data must be stored with Y axis inverted
  77832. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  77833. * @param compression defines the compressed used (can be null)
  77834. * @param textureType defines the compressed used (can be null)
  77835. * @returns a new raw 3D texture (stored in an InternalTexture)
  77836. */
  77837. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  77838. /**
  77839. * Update a raw 3D texture
  77840. * @param texture defines the texture to update
  77841. * @param data defines the data to store
  77842. * @param format defines the data format
  77843. * @param invertY defines if data must be stored with Y axis inverted
  77844. */
  77845. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  77846. /**
  77847. * Update a raw 3D texture
  77848. * @param texture defines the texture to update
  77849. * @param data defines the data to store
  77850. * @param format defines the data format
  77851. * @param invertY defines if data must be stored with Y axis inverted
  77852. * @param compression defines the used compression (can be null)
  77853. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  77854. */
  77855. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  77856. }
  77857. }
  77858. declare module BABYLON {
  77859. /**
  77860. * Raw texture can help creating a texture directly from an array of data.
  77861. * This can be super useful if you either get the data from an uncompressed source or
  77862. * if you wish to create your texture pixel by pixel.
  77863. */
  77864. export class RawTexture extends Texture {
  77865. /**
  77866. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77867. */
  77868. format: number;
  77869. private _engine;
  77870. /**
  77871. * Instantiates a new RawTexture.
  77872. * Raw texture can help creating a texture directly from an array of data.
  77873. * This can be super useful if you either get the data from an uncompressed source or
  77874. * if you wish to create your texture pixel by pixel.
  77875. * @param data define the array of data to use to create the texture
  77876. * @param width define the width of the texture
  77877. * @param height define the height of the texture
  77878. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77879. * @param scene define the scene the texture belongs to
  77880. * @param generateMipMaps define whether mip maps should be generated or not
  77881. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77882. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77883. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77884. */
  77885. constructor(data: ArrayBufferView, width: number, height: number,
  77886. /**
  77887. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  77888. */
  77889. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  77890. /**
  77891. * Updates the texture underlying data.
  77892. * @param data Define the new data of the texture
  77893. */
  77894. update(data: ArrayBufferView): void;
  77895. /**
  77896. * Creates a luminance texture from some data.
  77897. * @param data Define the texture data
  77898. * @param width Define the width of the texture
  77899. * @param height Define the height of the texture
  77900. * @param scene Define the scene the texture belongs to
  77901. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77902. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77903. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77904. * @returns the luminance texture
  77905. */
  77906. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77907. /**
  77908. * Creates a luminance alpha texture from some data.
  77909. * @param data Define the texture data
  77910. * @param width Define the width of the texture
  77911. * @param height Define the height of the texture
  77912. * @param scene Define the scene the texture belongs to
  77913. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77914. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77915. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77916. * @returns the luminance alpha texture
  77917. */
  77918. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77919. /**
  77920. * Creates an alpha texture from some data.
  77921. * @param data Define the texture data
  77922. * @param width Define the width of the texture
  77923. * @param height Define the height of the texture
  77924. * @param scene Define the scene the texture belongs to
  77925. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77926. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77927. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77928. * @returns the alpha texture
  77929. */
  77930. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  77931. /**
  77932. * Creates a RGB texture from some data.
  77933. * @param data Define the texture data
  77934. * @param width Define the width of the texture
  77935. * @param height Define the height of the texture
  77936. * @param scene Define the scene the texture belongs to
  77937. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77938. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77939. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77940. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77941. * @returns the RGB alpha texture
  77942. */
  77943. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77944. /**
  77945. * Creates a RGBA texture from some data.
  77946. * @param data Define the texture data
  77947. * @param width Define the width of the texture
  77948. * @param height Define the height of the texture
  77949. * @param scene Define the scene the texture belongs to
  77950. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77951. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77952. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77953. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77954. * @returns the RGBA texture
  77955. */
  77956. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77957. /**
  77958. * Creates a R texture from some data.
  77959. * @param data Define the texture data
  77960. * @param width Define the width of the texture
  77961. * @param height Define the height of the texture
  77962. * @param scene Define the scene the texture belongs to
  77963. * @param generateMipMaps Define whether or not to create mip maps for the texture
  77964. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  77965. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  77966. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  77967. * @returns the R texture
  77968. */
  77969. static CreateRTexture(data: ArrayBufferView, width: number, height: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  77970. }
  77971. }
  77972. declare module BABYLON {
  77973. /**
  77974. * Defines a runtime animation
  77975. */
  77976. export class RuntimeAnimation {
  77977. private _events;
  77978. /**
  77979. * The current frame of the runtime animation
  77980. */
  77981. private _currentFrame;
  77982. /**
  77983. * The animation used by the runtime animation
  77984. */
  77985. private _animation;
  77986. /**
  77987. * The target of the runtime animation
  77988. */
  77989. private _target;
  77990. /**
  77991. * The initiating animatable
  77992. */
  77993. private _host;
  77994. /**
  77995. * The original value of the runtime animation
  77996. */
  77997. private _originalValue;
  77998. /**
  77999. * The original blend value of the runtime animation
  78000. */
  78001. private _originalBlendValue;
  78002. /**
  78003. * The offsets cache of the runtime animation
  78004. */
  78005. private _offsetsCache;
  78006. /**
  78007. * The high limits cache of the runtime animation
  78008. */
  78009. private _highLimitsCache;
  78010. /**
  78011. * Specifies if the runtime animation has been stopped
  78012. */
  78013. private _stopped;
  78014. /**
  78015. * The blending factor of the runtime animation
  78016. */
  78017. private _blendingFactor;
  78018. /**
  78019. * The BabylonJS scene
  78020. */
  78021. private _scene;
  78022. /**
  78023. * The current value of the runtime animation
  78024. */
  78025. private _currentValue;
  78026. /** @hidden */
  78027. _animationState: _IAnimationState;
  78028. /**
  78029. * The active target of the runtime animation
  78030. */
  78031. private _activeTargets;
  78032. private _currentActiveTarget;
  78033. private _directTarget;
  78034. /**
  78035. * The target path of the runtime animation
  78036. */
  78037. private _targetPath;
  78038. /**
  78039. * The weight of the runtime animation
  78040. */
  78041. private _weight;
  78042. /**
  78043. * The ratio offset of the runtime animation
  78044. */
  78045. private _ratioOffset;
  78046. /**
  78047. * The previous delay of the runtime animation
  78048. */
  78049. private _previousDelay;
  78050. /**
  78051. * The previous ratio of the runtime animation
  78052. */
  78053. private _previousRatio;
  78054. private _enableBlending;
  78055. private _keys;
  78056. private _minFrame;
  78057. private _maxFrame;
  78058. private _minValue;
  78059. private _maxValue;
  78060. private _targetIsArray;
  78061. /**
  78062. * Gets the current frame of the runtime animation
  78063. */
  78064. readonly currentFrame: number;
  78065. /**
  78066. * Gets the weight of the runtime animation
  78067. */
  78068. readonly weight: number;
  78069. /**
  78070. * Gets the current value of the runtime animation
  78071. */
  78072. readonly currentValue: any;
  78073. /**
  78074. * Gets the target path of the runtime animation
  78075. */
  78076. readonly targetPath: string;
  78077. /**
  78078. * Gets the actual target of the runtime animation
  78079. */
  78080. readonly target: any;
  78081. /** @hidden */
  78082. _onLoop: () => void;
  78083. /**
  78084. * Create a new RuntimeAnimation object
  78085. * @param target defines the target of the animation
  78086. * @param animation defines the source animation object
  78087. * @param scene defines the hosting scene
  78088. * @param host defines the initiating Animatable
  78089. */
  78090. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  78091. private _preparePath;
  78092. /**
  78093. * Gets the animation from the runtime animation
  78094. */
  78095. readonly animation: Animation;
  78096. /**
  78097. * Resets the runtime animation to the beginning
  78098. * @param restoreOriginal defines whether to restore the target property to the original value
  78099. */
  78100. reset(restoreOriginal?: boolean): void;
  78101. /**
  78102. * Specifies if the runtime animation is stopped
  78103. * @returns Boolean specifying if the runtime animation is stopped
  78104. */
  78105. isStopped(): boolean;
  78106. /**
  78107. * Disposes of the runtime animation
  78108. */
  78109. dispose(): void;
  78110. /**
  78111. * Apply the interpolated value to the target
  78112. * @param currentValue defines the value computed by the animation
  78113. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  78114. */
  78115. setValue(currentValue: any, weight: number): void;
  78116. private _getOriginalValues;
  78117. private _setValue;
  78118. /**
  78119. * Gets the loop pmode of the runtime animation
  78120. * @returns Loop Mode
  78121. */
  78122. private _getCorrectLoopMode;
  78123. /**
  78124. * Move the current animation to a given frame
  78125. * @param frame defines the frame to move to
  78126. */
  78127. goToFrame(frame: number): void;
  78128. /**
  78129. * @hidden Internal use only
  78130. */
  78131. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  78132. /**
  78133. * Execute the current animation
  78134. * @param delay defines the delay to add to the current frame
  78135. * @param from defines the lower bound of the animation range
  78136. * @param to defines the upper bound of the animation range
  78137. * @param loop defines if the current animation must loop
  78138. * @param speedRatio defines the current speed ratio
  78139. * @param weight defines the weight of the animation (default is -1 so no weight)
  78140. * @param onLoop optional callback called when animation loops
  78141. * @returns a boolean indicating if the animation is running
  78142. */
  78143. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  78144. }
  78145. }
  78146. declare module BABYLON {
  78147. /**
  78148. * Class used to store an actual running animation
  78149. */
  78150. export class Animatable {
  78151. /** defines the target object */
  78152. target: any;
  78153. /** defines the starting frame number (default is 0) */
  78154. fromFrame: number;
  78155. /** defines the ending frame number (default is 100) */
  78156. toFrame: number;
  78157. /** defines if the animation must loop (default is false) */
  78158. loopAnimation: boolean;
  78159. /** defines a callback to call when animation ends if it is not looping */
  78160. onAnimationEnd?: (() => void) | null | undefined;
  78161. /** defines a callback to call when animation loops */
  78162. onAnimationLoop?: (() => void) | null | undefined;
  78163. private _localDelayOffset;
  78164. private _pausedDelay;
  78165. private _runtimeAnimations;
  78166. private _paused;
  78167. private _scene;
  78168. private _speedRatio;
  78169. private _weight;
  78170. private _syncRoot;
  78171. /**
  78172. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  78173. * This will only apply for non looping animation (default is true)
  78174. */
  78175. disposeOnEnd: boolean;
  78176. /**
  78177. * Gets a boolean indicating if the animation has started
  78178. */
  78179. animationStarted: boolean;
  78180. /**
  78181. * Observer raised when the animation ends
  78182. */
  78183. onAnimationEndObservable: Observable<Animatable>;
  78184. /**
  78185. * Observer raised when the animation loops
  78186. */
  78187. onAnimationLoopObservable: Observable<Animatable>;
  78188. /**
  78189. * Gets the root Animatable used to synchronize and normalize animations
  78190. */
  78191. readonly syncRoot: Nullable<Animatable>;
  78192. /**
  78193. * Gets the current frame of the first RuntimeAnimation
  78194. * Used to synchronize Animatables
  78195. */
  78196. readonly masterFrame: number;
  78197. /**
  78198. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  78199. */
  78200. weight: number;
  78201. /**
  78202. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  78203. */
  78204. speedRatio: number;
  78205. /**
  78206. * Creates a new Animatable
  78207. * @param scene defines the hosting scene
  78208. * @param target defines the target object
  78209. * @param fromFrame defines the starting frame number (default is 0)
  78210. * @param toFrame defines the ending frame number (default is 100)
  78211. * @param loopAnimation defines if the animation must loop (default is false)
  78212. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  78213. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  78214. * @param animations defines a group of animation to add to the new Animatable
  78215. * @param onAnimationLoop defines a callback to call when animation loops
  78216. */
  78217. constructor(scene: Scene,
  78218. /** defines the target object */
  78219. target: any,
  78220. /** defines the starting frame number (default is 0) */
  78221. fromFrame?: number,
  78222. /** defines the ending frame number (default is 100) */
  78223. toFrame?: number,
  78224. /** defines if the animation must loop (default is false) */
  78225. loopAnimation?: boolean, speedRatio?: number,
  78226. /** defines a callback to call when animation ends if it is not looping */
  78227. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  78228. /** defines a callback to call when animation loops */
  78229. onAnimationLoop?: (() => void) | null | undefined);
  78230. /**
  78231. * Synchronize and normalize current Animatable with a source Animatable
  78232. * This is useful when using animation weights and when animations are not of the same length
  78233. * @param root defines the root Animatable to synchronize with
  78234. * @returns the current Animatable
  78235. */
  78236. syncWith(root: Animatable): Animatable;
  78237. /**
  78238. * Gets the list of runtime animations
  78239. * @returns an array of RuntimeAnimation
  78240. */
  78241. getAnimations(): RuntimeAnimation[];
  78242. /**
  78243. * Adds more animations to the current animatable
  78244. * @param target defines the target of the animations
  78245. * @param animations defines the new animations to add
  78246. */
  78247. appendAnimations(target: any, animations: Animation[]): void;
  78248. /**
  78249. * Gets the source animation for a specific property
  78250. * @param property defines the propertyu to look for
  78251. * @returns null or the source animation for the given property
  78252. */
  78253. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  78254. /**
  78255. * Gets the runtime animation for a specific property
  78256. * @param property defines the propertyu to look for
  78257. * @returns null or the runtime animation for the given property
  78258. */
  78259. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  78260. /**
  78261. * Resets the animatable to its original state
  78262. */
  78263. reset(): void;
  78264. /**
  78265. * Allows the animatable to blend with current running animations
  78266. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78267. * @param blendingSpeed defines the blending speed to use
  78268. */
  78269. enableBlending(blendingSpeed: number): void;
  78270. /**
  78271. * Disable animation blending
  78272. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78273. */
  78274. disableBlending(): void;
  78275. /**
  78276. * Jump directly to a given frame
  78277. * @param frame defines the frame to jump to
  78278. */
  78279. goToFrame(frame: number): void;
  78280. /**
  78281. * Pause the animation
  78282. */
  78283. pause(): void;
  78284. /**
  78285. * Restart the animation
  78286. */
  78287. restart(): void;
  78288. private _raiseOnAnimationEnd;
  78289. /**
  78290. * Stop and delete the current animation
  78291. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  78292. * @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)
  78293. */
  78294. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  78295. /**
  78296. * Wait asynchronously for the animation to end
  78297. * @returns a promise which will be fullfilled when the animation ends
  78298. */
  78299. waitAsync(): Promise<Animatable>;
  78300. /** @hidden */
  78301. _animate(delay: number): boolean;
  78302. }
  78303. interface Scene {
  78304. /** @hidden */
  78305. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  78306. /** @hidden */
  78307. _processLateAnimationBindingsForMatrices(holder: {
  78308. totalWeight: number;
  78309. animations: RuntimeAnimation[];
  78310. originalValue: Matrix;
  78311. }): any;
  78312. /** @hidden */
  78313. _processLateAnimationBindingsForQuaternions(holder: {
  78314. totalWeight: number;
  78315. animations: RuntimeAnimation[];
  78316. originalValue: Quaternion;
  78317. }, refQuaternion: Quaternion): Quaternion;
  78318. /** @hidden */
  78319. _processLateAnimationBindings(): void;
  78320. /**
  78321. * Will start the animation sequence of a given target
  78322. * @param target defines the target
  78323. * @param from defines from which frame should animation start
  78324. * @param to defines until which frame should animation run.
  78325. * @param weight defines the weight to apply to the animation (1.0 by default)
  78326. * @param loop defines if the animation loops
  78327. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78328. * @param onAnimationEnd defines the function to be executed when the animation ends
  78329. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78330. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78331. * @param onAnimationLoop defines the callback to call when an animation loops
  78332. * @returns the animatable object created for this animation
  78333. */
  78334. beginWeightedAnimation(target: any, from: number, to: number, weight: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78335. /**
  78336. * Will start the animation sequence of a given target
  78337. * @param target defines the target
  78338. * @param from defines from which frame should animation start
  78339. * @param to defines until which frame should animation run.
  78340. * @param loop defines if the animation loops
  78341. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78342. * @param onAnimationEnd defines the function to be executed when the animation ends
  78343. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78344. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78345. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  78346. * @param onAnimationLoop defines the callback to call when an animation loops
  78347. * @returns the animatable object created for this animation
  78348. */
  78349. beginAnimation(target: any, from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, animatable?: Animatable, stopCurrent?: boolean, targetMask?: (target: any) => boolean, onAnimationLoop?: () => void): Animatable;
  78350. /**
  78351. * Will start the animation sequence of a given target and its hierarchy
  78352. * @param target defines the target
  78353. * @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.
  78354. * @param from defines from which frame should animation start
  78355. * @param to defines until which frame should animation run.
  78356. * @param loop defines if the animation loops
  78357. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  78358. * @param onAnimationEnd defines the function to be executed when the animation ends
  78359. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  78360. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  78361. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  78362. * @param onAnimationLoop defines the callback to call when an animation loops
  78363. * @returns the list of created animatables
  78364. */
  78365. 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[];
  78366. /**
  78367. * Begin a new animation on a given node
  78368. * @param target defines the target where the animation will take place
  78369. * @param animations defines the list of animations to start
  78370. * @param from defines the initial value
  78371. * @param to defines the final value
  78372. * @param loop defines if you want animation to loop (off by default)
  78373. * @param speedRatio defines the speed ratio to apply to all animations
  78374. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78375. * @param onAnimationLoop defines the callback to call when an animation loops
  78376. * @returns the list of created animatables
  78377. */
  78378. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable;
  78379. /**
  78380. * Begin a new animation on a given node and its hierarchy
  78381. * @param target defines the root node where the animation will take place
  78382. * @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.
  78383. * @param animations defines the list of animations to start
  78384. * @param from defines the initial value
  78385. * @param to defines the final value
  78386. * @param loop defines if you want animation to loop (off by default)
  78387. * @param speedRatio defines the speed ratio to apply to all animations
  78388. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  78389. * @param onAnimationLoop defines the callback to call when an animation loops
  78390. * @returns the list of animatables created for all nodes
  78391. */
  78392. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void): Animatable[];
  78393. /**
  78394. * Gets the animatable associated with a specific target
  78395. * @param target defines the target of the animatable
  78396. * @returns the required animatable if found
  78397. */
  78398. getAnimatableByTarget(target: any): Nullable<Animatable>;
  78399. /**
  78400. * Gets all animatables associated with a given target
  78401. * @param target defines the target to look animatables for
  78402. * @returns an array of Animatables
  78403. */
  78404. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  78405. /**
  78406. * Will stop the animation of the given target
  78407. * @param target - the target
  78408. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  78409. * @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)
  78410. */
  78411. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  78412. /**
  78413. * Stops and removes all animations that have been applied to the scene
  78414. */
  78415. stopAllAnimations(): void;
  78416. }
  78417. interface Bone {
  78418. /**
  78419. * Copy an animation range from another bone
  78420. * @param source defines the source bone
  78421. * @param rangeName defines the range name to copy
  78422. * @param frameOffset defines the frame offset
  78423. * @param rescaleAsRequired defines if rescaling must be applied if required
  78424. * @param skelDimensionsRatio defines the scaling ratio
  78425. * @returns true if operation was successful
  78426. */
  78427. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  78428. }
  78429. }
  78430. declare module BABYLON {
  78431. /**
  78432. * Class used to handle skinning animations
  78433. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  78434. */
  78435. export class Skeleton implements IAnimatable {
  78436. /** defines the skeleton name */
  78437. name: string;
  78438. /** defines the skeleton Id */
  78439. id: string;
  78440. /**
  78441. * Defines the list of child bones
  78442. */
  78443. bones: Bone[];
  78444. /**
  78445. * Defines an estimate of the dimension of the skeleton at rest
  78446. */
  78447. dimensionsAtRest: Vector3;
  78448. /**
  78449. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  78450. */
  78451. needInitialSkinMatrix: boolean;
  78452. /**
  78453. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  78454. */
  78455. overrideMesh: Nullable<AbstractMesh>;
  78456. /**
  78457. * Gets the list of animations attached to this skeleton
  78458. */
  78459. animations: Array<Animation>;
  78460. private _scene;
  78461. private _isDirty;
  78462. private _transformMatrices;
  78463. private _transformMatrixTexture;
  78464. private _meshesWithPoseMatrix;
  78465. private _animatables;
  78466. private _identity;
  78467. private _synchronizedWithMesh;
  78468. private _ranges;
  78469. private _lastAbsoluteTransformsUpdateId;
  78470. private _canUseTextureForBones;
  78471. private _uniqueId;
  78472. /** @hidden */
  78473. _numBonesWithLinkedTransformNode: number;
  78474. /**
  78475. * Specifies if the skeleton should be serialized
  78476. */
  78477. doNotSerialize: boolean;
  78478. private _useTextureToStoreBoneMatrices;
  78479. /**
  78480. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  78481. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  78482. */
  78483. useTextureToStoreBoneMatrices: boolean;
  78484. private _animationPropertiesOverride;
  78485. /**
  78486. * Gets or sets the animation properties override
  78487. */
  78488. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78489. /**
  78490. * List of inspectable custom properties (used by the Inspector)
  78491. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  78492. */
  78493. inspectableCustomProperties: IInspectable[];
  78494. /**
  78495. * An observable triggered before computing the skeleton's matrices
  78496. */
  78497. onBeforeComputeObservable: Observable<Skeleton>;
  78498. /**
  78499. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  78500. */
  78501. readonly isUsingTextureForMatrices: boolean;
  78502. /**
  78503. * Gets the unique ID of this skeleton
  78504. */
  78505. readonly uniqueId: number;
  78506. /**
  78507. * Creates a new skeleton
  78508. * @param name defines the skeleton name
  78509. * @param id defines the skeleton Id
  78510. * @param scene defines the hosting scene
  78511. */
  78512. constructor(
  78513. /** defines the skeleton name */
  78514. name: string,
  78515. /** defines the skeleton Id */
  78516. id: string, scene: Scene);
  78517. /**
  78518. * Gets the current object class name.
  78519. * @return the class name
  78520. */
  78521. getClassName(): string;
  78522. /**
  78523. * Returns an array containing the root bones
  78524. * @returns an array containing the root bones
  78525. */
  78526. getChildren(): Array<Bone>;
  78527. /**
  78528. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  78529. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  78530. * @returns a Float32Array containing matrices data
  78531. */
  78532. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  78533. /**
  78534. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  78535. * @returns a raw texture containing the data
  78536. */
  78537. getTransformMatrixTexture(): Nullable<RawTexture>;
  78538. /**
  78539. * Gets the current hosting scene
  78540. * @returns a scene object
  78541. */
  78542. getScene(): Scene;
  78543. /**
  78544. * Gets a string representing the current skeleton data
  78545. * @param fullDetails defines a boolean indicating if we want a verbose version
  78546. * @returns a string representing the current skeleton data
  78547. */
  78548. toString(fullDetails?: boolean): string;
  78549. /**
  78550. * Get bone's index searching by name
  78551. * @param name defines bone's name to search for
  78552. * @return the indice of the bone. Returns -1 if not found
  78553. */
  78554. getBoneIndexByName(name: string): number;
  78555. /**
  78556. * Creater a new animation range
  78557. * @param name defines the name of the range
  78558. * @param from defines the start key
  78559. * @param to defines the end key
  78560. */
  78561. createAnimationRange(name: string, from: number, to: number): void;
  78562. /**
  78563. * Delete a specific animation range
  78564. * @param name defines the name of the range
  78565. * @param deleteFrames defines if frames must be removed as well
  78566. */
  78567. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  78568. /**
  78569. * Gets a specific animation range
  78570. * @param name defines the name of the range to look for
  78571. * @returns the requested animation range or null if not found
  78572. */
  78573. getAnimationRange(name: string): Nullable<AnimationRange>;
  78574. /**
  78575. * Gets the list of all animation ranges defined on this skeleton
  78576. * @returns an array
  78577. */
  78578. getAnimationRanges(): Nullable<AnimationRange>[];
  78579. /**
  78580. * Copy animation range from a source skeleton.
  78581. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  78582. * @param source defines the source skeleton
  78583. * @param name defines the name of the range to copy
  78584. * @param rescaleAsRequired defines if rescaling must be applied if required
  78585. * @returns true if operation was successful
  78586. */
  78587. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  78588. /**
  78589. * Forces the skeleton to go to rest pose
  78590. */
  78591. returnToRest(): void;
  78592. private _getHighestAnimationFrame;
  78593. /**
  78594. * Begin a specific animation range
  78595. * @param name defines the name of the range to start
  78596. * @param loop defines if looping must be turned on (false by default)
  78597. * @param speedRatio defines the speed ratio to apply (1 by default)
  78598. * @param onAnimationEnd defines a callback which will be called when animation will end
  78599. * @returns a new animatable
  78600. */
  78601. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  78602. /** @hidden */
  78603. _markAsDirty(): void;
  78604. /** @hidden */
  78605. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78606. /** @hidden */
  78607. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  78608. private _computeTransformMatrices;
  78609. /**
  78610. * Build all resources required to render a skeleton
  78611. */
  78612. prepare(): void;
  78613. /**
  78614. * Gets the list of animatables currently running for this skeleton
  78615. * @returns an array of animatables
  78616. */
  78617. getAnimatables(): IAnimatable[];
  78618. /**
  78619. * Clone the current skeleton
  78620. * @param name defines the name of the new skeleton
  78621. * @param id defines the id of the new skeleton
  78622. * @returns the new skeleton
  78623. */
  78624. clone(name: string, id: string): Skeleton;
  78625. /**
  78626. * Enable animation blending for this skeleton
  78627. * @param blendingSpeed defines the blending speed to apply
  78628. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  78629. */
  78630. enableBlending(blendingSpeed?: number): void;
  78631. /**
  78632. * Releases all resources associated with the current skeleton
  78633. */
  78634. dispose(): void;
  78635. /**
  78636. * Serialize the skeleton in a JSON object
  78637. * @returns a JSON object
  78638. */
  78639. serialize(): any;
  78640. /**
  78641. * Creates a new skeleton from serialized data
  78642. * @param parsedSkeleton defines the serialized data
  78643. * @param scene defines the hosting scene
  78644. * @returns a new skeleton
  78645. */
  78646. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  78647. /**
  78648. * Compute all node absolute transforms
  78649. * @param forceUpdate defines if computation must be done even if cache is up to date
  78650. */
  78651. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  78652. /**
  78653. * Gets the root pose matrix
  78654. * @returns a matrix
  78655. */
  78656. getPoseMatrix(): Nullable<Matrix>;
  78657. /**
  78658. * Sorts bones per internal index
  78659. */
  78660. sortBones(): void;
  78661. private _sortBones;
  78662. }
  78663. }
  78664. declare module BABYLON {
  78665. /**
  78666. * Defines a target to use with MorphTargetManager
  78667. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78668. */
  78669. export class MorphTarget implements IAnimatable {
  78670. /** defines the name of the target */
  78671. name: string;
  78672. /**
  78673. * Gets or sets the list of animations
  78674. */
  78675. animations: Animation[];
  78676. private _scene;
  78677. private _positions;
  78678. private _normals;
  78679. private _tangents;
  78680. private _influence;
  78681. /**
  78682. * Observable raised when the influence changes
  78683. */
  78684. onInfluenceChanged: Observable<boolean>;
  78685. /** @hidden */
  78686. _onDataLayoutChanged: Observable<void>;
  78687. /**
  78688. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  78689. */
  78690. influence: number;
  78691. /**
  78692. * Gets or sets the id of the morph Target
  78693. */
  78694. id: string;
  78695. private _animationPropertiesOverride;
  78696. /**
  78697. * Gets or sets the animation properties override
  78698. */
  78699. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  78700. /**
  78701. * Creates a new MorphTarget
  78702. * @param name defines the name of the target
  78703. * @param influence defines the influence to use
  78704. * @param scene defines the scene the morphtarget belongs to
  78705. */
  78706. constructor(
  78707. /** defines the name of the target */
  78708. name: string, influence?: number, scene?: Nullable<Scene>);
  78709. /**
  78710. * Gets a boolean defining if the target contains position data
  78711. */
  78712. readonly hasPositions: boolean;
  78713. /**
  78714. * Gets a boolean defining if the target contains normal data
  78715. */
  78716. readonly hasNormals: boolean;
  78717. /**
  78718. * Gets a boolean defining if the target contains tangent data
  78719. */
  78720. readonly hasTangents: boolean;
  78721. /**
  78722. * Affects position data to this target
  78723. * @param data defines the position data to use
  78724. */
  78725. setPositions(data: Nullable<FloatArray>): void;
  78726. /**
  78727. * Gets the position data stored in this target
  78728. * @returns a FloatArray containing the position data (or null if not present)
  78729. */
  78730. getPositions(): Nullable<FloatArray>;
  78731. /**
  78732. * Affects normal data to this target
  78733. * @param data defines the normal data to use
  78734. */
  78735. setNormals(data: Nullable<FloatArray>): void;
  78736. /**
  78737. * Gets the normal data stored in this target
  78738. * @returns a FloatArray containing the normal data (or null if not present)
  78739. */
  78740. getNormals(): Nullable<FloatArray>;
  78741. /**
  78742. * Affects tangent data to this target
  78743. * @param data defines the tangent data to use
  78744. */
  78745. setTangents(data: Nullable<FloatArray>): void;
  78746. /**
  78747. * Gets the tangent data stored in this target
  78748. * @returns a FloatArray containing the tangent data (or null if not present)
  78749. */
  78750. getTangents(): Nullable<FloatArray>;
  78751. /**
  78752. * Serializes the current target into a Serialization object
  78753. * @returns the serialized object
  78754. */
  78755. serialize(): any;
  78756. /**
  78757. * Returns the string "MorphTarget"
  78758. * @returns "MorphTarget"
  78759. */
  78760. getClassName(): string;
  78761. /**
  78762. * Creates a new target from serialized data
  78763. * @param serializationObject defines the serialized data to use
  78764. * @returns a new MorphTarget
  78765. */
  78766. static Parse(serializationObject: any): MorphTarget;
  78767. /**
  78768. * Creates a MorphTarget from mesh data
  78769. * @param mesh defines the source mesh
  78770. * @param name defines the name to use for the new target
  78771. * @param influence defines the influence to attach to the target
  78772. * @returns a new MorphTarget
  78773. */
  78774. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  78775. }
  78776. }
  78777. declare module BABYLON {
  78778. /**
  78779. * This class is used to deform meshes using morphing between different targets
  78780. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  78781. */
  78782. export class MorphTargetManager {
  78783. private _targets;
  78784. private _targetInfluenceChangedObservers;
  78785. private _targetDataLayoutChangedObservers;
  78786. private _activeTargets;
  78787. private _scene;
  78788. private _influences;
  78789. private _supportsNormals;
  78790. private _supportsTangents;
  78791. private _vertexCount;
  78792. private _uniqueId;
  78793. private _tempInfluences;
  78794. /**
  78795. * Creates a new MorphTargetManager
  78796. * @param scene defines the current scene
  78797. */
  78798. constructor(scene?: Nullable<Scene>);
  78799. /**
  78800. * Gets the unique ID of this manager
  78801. */
  78802. readonly uniqueId: number;
  78803. /**
  78804. * Gets the number of vertices handled by this manager
  78805. */
  78806. readonly vertexCount: number;
  78807. /**
  78808. * Gets a boolean indicating if this manager supports morphing of normals
  78809. */
  78810. readonly supportsNormals: boolean;
  78811. /**
  78812. * Gets a boolean indicating if this manager supports morphing of tangents
  78813. */
  78814. readonly supportsTangents: boolean;
  78815. /**
  78816. * Gets the number of targets stored in this manager
  78817. */
  78818. readonly numTargets: number;
  78819. /**
  78820. * Gets the number of influencers (ie. the number of targets with influences > 0)
  78821. */
  78822. readonly numInfluencers: number;
  78823. /**
  78824. * Gets the list of influences (one per target)
  78825. */
  78826. readonly influences: Float32Array;
  78827. /**
  78828. * Gets the active target at specified index. An active target is a target with an influence > 0
  78829. * @param index defines the index to check
  78830. * @returns the requested target
  78831. */
  78832. getActiveTarget(index: number): MorphTarget;
  78833. /**
  78834. * Gets the target at specified index
  78835. * @param index defines the index to check
  78836. * @returns the requested target
  78837. */
  78838. getTarget(index: number): MorphTarget;
  78839. /**
  78840. * Add a new target to this manager
  78841. * @param target defines the target to add
  78842. */
  78843. addTarget(target: MorphTarget): void;
  78844. /**
  78845. * Removes a target from the manager
  78846. * @param target defines the target to remove
  78847. */
  78848. removeTarget(target: MorphTarget): void;
  78849. /**
  78850. * Serializes the current manager into a Serialization object
  78851. * @returns the serialized object
  78852. */
  78853. serialize(): any;
  78854. private _syncActiveTargets;
  78855. /**
  78856. * Syncrhonize the targets with all the meshes using this morph target manager
  78857. */
  78858. synchronize(): void;
  78859. /**
  78860. * Creates a new MorphTargetManager from serialized data
  78861. * @param serializationObject defines the serialized data
  78862. * @param scene defines the hosting scene
  78863. * @returns the new MorphTargetManager
  78864. */
  78865. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  78866. }
  78867. }
  78868. declare module BABYLON {
  78869. /**
  78870. * Mesh representing the gorund
  78871. */
  78872. export class GroundMesh extends Mesh {
  78873. /** If octree should be generated */
  78874. generateOctree: boolean;
  78875. private _heightQuads;
  78876. /** @hidden */
  78877. _subdivisionsX: number;
  78878. /** @hidden */
  78879. _subdivisionsY: number;
  78880. /** @hidden */
  78881. _width: number;
  78882. /** @hidden */
  78883. _height: number;
  78884. /** @hidden */
  78885. _minX: number;
  78886. /** @hidden */
  78887. _maxX: number;
  78888. /** @hidden */
  78889. _minZ: number;
  78890. /** @hidden */
  78891. _maxZ: number;
  78892. constructor(name: string, scene: Scene);
  78893. /**
  78894. * "GroundMesh"
  78895. * @returns "GroundMesh"
  78896. */
  78897. getClassName(): string;
  78898. /**
  78899. * The minimum of x and y subdivisions
  78900. */
  78901. readonly subdivisions: number;
  78902. /**
  78903. * X subdivisions
  78904. */
  78905. readonly subdivisionsX: number;
  78906. /**
  78907. * Y subdivisions
  78908. */
  78909. readonly subdivisionsY: number;
  78910. /**
  78911. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  78912. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  78913. * @param chunksCount the number of subdivisions for x and y
  78914. * @param octreeBlocksSize (Default: 32)
  78915. */
  78916. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  78917. /**
  78918. * Returns a height (y) value in the Worl system :
  78919. * the ground altitude at the coordinates (x, z) expressed in the World system.
  78920. * @param x x coordinate
  78921. * @param z z coordinate
  78922. * @returns the ground y position if (x, z) are outside the ground surface.
  78923. */
  78924. getHeightAtCoordinates(x: number, z: number): number;
  78925. /**
  78926. * Returns a normalized vector (Vector3) orthogonal to the ground
  78927. * at the ground coordinates (x, z) expressed in the World system.
  78928. * @param x x coordinate
  78929. * @param z z coordinate
  78930. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  78931. */
  78932. getNormalAtCoordinates(x: number, z: number): Vector3;
  78933. /**
  78934. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  78935. * at the ground coordinates (x, z) expressed in the World system.
  78936. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  78937. * @param x x coordinate
  78938. * @param z z coordinate
  78939. * @param ref vector to store the result
  78940. * @returns the GroundMesh.
  78941. */
  78942. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  78943. /**
  78944. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  78945. * if the ground has been updated.
  78946. * This can be used in the render loop.
  78947. * @returns the GroundMesh.
  78948. */
  78949. updateCoordinateHeights(): GroundMesh;
  78950. private _getFacetAt;
  78951. private _initHeightQuads;
  78952. private _computeHeightQuads;
  78953. /**
  78954. * Serializes this ground mesh
  78955. * @param serializationObject object to write serialization to
  78956. */
  78957. serialize(serializationObject: any): void;
  78958. /**
  78959. * Parses a serialized ground mesh
  78960. * @param parsedMesh the serialized mesh
  78961. * @param scene the scene to create the ground mesh in
  78962. * @returns the created ground mesh
  78963. */
  78964. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  78965. }
  78966. }
  78967. declare module BABYLON {
  78968. /**
  78969. * Interface for Physics-Joint data
  78970. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  78971. */
  78972. export interface PhysicsJointData {
  78973. /**
  78974. * The main pivot of the joint
  78975. */
  78976. mainPivot?: Vector3;
  78977. /**
  78978. * The connected pivot of the joint
  78979. */
  78980. connectedPivot?: Vector3;
  78981. /**
  78982. * The main axis of the joint
  78983. */
  78984. mainAxis?: Vector3;
  78985. /**
  78986. * The connected axis of the joint
  78987. */
  78988. connectedAxis?: Vector3;
  78989. /**
  78990. * The collision of the joint
  78991. */
  78992. collision?: boolean;
  78993. /**
  78994. * Native Oimo/Cannon/Energy data
  78995. */
  78996. nativeParams?: any;
  78997. }
  78998. /**
  78999. * This is a holder class for the physics joint created by the physics plugin
  79000. * It holds a set of functions to control the underlying joint
  79001. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79002. */
  79003. export class PhysicsJoint {
  79004. /**
  79005. * The type of the physics joint
  79006. */
  79007. type: number;
  79008. /**
  79009. * The data for the physics joint
  79010. */
  79011. jointData: PhysicsJointData;
  79012. private _physicsJoint;
  79013. protected _physicsPlugin: IPhysicsEnginePlugin;
  79014. /**
  79015. * Initializes the physics joint
  79016. * @param type The type of the physics joint
  79017. * @param jointData The data for the physics joint
  79018. */
  79019. constructor(
  79020. /**
  79021. * The type of the physics joint
  79022. */
  79023. type: number,
  79024. /**
  79025. * The data for the physics joint
  79026. */
  79027. jointData: PhysicsJointData);
  79028. /**
  79029. * Gets the physics joint
  79030. */
  79031. /**
  79032. * Sets the physics joint
  79033. */
  79034. physicsJoint: any;
  79035. /**
  79036. * Sets the physics plugin
  79037. */
  79038. physicsPlugin: IPhysicsEnginePlugin;
  79039. /**
  79040. * Execute a function that is physics-plugin specific.
  79041. * @param {Function} func the function that will be executed.
  79042. * It accepts two parameters: the physics world and the physics joint
  79043. */
  79044. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  79045. /**
  79046. * Distance-Joint type
  79047. */
  79048. static DistanceJoint: number;
  79049. /**
  79050. * Hinge-Joint type
  79051. */
  79052. static HingeJoint: number;
  79053. /**
  79054. * Ball-and-Socket joint type
  79055. */
  79056. static BallAndSocketJoint: number;
  79057. /**
  79058. * Wheel-Joint type
  79059. */
  79060. static WheelJoint: number;
  79061. /**
  79062. * Slider-Joint type
  79063. */
  79064. static SliderJoint: number;
  79065. /**
  79066. * Prismatic-Joint type
  79067. */
  79068. static PrismaticJoint: number;
  79069. /**
  79070. * Universal-Joint type
  79071. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  79072. */
  79073. static UniversalJoint: number;
  79074. /**
  79075. * Hinge-Joint 2 type
  79076. */
  79077. static Hinge2Joint: number;
  79078. /**
  79079. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  79080. */
  79081. static PointToPointJoint: number;
  79082. /**
  79083. * Spring-Joint type
  79084. */
  79085. static SpringJoint: number;
  79086. /**
  79087. * Lock-Joint type
  79088. */
  79089. static LockJoint: number;
  79090. }
  79091. /**
  79092. * A class representing a physics distance joint
  79093. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79094. */
  79095. export class DistanceJoint extends PhysicsJoint {
  79096. /**
  79097. *
  79098. * @param jointData The data for the Distance-Joint
  79099. */
  79100. constructor(jointData: DistanceJointData);
  79101. /**
  79102. * Update the predefined distance.
  79103. * @param maxDistance The maximum preferred distance
  79104. * @param minDistance The minimum preferred distance
  79105. */
  79106. updateDistance(maxDistance: number, minDistance?: number): void;
  79107. }
  79108. /**
  79109. * Represents a Motor-Enabled Joint
  79110. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79111. */
  79112. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  79113. /**
  79114. * Initializes the Motor-Enabled Joint
  79115. * @param type The type of the joint
  79116. * @param jointData The physica joint data for the joint
  79117. */
  79118. constructor(type: number, jointData: PhysicsJointData);
  79119. /**
  79120. * Set the motor values.
  79121. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79122. * @param force the force to apply
  79123. * @param maxForce max force for this motor.
  79124. */
  79125. setMotor(force?: number, maxForce?: number): void;
  79126. /**
  79127. * Set the motor's limits.
  79128. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79129. * @param upperLimit The upper limit of the motor
  79130. * @param lowerLimit The lower limit of the motor
  79131. */
  79132. setLimit(upperLimit: number, lowerLimit?: number): void;
  79133. }
  79134. /**
  79135. * This class represents a single physics Hinge-Joint
  79136. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79137. */
  79138. export class HingeJoint extends MotorEnabledJoint {
  79139. /**
  79140. * Initializes the Hinge-Joint
  79141. * @param jointData The joint data for the Hinge-Joint
  79142. */
  79143. constructor(jointData: PhysicsJointData);
  79144. /**
  79145. * Set the motor values.
  79146. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79147. * @param {number} force the force to apply
  79148. * @param {number} maxForce max force for this motor.
  79149. */
  79150. setMotor(force?: number, maxForce?: number): void;
  79151. /**
  79152. * Set the motor's limits.
  79153. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79154. * @param upperLimit The upper limit of the motor
  79155. * @param lowerLimit The lower limit of the motor
  79156. */
  79157. setLimit(upperLimit: number, lowerLimit?: number): void;
  79158. }
  79159. /**
  79160. * This class represents a dual hinge physics joint (same as wheel joint)
  79161. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79162. */
  79163. export class Hinge2Joint extends MotorEnabledJoint {
  79164. /**
  79165. * Initializes the Hinge2-Joint
  79166. * @param jointData The joint data for the Hinge2-Joint
  79167. */
  79168. constructor(jointData: PhysicsJointData);
  79169. /**
  79170. * Set the motor values.
  79171. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79172. * @param {number} targetSpeed the speed the motor is to reach
  79173. * @param {number} maxForce max force for this motor.
  79174. * @param {motorIndex} the motor's index, 0 or 1.
  79175. */
  79176. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  79177. /**
  79178. * Set the motor limits.
  79179. * Attention, this function is plugin specific. Engines won't react 100% the same.
  79180. * @param {number} upperLimit the upper limit
  79181. * @param {number} lowerLimit lower limit
  79182. * @param {motorIndex} the motor's index, 0 or 1.
  79183. */
  79184. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79185. }
  79186. /**
  79187. * Interface for a motor enabled joint
  79188. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79189. */
  79190. export interface IMotorEnabledJoint {
  79191. /**
  79192. * Physics joint
  79193. */
  79194. physicsJoint: any;
  79195. /**
  79196. * Sets the motor of the motor-enabled joint
  79197. * @param force The force of the motor
  79198. * @param maxForce The maximum force of the motor
  79199. * @param motorIndex The index of the motor
  79200. */
  79201. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  79202. /**
  79203. * Sets the limit of the motor
  79204. * @param upperLimit The upper limit of the motor
  79205. * @param lowerLimit The lower limit of the motor
  79206. * @param motorIndex The index of the motor
  79207. */
  79208. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79209. }
  79210. /**
  79211. * Joint data for a Distance-Joint
  79212. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79213. */
  79214. export interface DistanceJointData extends PhysicsJointData {
  79215. /**
  79216. * Max distance the 2 joint objects can be apart
  79217. */
  79218. maxDistance: number;
  79219. }
  79220. /**
  79221. * Joint data from a spring joint
  79222. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79223. */
  79224. export interface SpringJointData extends PhysicsJointData {
  79225. /**
  79226. * Length of the spring
  79227. */
  79228. length: number;
  79229. /**
  79230. * Stiffness of the spring
  79231. */
  79232. stiffness: number;
  79233. /**
  79234. * Damping of the spring
  79235. */
  79236. damping: number;
  79237. /** this callback will be called when applying the force to the impostors. */
  79238. forceApplicationCallback: () => void;
  79239. }
  79240. }
  79241. declare module BABYLON {
  79242. /**
  79243. * Holds the data for the raycast result
  79244. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79245. */
  79246. export class PhysicsRaycastResult {
  79247. private _hasHit;
  79248. private _hitDistance;
  79249. private _hitNormalWorld;
  79250. private _hitPointWorld;
  79251. private _rayFromWorld;
  79252. private _rayToWorld;
  79253. /**
  79254. * Gets if there was a hit
  79255. */
  79256. readonly hasHit: boolean;
  79257. /**
  79258. * Gets the distance from the hit
  79259. */
  79260. readonly hitDistance: number;
  79261. /**
  79262. * Gets the hit normal/direction in the world
  79263. */
  79264. readonly hitNormalWorld: Vector3;
  79265. /**
  79266. * Gets the hit point in the world
  79267. */
  79268. readonly hitPointWorld: Vector3;
  79269. /**
  79270. * Gets the ray "start point" of the ray in the world
  79271. */
  79272. readonly rayFromWorld: Vector3;
  79273. /**
  79274. * Gets the ray "end point" of the ray in the world
  79275. */
  79276. readonly rayToWorld: Vector3;
  79277. /**
  79278. * Sets the hit data (normal & point in world space)
  79279. * @param hitNormalWorld defines the normal in world space
  79280. * @param hitPointWorld defines the point in world space
  79281. */
  79282. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  79283. /**
  79284. * Sets the distance from the start point to the hit point
  79285. * @param distance
  79286. */
  79287. setHitDistance(distance: number): void;
  79288. /**
  79289. * Calculates the distance manually
  79290. */
  79291. calculateHitDistance(): void;
  79292. /**
  79293. * Resets all the values to default
  79294. * @param from The from point on world space
  79295. * @param to The to point on world space
  79296. */
  79297. reset(from?: Vector3, to?: Vector3): void;
  79298. }
  79299. /**
  79300. * Interface for the size containing width and height
  79301. */
  79302. interface IXYZ {
  79303. /**
  79304. * X
  79305. */
  79306. x: number;
  79307. /**
  79308. * Y
  79309. */
  79310. y: number;
  79311. /**
  79312. * Z
  79313. */
  79314. z: number;
  79315. }
  79316. }
  79317. declare module BABYLON {
  79318. /**
  79319. * Interface used to describe a physics joint
  79320. */
  79321. export interface PhysicsImpostorJoint {
  79322. /** Defines the main impostor to which the joint is linked */
  79323. mainImpostor: PhysicsImpostor;
  79324. /** Defines the impostor that is connected to the main impostor using this joint */
  79325. connectedImpostor: PhysicsImpostor;
  79326. /** Defines the joint itself */
  79327. joint: PhysicsJoint;
  79328. }
  79329. /** @hidden */
  79330. export interface IPhysicsEnginePlugin {
  79331. world: any;
  79332. name: string;
  79333. setGravity(gravity: Vector3): void;
  79334. setTimeStep(timeStep: number): void;
  79335. getTimeStep(): number;
  79336. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  79337. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79338. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  79339. generatePhysicsBody(impostor: PhysicsImpostor): void;
  79340. removePhysicsBody(impostor: PhysicsImpostor): void;
  79341. generateJoint(joint: PhysicsImpostorJoint): void;
  79342. removeJoint(joint: PhysicsImpostorJoint): void;
  79343. isSupported(): boolean;
  79344. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  79345. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  79346. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79347. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  79348. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79349. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  79350. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  79351. getBodyMass(impostor: PhysicsImpostor): number;
  79352. getBodyFriction(impostor: PhysicsImpostor): number;
  79353. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  79354. getBodyRestitution(impostor: PhysicsImpostor): number;
  79355. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  79356. getBodyPressure?(impostor: PhysicsImpostor): number;
  79357. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  79358. getBodyStiffness?(impostor: PhysicsImpostor): number;
  79359. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  79360. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  79361. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  79362. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  79363. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  79364. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79365. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  79366. sleepBody(impostor: PhysicsImpostor): void;
  79367. wakeUpBody(impostor: PhysicsImpostor): void;
  79368. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79369. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  79370. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  79371. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  79372. getRadius(impostor: PhysicsImpostor): number;
  79373. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  79374. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  79375. dispose(): void;
  79376. }
  79377. /**
  79378. * Interface used to define a physics engine
  79379. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  79380. */
  79381. export interface IPhysicsEngine {
  79382. /**
  79383. * Gets the gravity vector used by the simulation
  79384. */
  79385. gravity: Vector3;
  79386. /**
  79387. * Sets the gravity vector used by the simulation
  79388. * @param gravity defines the gravity vector to use
  79389. */
  79390. setGravity(gravity: Vector3): void;
  79391. /**
  79392. * Set the time step of the physics engine.
  79393. * Default is 1/60.
  79394. * To slow it down, enter 1/600 for example.
  79395. * To speed it up, 1/30
  79396. * @param newTimeStep the new timestep to apply to this world.
  79397. */
  79398. setTimeStep(newTimeStep: number): void;
  79399. /**
  79400. * Get the time step of the physics engine.
  79401. * @returns the current time step
  79402. */
  79403. getTimeStep(): number;
  79404. /**
  79405. * Release all resources
  79406. */
  79407. dispose(): void;
  79408. /**
  79409. * Gets the name of the current physics plugin
  79410. * @returns the name of the plugin
  79411. */
  79412. getPhysicsPluginName(): string;
  79413. /**
  79414. * Adding a new impostor for the impostor tracking.
  79415. * This will be done by the impostor itself.
  79416. * @param impostor the impostor to add
  79417. */
  79418. addImpostor(impostor: PhysicsImpostor): void;
  79419. /**
  79420. * Remove an impostor from the engine.
  79421. * This impostor and its mesh will not longer be updated by the physics engine.
  79422. * @param impostor the impostor to remove
  79423. */
  79424. removeImpostor(impostor: PhysicsImpostor): void;
  79425. /**
  79426. * Add a joint to the physics engine
  79427. * @param mainImpostor defines the main impostor to which the joint is added.
  79428. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  79429. * @param joint defines the joint that will connect both impostors.
  79430. */
  79431. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79432. /**
  79433. * Removes a joint from the simulation
  79434. * @param mainImpostor defines the impostor used with the joint
  79435. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  79436. * @param joint defines the joint to remove
  79437. */
  79438. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  79439. /**
  79440. * Gets the current plugin used to run the simulation
  79441. * @returns current plugin
  79442. */
  79443. getPhysicsPlugin(): IPhysicsEnginePlugin;
  79444. /**
  79445. * Gets the list of physic impostors
  79446. * @returns an array of PhysicsImpostor
  79447. */
  79448. getImpostors(): Array<PhysicsImpostor>;
  79449. /**
  79450. * Gets the impostor for a physics enabled object
  79451. * @param object defines the object impersonated by the impostor
  79452. * @returns the PhysicsImpostor or null if not found
  79453. */
  79454. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79455. /**
  79456. * Gets the impostor for a physics body object
  79457. * @param body defines physics body used by the impostor
  79458. * @returns the PhysicsImpostor or null if not found
  79459. */
  79460. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  79461. /**
  79462. * Does a raycast in the physics world
  79463. * @param from when should the ray start?
  79464. * @param to when should the ray end?
  79465. * @returns PhysicsRaycastResult
  79466. */
  79467. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  79468. /**
  79469. * Called by the scene. No need to call it.
  79470. * @param delta defines the timespam between frames
  79471. */
  79472. _step(delta: number): void;
  79473. }
  79474. }
  79475. declare module BABYLON {
  79476. /**
  79477. * The interface for the physics imposter parameters
  79478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79479. */
  79480. export interface PhysicsImpostorParameters {
  79481. /**
  79482. * The mass of the physics imposter
  79483. */
  79484. mass: number;
  79485. /**
  79486. * The friction of the physics imposter
  79487. */
  79488. friction?: number;
  79489. /**
  79490. * The coefficient of restitution of the physics imposter
  79491. */
  79492. restitution?: number;
  79493. /**
  79494. * The native options of the physics imposter
  79495. */
  79496. nativeOptions?: any;
  79497. /**
  79498. * Specifies if the parent should be ignored
  79499. */
  79500. ignoreParent?: boolean;
  79501. /**
  79502. * Specifies if bi-directional transformations should be disabled
  79503. */
  79504. disableBidirectionalTransformation?: boolean;
  79505. /**
  79506. * The pressure inside the physics imposter, soft object only
  79507. */
  79508. pressure?: number;
  79509. /**
  79510. * The stiffness the physics imposter, soft object only
  79511. */
  79512. stiffness?: number;
  79513. /**
  79514. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  79515. */
  79516. velocityIterations?: number;
  79517. /**
  79518. * The number of iterations used in maintaining consistent vertex positions, soft object only
  79519. */
  79520. positionIterations?: number;
  79521. /**
  79522. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  79523. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  79524. * Add to fix multiple points
  79525. */
  79526. fixedPoints?: number;
  79527. /**
  79528. * The collision margin around a soft object
  79529. */
  79530. margin?: number;
  79531. /**
  79532. * The collision margin around a soft object
  79533. */
  79534. damping?: number;
  79535. /**
  79536. * The path for a rope based on an extrusion
  79537. */
  79538. path?: any;
  79539. /**
  79540. * The shape of an extrusion used for a rope based on an extrusion
  79541. */
  79542. shape?: any;
  79543. }
  79544. /**
  79545. * Interface for a physics-enabled object
  79546. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79547. */
  79548. export interface IPhysicsEnabledObject {
  79549. /**
  79550. * The position of the physics-enabled object
  79551. */
  79552. position: Vector3;
  79553. /**
  79554. * The rotation of the physics-enabled object
  79555. */
  79556. rotationQuaternion: Nullable<Quaternion>;
  79557. /**
  79558. * The scale of the physics-enabled object
  79559. */
  79560. scaling: Vector3;
  79561. /**
  79562. * The rotation of the physics-enabled object
  79563. */
  79564. rotation?: Vector3;
  79565. /**
  79566. * The parent of the physics-enabled object
  79567. */
  79568. parent?: any;
  79569. /**
  79570. * The bounding info of the physics-enabled object
  79571. * @returns The bounding info of the physics-enabled object
  79572. */
  79573. getBoundingInfo(): BoundingInfo;
  79574. /**
  79575. * Computes the world matrix
  79576. * @param force Specifies if the world matrix should be computed by force
  79577. * @returns A world matrix
  79578. */
  79579. computeWorldMatrix(force: boolean): Matrix;
  79580. /**
  79581. * Gets the world matrix
  79582. * @returns A world matrix
  79583. */
  79584. getWorldMatrix?(): Matrix;
  79585. /**
  79586. * Gets the child meshes
  79587. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  79588. * @returns An array of abstract meshes
  79589. */
  79590. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  79591. /**
  79592. * Gets the vertex data
  79593. * @param kind The type of vertex data
  79594. * @returns A nullable array of numbers, or a float32 array
  79595. */
  79596. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  79597. /**
  79598. * Gets the indices from the mesh
  79599. * @returns A nullable array of index arrays
  79600. */
  79601. getIndices?(): Nullable<IndicesArray>;
  79602. /**
  79603. * Gets the scene from the mesh
  79604. * @returns the indices array or null
  79605. */
  79606. getScene?(): Scene;
  79607. /**
  79608. * Gets the absolute position from the mesh
  79609. * @returns the absolute position
  79610. */
  79611. getAbsolutePosition(): Vector3;
  79612. /**
  79613. * Gets the absolute pivot point from the mesh
  79614. * @returns the absolute pivot point
  79615. */
  79616. getAbsolutePivotPoint(): Vector3;
  79617. /**
  79618. * Rotates the mesh
  79619. * @param axis The axis of rotation
  79620. * @param amount The amount of rotation
  79621. * @param space The space of the rotation
  79622. * @returns The rotation transform node
  79623. */
  79624. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  79625. /**
  79626. * Translates the mesh
  79627. * @param axis The axis of translation
  79628. * @param distance The distance of translation
  79629. * @param space The space of the translation
  79630. * @returns The transform node
  79631. */
  79632. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  79633. /**
  79634. * Sets the absolute position of the mesh
  79635. * @param absolutePosition The absolute position of the mesh
  79636. * @returns The transform node
  79637. */
  79638. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  79639. /**
  79640. * Gets the class name of the mesh
  79641. * @returns The class name
  79642. */
  79643. getClassName(): string;
  79644. }
  79645. /**
  79646. * Represents a physics imposter
  79647. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  79648. */
  79649. export class PhysicsImpostor {
  79650. /**
  79651. * The physics-enabled object used as the physics imposter
  79652. */
  79653. object: IPhysicsEnabledObject;
  79654. /**
  79655. * The type of the physics imposter
  79656. */
  79657. type: number;
  79658. private _options;
  79659. private _scene?;
  79660. /**
  79661. * The default object size of the imposter
  79662. */
  79663. static DEFAULT_OBJECT_SIZE: Vector3;
  79664. /**
  79665. * The identity quaternion of the imposter
  79666. */
  79667. static IDENTITY_QUATERNION: Quaternion;
  79668. /** @hidden */
  79669. _pluginData: any;
  79670. private _physicsEngine;
  79671. private _physicsBody;
  79672. private _bodyUpdateRequired;
  79673. private _onBeforePhysicsStepCallbacks;
  79674. private _onAfterPhysicsStepCallbacks;
  79675. /** @hidden */
  79676. _onPhysicsCollideCallbacks: Array<{
  79677. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  79678. otherImpostors: Array<PhysicsImpostor>;
  79679. }>;
  79680. private _deltaPosition;
  79681. private _deltaRotation;
  79682. private _deltaRotationConjugated;
  79683. /** hidden */
  79684. _isFromLine: boolean;
  79685. private _parent;
  79686. private _isDisposed;
  79687. private static _tmpVecs;
  79688. private static _tmpQuat;
  79689. /**
  79690. * Specifies if the physics imposter is disposed
  79691. */
  79692. readonly isDisposed: boolean;
  79693. /**
  79694. * Gets the mass of the physics imposter
  79695. */
  79696. mass: number;
  79697. /**
  79698. * Gets the coefficient of friction
  79699. */
  79700. /**
  79701. * Sets the coefficient of friction
  79702. */
  79703. friction: number;
  79704. /**
  79705. * Gets the coefficient of restitution
  79706. */
  79707. /**
  79708. * Sets the coefficient of restitution
  79709. */
  79710. restitution: number;
  79711. /**
  79712. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  79713. */
  79714. /**
  79715. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  79716. */
  79717. pressure: number;
  79718. /**
  79719. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79720. */
  79721. /**
  79722. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  79723. */
  79724. stiffness: number;
  79725. /**
  79726. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79727. */
  79728. /**
  79729. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  79730. */
  79731. velocityIterations: number;
  79732. /**
  79733. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79734. */
  79735. /**
  79736. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  79737. */
  79738. positionIterations: number;
  79739. /**
  79740. * The unique id of the physics imposter
  79741. * set by the physics engine when adding this impostor to the array
  79742. */
  79743. uniqueId: number;
  79744. /**
  79745. * @hidden
  79746. */
  79747. soft: boolean;
  79748. /**
  79749. * @hidden
  79750. */
  79751. segments: number;
  79752. private _joints;
  79753. /**
  79754. * Initializes the physics imposter
  79755. * @param object The physics-enabled object used as the physics imposter
  79756. * @param type The type of the physics imposter
  79757. * @param _options The options for the physics imposter
  79758. * @param _scene The Babylon scene
  79759. */
  79760. constructor(
  79761. /**
  79762. * The physics-enabled object used as the physics imposter
  79763. */
  79764. object: IPhysicsEnabledObject,
  79765. /**
  79766. * The type of the physics imposter
  79767. */
  79768. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  79769. /**
  79770. * This function will completly initialize this impostor.
  79771. * It will create a new body - but only if this mesh has no parent.
  79772. * If it has, this impostor will not be used other than to define the impostor
  79773. * of the child mesh.
  79774. * @hidden
  79775. */
  79776. _init(): void;
  79777. private _getPhysicsParent;
  79778. /**
  79779. * Should a new body be generated.
  79780. * @returns boolean specifying if body initialization is required
  79781. */
  79782. isBodyInitRequired(): boolean;
  79783. /**
  79784. * Sets the updated scaling
  79785. * @param updated Specifies if the scaling is updated
  79786. */
  79787. setScalingUpdated(): void;
  79788. /**
  79789. * Force a regeneration of this or the parent's impostor's body.
  79790. * Use under cautious - This will remove all joints already implemented.
  79791. */
  79792. forceUpdate(): void;
  79793. /**
  79794. * Gets the body that holds this impostor. Either its own, or its parent.
  79795. */
  79796. /**
  79797. * Set the physics body. Used mainly by the physics engine/plugin
  79798. */
  79799. physicsBody: any;
  79800. /**
  79801. * Get the parent of the physics imposter
  79802. * @returns Physics imposter or null
  79803. */
  79804. /**
  79805. * Sets the parent of the physics imposter
  79806. */
  79807. parent: Nullable<PhysicsImpostor>;
  79808. /**
  79809. * Resets the update flags
  79810. */
  79811. resetUpdateFlags(): void;
  79812. /**
  79813. * Gets the object extend size
  79814. * @returns the object extend size
  79815. */
  79816. getObjectExtendSize(): Vector3;
  79817. /**
  79818. * Gets the object center
  79819. * @returns The object center
  79820. */
  79821. getObjectCenter(): Vector3;
  79822. /**
  79823. * Get a specific parametes from the options parameter
  79824. * @param paramName The object parameter name
  79825. * @returns The object parameter
  79826. */
  79827. getParam(paramName: string): any;
  79828. /**
  79829. * Sets a specific parameter in the options given to the physics plugin
  79830. * @param paramName The parameter name
  79831. * @param value The value of the parameter
  79832. */
  79833. setParam(paramName: string, value: number): void;
  79834. /**
  79835. * Specifically change the body's mass option. Won't recreate the physics body object
  79836. * @param mass The mass of the physics imposter
  79837. */
  79838. setMass(mass: number): void;
  79839. /**
  79840. * Gets the linear velocity
  79841. * @returns linear velocity or null
  79842. */
  79843. getLinearVelocity(): Nullable<Vector3>;
  79844. /**
  79845. * Sets the linear velocity
  79846. * @param velocity linear velocity or null
  79847. */
  79848. setLinearVelocity(velocity: Nullable<Vector3>): void;
  79849. /**
  79850. * Gets the angular velocity
  79851. * @returns angular velocity or null
  79852. */
  79853. getAngularVelocity(): Nullable<Vector3>;
  79854. /**
  79855. * Sets the angular velocity
  79856. * @param velocity The velocity or null
  79857. */
  79858. setAngularVelocity(velocity: Nullable<Vector3>): void;
  79859. /**
  79860. * Execute a function with the physics plugin native code
  79861. * Provide a function the will have two variables - the world object and the physics body object
  79862. * @param func The function to execute with the physics plugin native code
  79863. */
  79864. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  79865. /**
  79866. * Register a function that will be executed before the physics world is stepping forward
  79867. * @param func The function to execute before the physics world is stepped forward
  79868. */
  79869. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79870. /**
  79871. * Unregister a function that will be executed before the physics world is stepping forward
  79872. * @param func The function to execute before the physics world is stepped forward
  79873. */
  79874. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79875. /**
  79876. * Register a function that will be executed after the physics step
  79877. * @param func The function to execute after physics step
  79878. */
  79879. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79880. /**
  79881. * Unregisters a function that will be executed after the physics step
  79882. * @param func The function to execute after physics step
  79883. */
  79884. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  79885. /**
  79886. * register a function that will be executed when this impostor collides against a different body
  79887. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  79888. * @param func Callback that is executed on collision
  79889. */
  79890. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  79891. /**
  79892. * Unregisters the physics imposter on contact
  79893. * @param collideAgainst The physics object to collide against
  79894. * @param func Callback to execute on collision
  79895. */
  79896. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  79897. private _tmpQuat;
  79898. private _tmpQuat2;
  79899. /**
  79900. * Get the parent rotation
  79901. * @returns The parent rotation
  79902. */
  79903. getParentsRotation(): Quaternion;
  79904. /**
  79905. * this function is executed by the physics engine.
  79906. */
  79907. beforeStep: () => void;
  79908. /**
  79909. * this function is executed by the physics engine
  79910. */
  79911. afterStep: () => void;
  79912. /**
  79913. * Legacy collision detection event support
  79914. */
  79915. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  79916. /**
  79917. * event and body object due to cannon's event-based architecture.
  79918. */
  79919. onCollide: (e: {
  79920. body: any;
  79921. }) => void;
  79922. /**
  79923. * Apply a force
  79924. * @param force The force to apply
  79925. * @param contactPoint The contact point for the force
  79926. * @returns The physics imposter
  79927. */
  79928. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79929. /**
  79930. * Apply an impulse
  79931. * @param force The impulse force
  79932. * @param contactPoint The contact point for the impulse force
  79933. * @returns The physics imposter
  79934. */
  79935. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  79936. /**
  79937. * A help function to create a joint
  79938. * @param otherImpostor A physics imposter used to create a joint
  79939. * @param jointType The type of joint
  79940. * @param jointData The data for the joint
  79941. * @returns The physics imposter
  79942. */
  79943. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  79944. /**
  79945. * Add a joint to this impostor with a different impostor
  79946. * @param otherImpostor A physics imposter used to add a joint
  79947. * @param joint The joint to add
  79948. * @returns The physics imposter
  79949. */
  79950. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  79951. /**
  79952. * Add an anchor to a cloth impostor
  79953. * @param otherImpostor rigid impostor to anchor to
  79954. * @param width ratio across width from 0 to 1
  79955. * @param height ratio up height from 0 to 1
  79956. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  79957. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  79958. * @returns impostor the soft imposter
  79959. */
  79960. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79961. /**
  79962. * Add a hook to a rope impostor
  79963. * @param otherImpostor rigid impostor to anchor to
  79964. * @param length ratio across rope from 0 to 1
  79965. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  79966. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  79967. * @returns impostor the rope imposter
  79968. */
  79969. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  79970. /**
  79971. * Will keep this body still, in a sleep mode.
  79972. * @returns the physics imposter
  79973. */
  79974. sleep(): PhysicsImpostor;
  79975. /**
  79976. * Wake the body up.
  79977. * @returns The physics imposter
  79978. */
  79979. wakeUp(): PhysicsImpostor;
  79980. /**
  79981. * Clones the physics imposter
  79982. * @param newObject The physics imposter clones to this physics-enabled object
  79983. * @returns A nullable physics imposter
  79984. */
  79985. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  79986. /**
  79987. * Disposes the physics imposter
  79988. */
  79989. dispose(): void;
  79990. /**
  79991. * Sets the delta position
  79992. * @param position The delta position amount
  79993. */
  79994. setDeltaPosition(position: Vector3): void;
  79995. /**
  79996. * Sets the delta rotation
  79997. * @param rotation The delta rotation amount
  79998. */
  79999. setDeltaRotation(rotation: Quaternion): void;
  80000. /**
  80001. * Gets the box size of the physics imposter and stores the result in the input parameter
  80002. * @param result Stores the box size
  80003. * @returns The physics imposter
  80004. */
  80005. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  80006. /**
  80007. * Gets the radius of the physics imposter
  80008. * @returns Radius of the physics imposter
  80009. */
  80010. getRadius(): number;
  80011. /**
  80012. * Sync a bone with this impostor
  80013. * @param bone The bone to sync to the impostor.
  80014. * @param boneMesh The mesh that the bone is influencing.
  80015. * @param jointPivot The pivot of the joint / bone in local space.
  80016. * @param distToJoint Optional distance from the impostor to the joint.
  80017. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80018. */
  80019. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  80020. /**
  80021. * Sync impostor to a bone
  80022. * @param bone The bone that the impostor will be synced to.
  80023. * @param boneMesh The mesh that the bone is influencing.
  80024. * @param jointPivot The pivot of the joint / bone in local space.
  80025. * @param distToJoint Optional distance from the impostor to the joint.
  80026. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  80027. * @param boneAxis Optional vector3 axis the bone is aligned with
  80028. */
  80029. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  80030. /**
  80031. * No-Imposter type
  80032. */
  80033. static NoImpostor: number;
  80034. /**
  80035. * Sphere-Imposter type
  80036. */
  80037. static SphereImpostor: number;
  80038. /**
  80039. * Box-Imposter type
  80040. */
  80041. static BoxImpostor: number;
  80042. /**
  80043. * Plane-Imposter type
  80044. */
  80045. static PlaneImpostor: number;
  80046. /**
  80047. * Mesh-imposter type
  80048. */
  80049. static MeshImpostor: number;
  80050. /**
  80051. * Cylinder-Imposter type
  80052. */
  80053. static CylinderImpostor: number;
  80054. /**
  80055. * Particle-Imposter type
  80056. */
  80057. static ParticleImpostor: number;
  80058. /**
  80059. * Heightmap-Imposter type
  80060. */
  80061. static HeightmapImpostor: number;
  80062. /**
  80063. * ConvexHull-Impostor type (Ammo.js plugin only)
  80064. */
  80065. static ConvexHullImpostor: number;
  80066. /**
  80067. * Rope-Imposter type
  80068. */
  80069. static RopeImpostor: number;
  80070. /**
  80071. * Cloth-Imposter type
  80072. */
  80073. static ClothImpostor: number;
  80074. /**
  80075. * Softbody-Imposter type
  80076. */
  80077. static SoftbodyImpostor: number;
  80078. }
  80079. }
  80080. declare module BABYLON {
  80081. /**
  80082. * Class used to represent a specific level of detail of a mesh
  80083. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80084. */
  80085. export class MeshLODLevel {
  80086. /** Defines the distance where this level should star being displayed */
  80087. distance: number;
  80088. /** Defines the mesh to use to render this level */
  80089. mesh: Nullable<Mesh>;
  80090. /**
  80091. * Creates a new LOD level
  80092. * @param distance defines the distance where this level should star being displayed
  80093. * @param mesh defines the mesh to use to render this level
  80094. */
  80095. constructor(
  80096. /** Defines the distance where this level should star being displayed */
  80097. distance: number,
  80098. /** Defines the mesh to use to render this level */
  80099. mesh: Nullable<Mesh>);
  80100. }
  80101. /**
  80102. * @hidden
  80103. **/
  80104. export class _CreationDataStorage {
  80105. closePath?: boolean;
  80106. closeArray?: boolean;
  80107. idx: number[];
  80108. dashSize: number;
  80109. gapSize: number;
  80110. path3D: Path3D;
  80111. pathArray: Vector3[][];
  80112. arc: number;
  80113. radius: number;
  80114. cap: number;
  80115. tessellation: number;
  80116. }
  80117. /**
  80118. * @hidden
  80119. **/
  80120. class _InstanceDataStorage {
  80121. visibleInstances: any;
  80122. batchCache: _InstancesBatch;
  80123. instancesBufferSize: number;
  80124. instancesBuffer: Nullable<Buffer>;
  80125. instancesData: Float32Array;
  80126. overridenInstanceCount: number;
  80127. isFrozen: boolean;
  80128. previousBatch: _InstancesBatch;
  80129. hardwareInstancedRendering: boolean;
  80130. sideOrientation: number;
  80131. }
  80132. /**
  80133. * @hidden
  80134. **/
  80135. export class _InstancesBatch {
  80136. mustReturn: boolean;
  80137. visibleInstances: Nullable<InstancedMesh[]>[];
  80138. renderSelf: boolean[];
  80139. hardwareInstancedRendering: boolean[];
  80140. }
  80141. /**
  80142. * Class used to represent renderable models
  80143. */
  80144. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  80145. /**
  80146. * Mesh side orientation : usually the external or front surface
  80147. */
  80148. static readonly FRONTSIDE: number;
  80149. /**
  80150. * Mesh side orientation : usually the internal or back surface
  80151. */
  80152. static readonly BACKSIDE: number;
  80153. /**
  80154. * Mesh side orientation : both internal and external or front and back surfaces
  80155. */
  80156. static readonly DOUBLESIDE: number;
  80157. /**
  80158. * Mesh side orientation : by default, `FRONTSIDE`
  80159. */
  80160. static readonly DEFAULTSIDE: number;
  80161. /**
  80162. * Mesh cap setting : no cap
  80163. */
  80164. static readonly NO_CAP: number;
  80165. /**
  80166. * Mesh cap setting : one cap at the beginning of the mesh
  80167. */
  80168. static readonly CAP_START: number;
  80169. /**
  80170. * Mesh cap setting : one cap at the end of the mesh
  80171. */
  80172. static readonly CAP_END: number;
  80173. /**
  80174. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  80175. */
  80176. static readonly CAP_ALL: number;
  80177. /**
  80178. * Gets the default side orientation.
  80179. * @param orientation the orientation to value to attempt to get
  80180. * @returns the default orientation
  80181. * @hidden
  80182. */
  80183. static _GetDefaultSideOrientation(orientation?: number): number;
  80184. private _onBeforeRenderObservable;
  80185. private _onBeforeBindObservable;
  80186. private _onAfterRenderObservable;
  80187. private _onBeforeDrawObservable;
  80188. /**
  80189. * An event triggered before rendering the mesh
  80190. */
  80191. readonly onBeforeRenderObservable: Observable<Mesh>;
  80192. /**
  80193. * An event triggered before binding the mesh
  80194. */
  80195. readonly onBeforeBindObservable: Observable<Mesh>;
  80196. /**
  80197. * An event triggered after rendering the mesh
  80198. */
  80199. readonly onAfterRenderObservable: Observable<Mesh>;
  80200. /**
  80201. * An event triggered before drawing the mesh
  80202. */
  80203. readonly onBeforeDrawObservable: Observable<Mesh>;
  80204. private _onBeforeDrawObserver;
  80205. /**
  80206. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  80207. */
  80208. onBeforeDraw: () => void;
  80209. /**
  80210. * Gets the delay loading state of the mesh (when delay loading is turned on)
  80211. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  80212. */
  80213. delayLoadState: number;
  80214. /**
  80215. * Gets the list of instances created from this mesh
  80216. * it is not supposed to be modified manually.
  80217. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  80218. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80219. */
  80220. instances: InstancedMesh[];
  80221. /**
  80222. * Gets the file containing delay loading data for this mesh
  80223. */
  80224. delayLoadingFile: string;
  80225. /** @hidden */
  80226. _binaryInfo: any;
  80227. private _LODLevels;
  80228. /**
  80229. * User defined function used to change how LOD level selection is done
  80230. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  80231. */
  80232. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  80233. private _morphTargetManager;
  80234. /**
  80235. * Gets or sets the morph target manager
  80236. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  80237. */
  80238. morphTargetManager: Nullable<MorphTargetManager>;
  80239. /** @hidden */
  80240. _creationDataStorage: Nullable<_CreationDataStorage>;
  80241. /** @hidden */
  80242. _geometry: Nullable<Geometry>;
  80243. /** @hidden */
  80244. _delayInfo: Array<string>;
  80245. /** @hidden */
  80246. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  80247. /** @hidden */
  80248. _instanceDataStorage: _InstanceDataStorage;
  80249. private _effectiveMaterial;
  80250. /** @hidden */
  80251. _shouldGenerateFlatShading: boolean;
  80252. private _preActivateId;
  80253. /** @hidden */
  80254. _originalBuilderSideOrientation: number;
  80255. /**
  80256. * Use this property to change the original side orientation defined at construction time
  80257. */
  80258. overrideMaterialSideOrientation: Nullable<number>;
  80259. private _areNormalsFrozen;
  80260. private _sourcePositions;
  80261. private _sourceNormals;
  80262. private _source;
  80263. private meshMap;
  80264. /**
  80265. * Gets the source mesh (the one used to clone this one from)
  80266. */
  80267. readonly source: Nullable<Mesh>;
  80268. /**
  80269. * Gets or sets a boolean indicating that this mesh does not use index buffer
  80270. */
  80271. isUnIndexed: boolean;
  80272. /**
  80273. * @constructor
  80274. * @param name The value used by scene.getMeshByName() to do a lookup.
  80275. * @param scene The scene to add this mesh to.
  80276. * @param parent The parent of this mesh, if it has one
  80277. * @param source An optional Mesh from which geometry is shared, cloned.
  80278. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  80279. * When false, achieved by calling a clone(), also passing False.
  80280. * This will make creation of children, recursive.
  80281. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  80282. */
  80283. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  80284. /**
  80285. * Gets the class name
  80286. * @returns the string "Mesh".
  80287. */
  80288. getClassName(): string;
  80289. /** @hidden */
  80290. readonly _isMesh: boolean;
  80291. /**
  80292. * Returns a description of this mesh
  80293. * @param fullDetails define if full details about this mesh must be used
  80294. * @returns a descriptive string representing this mesh
  80295. */
  80296. toString(fullDetails?: boolean): string;
  80297. /** @hidden */
  80298. _unBindEffect(): void;
  80299. /**
  80300. * Gets a boolean indicating if this mesh has LOD
  80301. */
  80302. readonly hasLODLevels: boolean;
  80303. /**
  80304. * Gets the list of MeshLODLevel associated with the current mesh
  80305. * @returns an array of MeshLODLevel
  80306. */
  80307. getLODLevels(): MeshLODLevel[];
  80308. private _sortLODLevels;
  80309. /**
  80310. * Add a mesh as LOD level triggered at the given distance.
  80311. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80312. * @param distance The distance from the center of the object to show this level
  80313. * @param mesh The mesh to be added as LOD level (can be null)
  80314. * @return This mesh (for chaining)
  80315. */
  80316. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  80317. /**
  80318. * Returns the LOD level mesh at the passed distance or null if not found.
  80319. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80320. * @param distance The distance from the center of the object to show this level
  80321. * @returns a Mesh or `null`
  80322. */
  80323. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  80324. /**
  80325. * Remove a mesh from the LOD array
  80326. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80327. * @param mesh defines the mesh to be removed
  80328. * @return This mesh (for chaining)
  80329. */
  80330. removeLODLevel(mesh: Mesh): Mesh;
  80331. /**
  80332. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  80333. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  80334. * @param camera defines the camera to use to compute distance
  80335. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  80336. * @return This mesh (for chaining)
  80337. */
  80338. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  80339. /**
  80340. * Gets the mesh internal Geometry object
  80341. */
  80342. readonly geometry: Nullable<Geometry>;
  80343. /**
  80344. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  80345. * @returns the total number of vertices
  80346. */
  80347. getTotalVertices(): number;
  80348. /**
  80349. * Returns the content of an associated vertex buffer
  80350. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80351. * - VertexBuffer.PositionKind
  80352. * - VertexBuffer.UVKind
  80353. * - VertexBuffer.UV2Kind
  80354. * - VertexBuffer.UV3Kind
  80355. * - VertexBuffer.UV4Kind
  80356. * - VertexBuffer.UV5Kind
  80357. * - VertexBuffer.UV6Kind
  80358. * - VertexBuffer.ColorKind
  80359. * - VertexBuffer.MatricesIndicesKind
  80360. * - VertexBuffer.MatricesIndicesExtraKind
  80361. * - VertexBuffer.MatricesWeightsKind
  80362. * - VertexBuffer.MatricesWeightsExtraKind
  80363. * @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
  80364. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  80365. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  80366. */
  80367. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  80368. /**
  80369. * Returns the mesh VertexBuffer object from the requested `kind`
  80370. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80371. * - VertexBuffer.PositionKind
  80372. * - VertexBuffer.UVKind
  80373. * - VertexBuffer.UV2Kind
  80374. * - VertexBuffer.UV3Kind
  80375. * - VertexBuffer.UV4Kind
  80376. * - VertexBuffer.UV5Kind
  80377. * - VertexBuffer.UV6Kind
  80378. * - VertexBuffer.ColorKind
  80379. * - VertexBuffer.MatricesIndicesKind
  80380. * - VertexBuffer.MatricesIndicesExtraKind
  80381. * - VertexBuffer.MatricesWeightsKind
  80382. * - VertexBuffer.MatricesWeightsExtraKind
  80383. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  80384. */
  80385. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  80386. /**
  80387. * Tests if a specific vertex buffer is associated with this mesh
  80388. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80389. * - VertexBuffer.PositionKind
  80390. * - VertexBuffer.UVKind
  80391. * - VertexBuffer.UV2Kind
  80392. * - VertexBuffer.UV3Kind
  80393. * - VertexBuffer.UV4Kind
  80394. * - VertexBuffer.UV5Kind
  80395. * - VertexBuffer.UV6Kind
  80396. * - VertexBuffer.ColorKind
  80397. * - VertexBuffer.MatricesIndicesKind
  80398. * - VertexBuffer.MatricesIndicesExtraKind
  80399. * - VertexBuffer.MatricesWeightsKind
  80400. * - VertexBuffer.MatricesWeightsExtraKind
  80401. * @returns a boolean
  80402. */
  80403. isVerticesDataPresent(kind: string): boolean;
  80404. /**
  80405. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  80406. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  80407. * - VertexBuffer.PositionKind
  80408. * - VertexBuffer.UVKind
  80409. * - VertexBuffer.UV2Kind
  80410. * - VertexBuffer.UV3Kind
  80411. * - VertexBuffer.UV4Kind
  80412. * - VertexBuffer.UV5Kind
  80413. * - VertexBuffer.UV6Kind
  80414. * - VertexBuffer.ColorKind
  80415. * - VertexBuffer.MatricesIndicesKind
  80416. * - VertexBuffer.MatricesIndicesExtraKind
  80417. * - VertexBuffer.MatricesWeightsKind
  80418. * - VertexBuffer.MatricesWeightsExtraKind
  80419. * @returns a boolean
  80420. */
  80421. isVertexBufferUpdatable(kind: string): boolean;
  80422. /**
  80423. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  80424. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  80425. * - VertexBuffer.PositionKind
  80426. * - VertexBuffer.UVKind
  80427. * - VertexBuffer.UV2Kind
  80428. * - VertexBuffer.UV3Kind
  80429. * - VertexBuffer.UV4Kind
  80430. * - VertexBuffer.UV5Kind
  80431. * - VertexBuffer.UV6Kind
  80432. * - VertexBuffer.ColorKind
  80433. * - VertexBuffer.MatricesIndicesKind
  80434. * - VertexBuffer.MatricesIndicesExtraKind
  80435. * - VertexBuffer.MatricesWeightsKind
  80436. * - VertexBuffer.MatricesWeightsExtraKind
  80437. * @returns an array of strings
  80438. */
  80439. getVerticesDataKinds(): string[];
  80440. /**
  80441. * Returns a positive integer : the total number of indices in this mesh geometry.
  80442. * @returns the numner of indices or zero if the mesh has no geometry.
  80443. */
  80444. getTotalIndices(): number;
  80445. /**
  80446. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  80447. * @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.
  80448. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  80449. * @returns the indices array or an empty array if the mesh has no geometry
  80450. */
  80451. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  80452. readonly isBlocked: boolean;
  80453. /**
  80454. * Determine if the current mesh is ready to be rendered
  80455. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  80456. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  80457. * @returns true if all associated assets are ready (material, textures, shaders)
  80458. */
  80459. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  80460. /**
  80461. * 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.
  80462. */
  80463. readonly areNormalsFrozen: boolean;
  80464. /**
  80465. * 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.
  80466. * @returns the current mesh
  80467. */
  80468. freezeNormals(): Mesh;
  80469. /**
  80470. * 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
  80471. * @returns the current mesh
  80472. */
  80473. unfreezeNormals(): Mesh;
  80474. /**
  80475. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  80476. */
  80477. overridenInstanceCount: number;
  80478. /** @hidden */
  80479. _preActivate(): Mesh;
  80480. /** @hidden */
  80481. _preActivateForIntermediateRendering(renderId: number): Mesh;
  80482. /** @hidden */
  80483. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  80484. /**
  80485. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  80486. * This means the mesh underlying bounding box and sphere are recomputed.
  80487. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  80488. * @returns the current mesh
  80489. */
  80490. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  80491. /** @hidden */
  80492. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  80493. /**
  80494. * This function will subdivide the mesh into multiple submeshes
  80495. * @param count defines the expected number of submeshes
  80496. */
  80497. subdivide(count: number): void;
  80498. /**
  80499. * Copy a FloatArray into a specific associated vertex buffer
  80500. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80501. * - VertexBuffer.PositionKind
  80502. * - VertexBuffer.UVKind
  80503. * - VertexBuffer.UV2Kind
  80504. * - VertexBuffer.UV3Kind
  80505. * - VertexBuffer.UV4Kind
  80506. * - VertexBuffer.UV5Kind
  80507. * - VertexBuffer.UV6Kind
  80508. * - VertexBuffer.ColorKind
  80509. * - VertexBuffer.MatricesIndicesKind
  80510. * - VertexBuffer.MatricesIndicesExtraKind
  80511. * - VertexBuffer.MatricesWeightsKind
  80512. * - VertexBuffer.MatricesWeightsExtraKind
  80513. * @param data defines the data source
  80514. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80515. * @param stride defines the data stride size (can be null)
  80516. * @returns the current mesh
  80517. */
  80518. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): Mesh;
  80519. /**
  80520. * Flags an associated vertex buffer as updatable
  80521. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  80522. * - VertexBuffer.PositionKind
  80523. * - VertexBuffer.UVKind
  80524. * - VertexBuffer.UV2Kind
  80525. * - VertexBuffer.UV3Kind
  80526. * - VertexBuffer.UV4Kind
  80527. * - VertexBuffer.UV5Kind
  80528. * - VertexBuffer.UV6Kind
  80529. * - VertexBuffer.ColorKind
  80530. * - VertexBuffer.MatricesIndicesKind
  80531. * - VertexBuffer.MatricesIndicesExtraKind
  80532. * - VertexBuffer.MatricesWeightsKind
  80533. * - VertexBuffer.MatricesWeightsExtraKind
  80534. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  80535. */
  80536. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  80537. /**
  80538. * Sets the mesh global Vertex Buffer
  80539. * @param buffer defines the buffer to use
  80540. * @returns the current mesh
  80541. */
  80542. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  80543. /**
  80544. * Update a specific associated vertex buffer
  80545. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  80546. * - VertexBuffer.PositionKind
  80547. * - VertexBuffer.UVKind
  80548. * - VertexBuffer.UV2Kind
  80549. * - VertexBuffer.UV3Kind
  80550. * - VertexBuffer.UV4Kind
  80551. * - VertexBuffer.UV5Kind
  80552. * - VertexBuffer.UV6Kind
  80553. * - VertexBuffer.ColorKind
  80554. * - VertexBuffer.MatricesIndicesKind
  80555. * - VertexBuffer.MatricesIndicesExtraKind
  80556. * - VertexBuffer.MatricesWeightsKind
  80557. * - VertexBuffer.MatricesWeightsExtraKind
  80558. * @param data defines the data source
  80559. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  80560. * @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)
  80561. * @returns the current mesh
  80562. */
  80563. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  80564. /**
  80565. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  80566. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  80567. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  80568. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  80569. * @returns the current mesh
  80570. */
  80571. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  80572. /**
  80573. * Creates a un-shared specific occurence of the geometry for the mesh.
  80574. * @returns the current mesh
  80575. */
  80576. makeGeometryUnique(): Mesh;
  80577. /**
  80578. * Set the index buffer of this mesh
  80579. * @param indices defines the source data
  80580. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  80581. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  80582. * @returns the current mesh
  80583. */
  80584. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): Mesh;
  80585. /**
  80586. * Update the current index buffer
  80587. * @param indices defines the source data
  80588. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  80589. * @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)
  80590. * @returns the current mesh
  80591. */
  80592. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): Mesh;
  80593. /**
  80594. * Invert the geometry to move from a right handed system to a left handed one.
  80595. * @returns the current mesh
  80596. */
  80597. toLeftHanded(): Mesh;
  80598. /** @hidden */
  80599. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  80600. /** @hidden */
  80601. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  80602. /**
  80603. * Registers for this mesh a javascript function called just before the rendering process
  80604. * @param func defines the function to call before rendering this mesh
  80605. * @returns the current mesh
  80606. */
  80607. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80608. /**
  80609. * Disposes a previously registered javascript function called before the rendering
  80610. * @param func defines the function to remove
  80611. * @returns the current mesh
  80612. */
  80613. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  80614. /**
  80615. * Registers for this mesh a javascript function called just after the rendering is complete
  80616. * @param func defines the function to call after rendering this mesh
  80617. * @returns the current mesh
  80618. */
  80619. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80620. /**
  80621. * Disposes a previously registered javascript function called after the rendering.
  80622. * @param func defines the function to remove
  80623. * @returns the current mesh
  80624. */
  80625. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  80626. /** @hidden */
  80627. _getInstancesRenderList(subMeshId: number): _InstancesBatch;
  80628. /** @hidden */
  80629. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  80630. /** @hidden */
  80631. _processRendering(subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  80632. /** @hidden */
  80633. _freeze(): void;
  80634. /** @hidden */
  80635. _unFreeze(): void;
  80636. /**
  80637. * 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
  80638. * @param subMesh defines the subMesh to render
  80639. * @param enableAlphaMode defines if alpha mode can be changed
  80640. * @returns the current mesh
  80641. */
  80642. render(subMesh: SubMesh, enableAlphaMode: boolean): Mesh;
  80643. private _onBeforeDraw;
  80644. /**
  80645. * Renormalize the mesh and patch it up if there are no weights
  80646. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  80647. * However in the case of zero weights then we set just a single influence to 1.
  80648. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  80649. */
  80650. cleanMatrixWeights(): void;
  80651. private normalizeSkinFourWeights;
  80652. private normalizeSkinWeightsAndExtra;
  80653. /**
  80654. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  80655. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  80656. * the user know there was an issue with importing the mesh
  80657. * @returns a validation object with skinned, valid and report string
  80658. */
  80659. validateSkinning(): {
  80660. skinned: boolean;
  80661. valid: boolean;
  80662. report: string;
  80663. };
  80664. /** @hidden */
  80665. _checkDelayState(): Mesh;
  80666. private _queueLoad;
  80667. /**
  80668. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  80669. * A mesh is in the frustum if its bounding box intersects the frustum
  80670. * @param frustumPlanes defines the frustum to test
  80671. * @returns true if the mesh is in the frustum planes
  80672. */
  80673. isInFrustum(frustumPlanes: Plane[]): boolean;
  80674. /**
  80675. * Sets the mesh material by the material or multiMaterial `id` property
  80676. * @param id is a string identifying the material or the multiMaterial
  80677. * @returns the current mesh
  80678. */
  80679. setMaterialByID(id: string): Mesh;
  80680. /**
  80681. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  80682. * @returns an array of IAnimatable
  80683. */
  80684. getAnimatables(): IAnimatable[];
  80685. /**
  80686. * Modifies the mesh geometry according to the passed transformation matrix.
  80687. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  80688. * The mesh normals are modified using the same transformation.
  80689. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80690. * @param transform defines the transform matrix to use
  80691. * @see http://doc.babylonjs.com/resources/baking_transformations
  80692. * @returns the current mesh
  80693. */
  80694. bakeTransformIntoVertices(transform: Matrix): Mesh;
  80695. /**
  80696. * Modifies the mesh geometry according to its own current World Matrix.
  80697. * The mesh World Matrix is then reset.
  80698. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  80699. * Note that, under the hood, this method sets a new VertexBuffer each call.
  80700. * @see http://doc.babylonjs.com/resources/baking_transformations
  80701. * @returns the current mesh
  80702. */
  80703. bakeCurrentTransformIntoVertices(): Mesh;
  80704. /** @hidden */
  80705. readonly _positions: Nullable<Vector3[]>;
  80706. /** @hidden */
  80707. _resetPointsArrayCache(): Mesh;
  80708. /** @hidden */
  80709. _generatePointsArray(): boolean;
  80710. /**
  80711. * Returns a new Mesh object generated from the current mesh properties.
  80712. * This method must not get confused with createInstance()
  80713. * @param name is a string, the name given to the new mesh
  80714. * @param newParent can be any Node object (default `null`)
  80715. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  80716. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  80717. * @returns a new mesh
  80718. */
  80719. clone(name?: string, newParent?: Node, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  80720. /**
  80721. * Releases resources associated with this mesh.
  80722. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80723. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80724. */
  80725. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  80726. /**
  80727. * Modifies the mesh geometry according to a displacement map.
  80728. * 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.
  80729. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80730. * @param url is a string, the URL from the image file is to be downloaded.
  80731. * @param minHeight is the lower limit of the displacement.
  80732. * @param maxHeight is the upper limit of the displacement.
  80733. * @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.
  80734. * @param uvOffset is an optional vector2 used to offset UV.
  80735. * @param uvScale is an optional vector2 used to scale UV.
  80736. * @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.
  80737. * @returns the Mesh.
  80738. */
  80739. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80740. /**
  80741. * Modifies the mesh geometry according to a displacementMap buffer.
  80742. * 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.
  80743. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  80744. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  80745. * @param heightMapWidth is the width of the buffer image.
  80746. * @param heightMapHeight is the height of the buffer image.
  80747. * @param minHeight is the lower limit of the displacement.
  80748. * @param maxHeight is the upper limit of the displacement.
  80749. * @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.
  80750. * @param uvOffset is an optional vector2 used to offset UV.
  80751. * @param uvScale is an optional vector2 used to scale UV.
  80752. * @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.
  80753. * @returns the Mesh.
  80754. */
  80755. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  80756. /**
  80757. * Modify the mesh to get a flat shading rendering.
  80758. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  80759. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  80760. * @returns current mesh
  80761. */
  80762. convertToFlatShadedMesh(): Mesh;
  80763. /**
  80764. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  80765. * In other words, more vertices, no more indices and a single bigger VBO.
  80766. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  80767. * @returns current mesh
  80768. */
  80769. convertToUnIndexedMesh(): Mesh;
  80770. /**
  80771. * Inverses facet orientations.
  80772. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80773. * @param flipNormals will also inverts the normals
  80774. * @returns current mesh
  80775. */
  80776. flipFaces(flipNormals?: boolean): Mesh;
  80777. /**
  80778. * Increase the number of facets and hence vertices in a mesh
  80779. * Vertex normals are interpolated from existing vertex normals
  80780. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80781. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  80782. */
  80783. increaseVertices(numberPerEdge: number): void;
  80784. /**
  80785. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  80786. * This will undo any application of covertToFlatShadedMesh
  80787. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  80788. */
  80789. forceSharedVertices(): void;
  80790. /** @hidden */
  80791. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  80792. /** @hidden */
  80793. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  80794. /**
  80795. * Creates a new InstancedMesh object from the mesh model.
  80796. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  80797. * @param name defines the name of the new instance
  80798. * @returns a new InstancedMesh
  80799. */
  80800. createInstance(name: string): InstancedMesh;
  80801. /**
  80802. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  80803. * After this call, all the mesh instances have the same submeshes than the current mesh.
  80804. * @returns the current mesh
  80805. */
  80806. synchronizeInstances(): Mesh;
  80807. /**
  80808. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  80809. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  80810. * This should be used together with the simplification to avoid disappearing triangles.
  80811. * @param successCallback an optional success callback to be called after the optimization finished.
  80812. * @returns the current mesh
  80813. */
  80814. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  80815. /**
  80816. * Serialize current mesh
  80817. * @param serializationObject defines the object which will receive the serialization data
  80818. */
  80819. serialize(serializationObject: any): void;
  80820. /** @hidden */
  80821. _syncGeometryWithMorphTargetManager(): void;
  80822. /** @hidden */
  80823. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  80824. /**
  80825. * Returns a new Mesh object parsed from the source provided.
  80826. * @param parsedMesh is the source
  80827. * @param scene defines the hosting scene
  80828. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  80829. * @returns a new Mesh
  80830. */
  80831. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  80832. /**
  80833. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  80834. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80835. * @param name defines the name of the mesh to create
  80836. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  80837. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  80838. * @param closePath creates a seam between the first and the last points of each path of the path array
  80839. * @param offset is taken in account only if the `pathArray` is containing a single path
  80840. * @param scene defines the hosting scene
  80841. * @param updatable defines if the mesh must be flagged as updatable
  80842. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80843. * @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)
  80844. * @returns a new Mesh
  80845. */
  80846. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  80847. /**
  80848. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  80849. * @param name defines the name of the mesh to create
  80850. * @param radius sets the radius size (float) of the polygon (default 0.5)
  80851. * @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
  80852. * @param scene defines the hosting scene
  80853. * @param updatable defines if the mesh must be flagged as updatable
  80854. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80855. * @returns a new Mesh
  80856. */
  80857. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80858. /**
  80859. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  80860. * @param name defines the name of the mesh to create
  80861. * @param size sets the size (float) of each box side (default 1)
  80862. * @param scene defines the hosting scene
  80863. * @param updatable defines if the mesh must be flagged as updatable
  80864. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80865. * @returns a new Mesh
  80866. */
  80867. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  80868. /**
  80869. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  80870. * @param name defines the name of the mesh to create
  80871. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80872. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80873. * @param scene defines the hosting scene
  80874. * @param updatable defines if the mesh must be flagged as updatable
  80875. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80876. * @returns a new Mesh
  80877. */
  80878. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80879. /**
  80880. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  80881. * @param name defines the name of the mesh to create
  80882. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  80883. * @param diameter sets the diameter size (float) of the sphere (default 1)
  80884. * @param scene defines the hosting scene
  80885. * @returns a new Mesh
  80886. */
  80887. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  80888. /**
  80889. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  80890. * @param name defines the name of the mesh to create
  80891. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  80892. * @param diameterTop set the top cap diameter (floats, default 1)
  80893. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  80894. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  80895. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  80896. * @param scene defines the hosting scene
  80897. * @param updatable defines if the mesh must be flagged as updatable
  80898. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80899. * @returns a new Mesh
  80900. */
  80901. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  80902. /**
  80903. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  80904. * @param name defines the name of the mesh to create
  80905. * @param diameter sets the diameter size (float) of the torus (default 1)
  80906. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  80907. * @param tessellation sets the number of torus sides (postive integer, default 16)
  80908. * @param scene defines the hosting scene
  80909. * @param updatable defines if the mesh must be flagged as updatable
  80910. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80911. * @returns a new Mesh
  80912. */
  80913. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80914. /**
  80915. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  80916. * @param name defines the name of the mesh to create
  80917. * @param radius sets the global radius size (float) of the torus knot (default 2)
  80918. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  80919. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  80920. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  80921. * @param p the number of windings on X axis (positive integers, default 2)
  80922. * @param q the number of windings on Y axis (positive integers, default 3)
  80923. * @param scene defines the hosting scene
  80924. * @param updatable defines if the mesh must be flagged as updatable
  80925. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80926. * @returns a new Mesh
  80927. */
  80928. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  80929. /**
  80930. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  80931. * @param name defines the name of the mesh to create
  80932. * @param points is an array successive Vector3
  80933. * @param scene defines the hosting scene
  80934. * @param updatable defines if the mesh must be flagged as updatable
  80935. * @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).
  80936. * @returns a new Mesh
  80937. */
  80938. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  80939. /**
  80940. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  80941. * @param name defines the name of the mesh to create
  80942. * @param points is an array successive Vector3
  80943. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  80944. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  80945. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  80946. * @param scene defines the hosting scene
  80947. * @param updatable defines if the mesh must be flagged as updatable
  80948. * @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)
  80949. * @returns a new Mesh
  80950. */
  80951. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  80952. /**
  80953. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  80954. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  80955. * 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.
  80956. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  80957. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  80958. * Remember you can only change the shape positions, not their number when updating a polygon.
  80959. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  80960. * @param name defines the name of the mesh to create
  80961. * @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
  80962. * @param scene defines the hosting scene
  80963. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80964. * @param updatable defines if the mesh must be flagged as updatable
  80965. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80966. * @param earcutInjection can be used to inject your own earcut reference
  80967. * @returns a new Mesh
  80968. */
  80969. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80970. /**
  80971. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  80972. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  80973. * @param name defines the name of the mesh to create
  80974. * @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
  80975. * @param depth defines the height of extrusion
  80976. * @param scene defines the hosting scene
  80977. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  80978. * @param updatable defines if the mesh must be flagged as updatable
  80979. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80980. * @param earcutInjection can be used to inject your own earcut reference
  80981. * @returns a new Mesh
  80982. */
  80983. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  80984. /**
  80985. * Creates an extruded shape mesh.
  80986. * 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
  80987. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  80988. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  80989. * @param name defines the name of the mesh to create
  80990. * @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
  80991. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  80992. * @param scale is the value to scale the shape
  80993. * @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
  80994. * @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
  80995. * @param scene defines the hosting scene
  80996. * @param updatable defines if the mesh must be flagged as updatable
  80997. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  80998. * @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)
  80999. * @returns a new Mesh
  81000. */
  81001. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81002. /**
  81003. * Creates an custom extruded shape mesh.
  81004. * The custom extrusion is a parametric shape.
  81005. * It has no predefined shape. Its final shape will depend on the input parameters.
  81006. * Please consider using the same method from the MeshBuilder class instead
  81007. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  81008. * @param name defines the name of the mesh to create
  81009. * @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
  81010. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  81011. * @param scaleFunction is a custom Javascript function called on each path point
  81012. * @param rotationFunction is a custom Javascript function called on each path point
  81013. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  81014. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  81015. * @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
  81016. * @param scene defines the hosting scene
  81017. * @param updatable defines if the mesh must be flagged as updatable
  81018. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81019. * @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)
  81020. * @returns a new Mesh
  81021. */
  81022. 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;
  81023. /**
  81024. * Creates lathe mesh.
  81025. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  81026. * Please consider using the same method from the MeshBuilder class instead
  81027. * @param name defines the name of the mesh to create
  81028. * @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
  81029. * @param radius is the radius value of the lathe
  81030. * @param tessellation is the side number of the lathe.
  81031. * @param scene defines the hosting scene
  81032. * @param updatable defines if the mesh must be flagged as updatable
  81033. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81034. * @returns a new Mesh
  81035. */
  81036. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81037. /**
  81038. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  81039. * @param name defines the name of the mesh to create
  81040. * @param size sets the size (float) of both sides of the plane at once (default 1)
  81041. * @param scene defines the hosting scene
  81042. * @param updatable defines if the mesh must be flagged as updatable
  81043. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81044. * @returns a new Mesh
  81045. */
  81046. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  81047. /**
  81048. * Creates a ground mesh.
  81049. * Please consider using the same method from the MeshBuilder class instead
  81050. * @param name defines the name of the mesh to create
  81051. * @param width set the width of the ground
  81052. * @param height set the height of the ground
  81053. * @param subdivisions sets the number of subdivisions per side
  81054. * @param scene defines the hosting scene
  81055. * @param updatable defines if the mesh must be flagged as updatable
  81056. * @returns a new Mesh
  81057. */
  81058. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  81059. /**
  81060. * Creates a tiled ground mesh.
  81061. * Please consider using the same method from the MeshBuilder class instead
  81062. * @param name defines the name of the mesh to create
  81063. * @param xmin set the ground minimum X coordinate
  81064. * @param zmin set the ground minimum Y coordinate
  81065. * @param xmax set the ground maximum X coordinate
  81066. * @param zmax set the ground maximum Z coordinate
  81067. * @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
  81068. * @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
  81069. * @param scene defines the hosting scene
  81070. * @param updatable defines if the mesh must be flagged as updatable
  81071. * @returns a new Mesh
  81072. */
  81073. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  81074. w: number;
  81075. h: number;
  81076. }, precision: {
  81077. w: number;
  81078. h: number;
  81079. }, scene: Scene, updatable?: boolean): Mesh;
  81080. /**
  81081. * Creates a ground mesh from a height map.
  81082. * Please consider using the same method from the MeshBuilder class instead
  81083. * @see http://doc.babylonjs.com/babylon101/height_map
  81084. * @param name defines the name of the mesh to create
  81085. * @param url sets the URL of the height map image resource
  81086. * @param width set the ground width size
  81087. * @param height set the ground height size
  81088. * @param subdivisions sets the number of subdivision per side
  81089. * @param minHeight is the minimum altitude on the ground
  81090. * @param maxHeight is the maximum altitude on the ground
  81091. * @param scene defines the hosting scene
  81092. * @param updatable defines if the mesh must be flagged as updatable
  81093. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  81094. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  81095. * @returns a new Mesh
  81096. */
  81097. 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;
  81098. /**
  81099. * Creates a tube mesh.
  81100. * The tube is a parametric shape.
  81101. * It has no predefined shape. Its final shape will depend on the input parameters.
  81102. * Please consider using the same method from the MeshBuilder class instead
  81103. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  81104. * @param name defines the name of the mesh to create
  81105. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  81106. * @param radius sets the tube radius size
  81107. * @param tessellation is the number of sides on the tubular surface
  81108. * @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
  81109. * @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
  81110. * @param scene defines the hosting scene
  81111. * @param updatable defines if the mesh must be flagged as updatable
  81112. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  81113. * @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)
  81114. * @returns a new Mesh
  81115. */
  81116. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  81117. (i: number, distance: number): number;
  81118. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  81119. /**
  81120. * Creates a polyhedron mesh.
  81121. * Please consider using the same method from the MeshBuilder class instead.
  81122. * * 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
  81123. * * The parameter `size` (positive float, default 1) sets the polygon size
  81124. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  81125. * * 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`
  81126. * * 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
  81127. * * 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)`)
  81128. * * 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
  81129. * * 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
  81130. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81131. * * If you create a double-sided mesh, you can choose what parts of 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
  81132. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81133. * @param name defines the name of the mesh to create
  81134. * @param options defines the options used to create the mesh
  81135. * @param scene defines the hosting scene
  81136. * @returns a new Mesh
  81137. */
  81138. static CreatePolyhedron(name: string, options: {
  81139. type?: number;
  81140. size?: number;
  81141. sizeX?: number;
  81142. sizeY?: number;
  81143. sizeZ?: number;
  81144. custom?: any;
  81145. faceUV?: Vector4[];
  81146. faceColors?: Color4[];
  81147. updatable?: boolean;
  81148. sideOrientation?: number;
  81149. }, scene: Scene): Mesh;
  81150. /**
  81151. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  81152. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  81153. * * 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`)
  81154. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  81155. * * 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
  81156. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  81157. * * If you create a double-sided mesh, you can choose what parts of 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
  81158. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  81159. * @param name defines the name of the mesh
  81160. * @param options defines the options used to create the mesh
  81161. * @param scene defines the hosting scene
  81162. * @returns a new Mesh
  81163. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  81164. */
  81165. static CreateIcoSphere(name: string, options: {
  81166. radius?: number;
  81167. flat?: boolean;
  81168. subdivisions?: number;
  81169. sideOrientation?: number;
  81170. updatable?: boolean;
  81171. }, scene: Scene): Mesh;
  81172. /**
  81173. * Creates a decal mesh.
  81174. * Please consider using the same method from the MeshBuilder class instead.
  81175. * A decal is a mesh usually applied as a model onto the surface of another mesh
  81176. * @param name defines the name of the mesh
  81177. * @param sourceMesh defines the mesh receiving the decal
  81178. * @param position sets the position of the decal in world coordinates
  81179. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  81180. * @param size sets the decal scaling
  81181. * @param angle sets the angle to rotate the decal
  81182. * @returns a new Mesh
  81183. */
  81184. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  81185. /**
  81186. * Prepare internal position array for software CPU skinning
  81187. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  81188. */
  81189. setPositionsForCPUSkinning(): Float32Array;
  81190. /**
  81191. * Prepare internal normal array for software CPU skinning
  81192. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  81193. */
  81194. setNormalsForCPUSkinning(): Float32Array;
  81195. /**
  81196. * Updates the vertex buffer by applying transformation from the bones
  81197. * @param skeleton defines the skeleton to apply to current mesh
  81198. * @returns the current mesh
  81199. */
  81200. applySkeleton(skeleton: Skeleton): Mesh;
  81201. /**
  81202. * 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
  81203. * @param meshes defines the list of meshes to scan
  81204. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  81205. */
  81206. static MinMax(meshes: AbstractMesh[]): {
  81207. min: Vector3;
  81208. max: Vector3;
  81209. };
  81210. /**
  81211. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  81212. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  81213. * @returns a vector3
  81214. */
  81215. static Center(meshesOrMinMaxVector: {
  81216. min: Vector3;
  81217. max: Vector3;
  81218. } | AbstractMesh[]): Vector3;
  81219. /**
  81220. * Merge the array of meshes into a single mesh for performance reasons.
  81221. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  81222. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  81223. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  81224. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  81225. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  81226. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  81227. * @returns a new mesh
  81228. */
  81229. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  81230. /** @hidden */
  81231. addInstance(instance: InstancedMesh): void;
  81232. /** @hidden */
  81233. removeInstance(instance: InstancedMesh): void;
  81234. }
  81235. }
  81236. declare module BABYLON {
  81237. /**
  81238. * Base class for the main features of a material in Babylon.js
  81239. */
  81240. export class Material implements IAnimatable {
  81241. /**
  81242. * Returns the triangle fill mode
  81243. */
  81244. static readonly TriangleFillMode: number;
  81245. /**
  81246. * Returns the wireframe mode
  81247. */
  81248. static readonly WireFrameFillMode: number;
  81249. /**
  81250. * Returns the point fill mode
  81251. */
  81252. static readonly PointFillMode: number;
  81253. /**
  81254. * Returns the point list draw mode
  81255. */
  81256. static readonly PointListDrawMode: number;
  81257. /**
  81258. * Returns the line list draw mode
  81259. */
  81260. static readonly LineListDrawMode: number;
  81261. /**
  81262. * Returns the line loop draw mode
  81263. */
  81264. static readonly LineLoopDrawMode: number;
  81265. /**
  81266. * Returns the line strip draw mode
  81267. */
  81268. static readonly LineStripDrawMode: number;
  81269. /**
  81270. * Returns the triangle strip draw mode
  81271. */
  81272. static readonly TriangleStripDrawMode: number;
  81273. /**
  81274. * Returns the triangle fan draw mode
  81275. */
  81276. static readonly TriangleFanDrawMode: number;
  81277. /**
  81278. * Stores the clock-wise side orientation
  81279. */
  81280. static readonly ClockWiseSideOrientation: number;
  81281. /**
  81282. * Stores the counter clock-wise side orientation
  81283. */
  81284. static readonly CounterClockWiseSideOrientation: number;
  81285. /**
  81286. * The dirty texture flag value
  81287. */
  81288. static readonly TextureDirtyFlag: number;
  81289. /**
  81290. * The dirty light flag value
  81291. */
  81292. static readonly LightDirtyFlag: number;
  81293. /**
  81294. * The dirty fresnel flag value
  81295. */
  81296. static readonly FresnelDirtyFlag: number;
  81297. /**
  81298. * The dirty attribute flag value
  81299. */
  81300. static readonly AttributesDirtyFlag: number;
  81301. /**
  81302. * The dirty misc flag value
  81303. */
  81304. static readonly MiscDirtyFlag: number;
  81305. /**
  81306. * The all dirty flag value
  81307. */
  81308. static readonly AllDirtyFlag: number;
  81309. /**
  81310. * The ID of the material
  81311. */
  81312. id: string;
  81313. /**
  81314. * Gets or sets the unique id of the material
  81315. */
  81316. uniqueId: number;
  81317. /**
  81318. * The name of the material
  81319. */
  81320. name: string;
  81321. /**
  81322. * Gets or sets user defined metadata
  81323. */
  81324. metadata: any;
  81325. /**
  81326. * For internal use only. Please do not use.
  81327. */
  81328. reservedDataStore: any;
  81329. /**
  81330. * Specifies if the ready state should be checked on each call
  81331. */
  81332. checkReadyOnEveryCall: boolean;
  81333. /**
  81334. * Specifies if the ready state should be checked once
  81335. */
  81336. checkReadyOnlyOnce: boolean;
  81337. /**
  81338. * The state of the material
  81339. */
  81340. state: string;
  81341. /**
  81342. * The alpha value of the material
  81343. */
  81344. protected _alpha: number;
  81345. /**
  81346. * List of inspectable custom properties (used by the Inspector)
  81347. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  81348. */
  81349. inspectableCustomProperties: IInspectable[];
  81350. /**
  81351. * Sets the alpha value of the material
  81352. */
  81353. /**
  81354. * Gets the alpha value of the material
  81355. */
  81356. alpha: number;
  81357. /**
  81358. * Specifies if back face culling is enabled
  81359. */
  81360. protected _backFaceCulling: boolean;
  81361. /**
  81362. * Sets the back-face culling state
  81363. */
  81364. /**
  81365. * Gets the back-face culling state
  81366. */
  81367. backFaceCulling: boolean;
  81368. /**
  81369. * Stores the value for side orientation
  81370. */
  81371. sideOrientation: number;
  81372. /**
  81373. * Callback triggered when the material is compiled
  81374. */
  81375. onCompiled: Nullable<(effect: Effect) => void>;
  81376. /**
  81377. * Callback triggered when an error occurs
  81378. */
  81379. onError: Nullable<(effect: Effect, errors: string) => void>;
  81380. /**
  81381. * Callback triggered to get the render target textures
  81382. */
  81383. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  81384. /**
  81385. * Gets a boolean indicating that current material needs to register RTT
  81386. */
  81387. readonly hasRenderTargetTextures: boolean;
  81388. /**
  81389. * Specifies if the material should be serialized
  81390. */
  81391. doNotSerialize: boolean;
  81392. /**
  81393. * @hidden
  81394. */
  81395. _storeEffectOnSubMeshes: boolean;
  81396. /**
  81397. * Stores the animations for the material
  81398. */
  81399. animations: Nullable<Array<Animation>>;
  81400. /**
  81401. * An event triggered when the material is disposed
  81402. */
  81403. onDisposeObservable: Observable<Material>;
  81404. /**
  81405. * An observer which watches for dispose events
  81406. */
  81407. private _onDisposeObserver;
  81408. private _onUnBindObservable;
  81409. /**
  81410. * Called during a dispose event
  81411. */
  81412. onDispose: () => void;
  81413. private _onBindObservable;
  81414. /**
  81415. * An event triggered when the material is bound
  81416. */
  81417. readonly onBindObservable: Observable<AbstractMesh>;
  81418. /**
  81419. * An observer which watches for bind events
  81420. */
  81421. private _onBindObserver;
  81422. /**
  81423. * Called during a bind event
  81424. */
  81425. onBind: (Mesh: AbstractMesh) => void;
  81426. /**
  81427. * An event triggered when the material is unbound
  81428. */
  81429. readonly onUnBindObservable: Observable<Material>;
  81430. /**
  81431. * Stores the value of the alpha mode
  81432. */
  81433. private _alphaMode;
  81434. /**
  81435. * Sets the value of the alpha mode.
  81436. *
  81437. * | Value | Type | Description |
  81438. * | --- | --- | --- |
  81439. * | 0 | ALPHA_DISABLE | |
  81440. * | 1 | ALPHA_ADD | |
  81441. * | 2 | ALPHA_COMBINE | |
  81442. * | 3 | ALPHA_SUBTRACT | |
  81443. * | 4 | ALPHA_MULTIPLY | |
  81444. * | 5 | ALPHA_MAXIMIZED | |
  81445. * | 6 | ALPHA_ONEONE | |
  81446. * | 7 | ALPHA_PREMULTIPLIED | |
  81447. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  81448. * | 9 | ALPHA_INTERPOLATE | |
  81449. * | 10 | ALPHA_SCREENMODE | |
  81450. *
  81451. */
  81452. /**
  81453. * Gets the value of the alpha mode
  81454. */
  81455. alphaMode: number;
  81456. /**
  81457. * Stores the state of the need depth pre-pass value
  81458. */
  81459. private _needDepthPrePass;
  81460. /**
  81461. * Sets the need depth pre-pass value
  81462. */
  81463. /**
  81464. * Gets the depth pre-pass value
  81465. */
  81466. needDepthPrePass: boolean;
  81467. /**
  81468. * Specifies if depth writing should be disabled
  81469. */
  81470. disableDepthWrite: boolean;
  81471. /**
  81472. * Specifies if depth writing should be forced
  81473. */
  81474. forceDepthWrite: boolean;
  81475. /**
  81476. * Specifies if there should be a separate pass for culling
  81477. */
  81478. separateCullingPass: boolean;
  81479. /**
  81480. * Stores the state specifing if fog should be enabled
  81481. */
  81482. private _fogEnabled;
  81483. /**
  81484. * Sets the state for enabling fog
  81485. */
  81486. /**
  81487. * Gets the value of the fog enabled state
  81488. */
  81489. fogEnabled: boolean;
  81490. /**
  81491. * Stores the size of points
  81492. */
  81493. pointSize: number;
  81494. /**
  81495. * Stores the z offset value
  81496. */
  81497. zOffset: number;
  81498. /**
  81499. * Gets a value specifying if wireframe mode is enabled
  81500. */
  81501. /**
  81502. * Sets the state of wireframe mode
  81503. */
  81504. wireframe: boolean;
  81505. /**
  81506. * Gets the value specifying if point clouds are enabled
  81507. */
  81508. /**
  81509. * Sets the state of point cloud mode
  81510. */
  81511. pointsCloud: boolean;
  81512. /**
  81513. * Gets the material fill mode
  81514. */
  81515. /**
  81516. * Sets the material fill mode
  81517. */
  81518. fillMode: number;
  81519. /**
  81520. * @hidden
  81521. * Stores the effects for the material
  81522. */
  81523. _effect: Nullable<Effect>;
  81524. /**
  81525. * @hidden
  81526. * Specifies if the material was previously ready
  81527. */
  81528. _wasPreviouslyReady: boolean;
  81529. /**
  81530. * Specifies if uniform buffers should be used
  81531. */
  81532. private _useUBO;
  81533. /**
  81534. * Stores a reference to the scene
  81535. */
  81536. private _scene;
  81537. /**
  81538. * Stores the fill mode state
  81539. */
  81540. private _fillMode;
  81541. /**
  81542. * Specifies if the depth write state should be cached
  81543. */
  81544. private _cachedDepthWriteState;
  81545. /**
  81546. * Stores the uniform buffer
  81547. */
  81548. protected _uniformBuffer: UniformBuffer;
  81549. /** @hidden */
  81550. _indexInSceneMaterialArray: number;
  81551. /** @hidden */
  81552. meshMap: Nullable<{
  81553. [id: string]: AbstractMesh | undefined;
  81554. }>;
  81555. /**
  81556. * Creates a material instance
  81557. * @param name defines the name of the material
  81558. * @param scene defines the scene to reference
  81559. * @param doNotAdd specifies if the material should be added to the scene
  81560. */
  81561. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  81562. /**
  81563. * Returns a string representation of the current material
  81564. * @param fullDetails defines a boolean indicating which levels of logging is desired
  81565. * @returns a string with material information
  81566. */
  81567. toString(fullDetails?: boolean): string;
  81568. /**
  81569. * Gets the class name of the material
  81570. * @returns a string with the class name of the material
  81571. */
  81572. getClassName(): string;
  81573. /**
  81574. * Specifies if updates for the material been locked
  81575. */
  81576. readonly isFrozen: boolean;
  81577. /**
  81578. * Locks updates for the material
  81579. */
  81580. freeze(): void;
  81581. /**
  81582. * Unlocks updates for the material
  81583. */
  81584. unfreeze(): void;
  81585. /**
  81586. * Specifies if the material is ready to be used
  81587. * @param mesh defines the mesh to check
  81588. * @param useInstances specifies if instances should be used
  81589. * @returns a boolean indicating if the material is ready to be used
  81590. */
  81591. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  81592. /**
  81593. * Specifies that the submesh is ready to be used
  81594. * @param mesh defines the mesh to check
  81595. * @param subMesh defines which submesh to check
  81596. * @param useInstances specifies that instances should be used
  81597. * @returns a boolean indicating that the submesh is ready or not
  81598. */
  81599. isReadyForSubMesh(mesh: AbstractMesh, subMesh: BaseSubMesh, useInstances?: boolean): boolean;
  81600. /**
  81601. * Returns the material effect
  81602. * @returns the effect associated with the material
  81603. */
  81604. getEffect(): Nullable<Effect>;
  81605. /**
  81606. * Returns the current scene
  81607. * @returns a Scene
  81608. */
  81609. getScene(): Scene;
  81610. /**
  81611. * Specifies if the material will require alpha blending
  81612. * @returns a boolean specifying if alpha blending is needed
  81613. */
  81614. needAlphaBlending(): boolean;
  81615. /**
  81616. * Specifies if the mesh will require alpha blending
  81617. * @param mesh defines the mesh to check
  81618. * @returns a boolean specifying if alpha blending is needed for the mesh
  81619. */
  81620. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  81621. /**
  81622. * Specifies if this material should be rendered in alpha test mode
  81623. * @returns a boolean specifying if an alpha test is needed.
  81624. */
  81625. needAlphaTesting(): boolean;
  81626. /**
  81627. * Gets the texture used for the alpha test
  81628. * @returns the texture to use for alpha testing
  81629. */
  81630. getAlphaTestTexture(): Nullable<BaseTexture>;
  81631. /**
  81632. * Marks the material to indicate that it needs to be re-calculated
  81633. */
  81634. markDirty(): void;
  81635. /** @hidden */
  81636. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  81637. /**
  81638. * Binds the material to the mesh
  81639. * @param world defines the world transformation matrix
  81640. * @param mesh defines the mesh to bind the material to
  81641. */
  81642. bind(world: Matrix, mesh?: Mesh): void;
  81643. /**
  81644. * Binds the submesh to the material
  81645. * @param world defines the world transformation matrix
  81646. * @param mesh defines the mesh containing the submesh
  81647. * @param subMesh defines the submesh to bind the material to
  81648. */
  81649. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  81650. /**
  81651. * Binds the world matrix to the material
  81652. * @param world defines the world transformation matrix
  81653. */
  81654. bindOnlyWorldMatrix(world: Matrix): void;
  81655. /**
  81656. * Binds the scene's uniform buffer to the effect.
  81657. * @param effect defines the effect to bind to the scene uniform buffer
  81658. * @param sceneUbo defines the uniform buffer storing scene data
  81659. */
  81660. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  81661. /**
  81662. * Binds the view matrix to the effect
  81663. * @param effect defines the effect to bind the view matrix to
  81664. */
  81665. bindView(effect: Effect): void;
  81666. /**
  81667. * Binds the view projection matrix to the effect
  81668. * @param effect defines the effect to bind the view projection matrix to
  81669. */
  81670. bindViewProjection(effect: Effect): void;
  81671. /**
  81672. * Specifies if material alpha testing should be turned on for the mesh
  81673. * @param mesh defines the mesh to check
  81674. */
  81675. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  81676. /**
  81677. * Processes to execute after binding the material to a mesh
  81678. * @param mesh defines the rendered mesh
  81679. */
  81680. protected _afterBind(mesh?: Mesh): void;
  81681. /**
  81682. * Unbinds the material from the mesh
  81683. */
  81684. unbind(): void;
  81685. /**
  81686. * Gets the active textures from the material
  81687. * @returns an array of textures
  81688. */
  81689. getActiveTextures(): BaseTexture[];
  81690. /**
  81691. * Specifies if the material uses a texture
  81692. * @param texture defines the texture to check against the material
  81693. * @returns a boolean specifying if the material uses the texture
  81694. */
  81695. hasTexture(texture: BaseTexture): boolean;
  81696. /**
  81697. * Makes a duplicate of the material, and gives it a new name
  81698. * @param name defines the new name for the duplicated material
  81699. * @returns the cloned material
  81700. */
  81701. clone(name: string): Nullable<Material>;
  81702. /**
  81703. * Gets the meshes bound to the material
  81704. * @returns an array of meshes bound to the material
  81705. */
  81706. getBindedMeshes(): AbstractMesh[];
  81707. /**
  81708. * Force shader compilation
  81709. * @param mesh defines the mesh associated with this material
  81710. * @param onCompiled defines a function to execute once the material is compiled
  81711. * @param options defines the options to configure the compilation
  81712. */
  81713. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  81714. clipPlane: boolean;
  81715. }>): void;
  81716. /**
  81717. * Force shader compilation
  81718. * @param mesh defines the mesh that will use this material
  81719. * @param options defines additional options for compiling the shaders
  81720. * @returns a promise that resolves when the compilation completes
  81721. */
  81722. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<{
  81723. clipPlane: boolean;
  81724. }>): Promise<void>;
  81725. private static readonly _ImageProcessingDirtyCallBack;
  81726. private static readonly _TextureDirtyCallBack;
  81727. private static readonly _FresnelDirtyCallBack;
  81728. private static readonly _MiscDirtyCallBack;
  81729. private static readonly _LightsDirtyCallBack;
  81730. private static readonly _AttributeDirtyCallBack;
  81731. private static _FresnelAndMiscDirtyCallBack;
  81732. private static _TextureAndMiscDirtyCallBack;
  81733. private static readonly _DirtyCallbackArray;
  81734. private static readonly _RunDirtyCallBacks;
  81735. /**
  81736. * Marks a define in the material to indicate that it needs to be re-computed
  81737. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  81738. */
  81739. markAsDirty(flag: number): void;
  81740. /**
  81741. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  81742. * @param func defines a function which checks material defines against the submeshes
  81743. */
  81744. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  81745. /**
  81746. * Indicates that image processing needs to be re-calculated for all submeshes
  81747. */
  81748. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  81749. /**
  81750. * Indicates that textures need to be re-calculated for all submeshes
  81751. */
  81752. protected _markAllSubMeshesAsTexturesDirty(): void;
  81753. /**
  81754. * Indicates that fresnel needs to be re-calculated for all submeshes
  81755. */
  81756. protected _markAllSubMeshesAsFresnelDirty(): void;
  81757. /**
  81758. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  81759. */
  81760. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  81761. /**
  81762. * Indicates that lights need to be re-calculated for all submeshes
  81763. */
  81764. protected _markAllSubMeshesAsLightsDirty(): void;
  81765. /**
  81766. * Indicates that attributes need to be re-calculated for all submeshes
  81767. */
  81768. protected _markAllSubMeshesAsAttributesDirty(): void;
  81769. /**
  81770. * Indicates that misc needs to be re-calculated for all submeshes
  81771. */
  81772. protected _markAllSubMeshesAsMiscDirty(): void;
  81773. /**
  81774. * Indicates that textures and misc need to be re-calculated for all submeshes
  81775. */
  81776. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  81777. /**
  81778. * Disposes the material
  81779. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  81780. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  81781. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  81782. */
  81783. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  81784. /** @hidden */
  81785. private releaseVertexArrayObject;
  81786. /**
  81787. * Serializes this material
  81788. * @returns the serialized material object
  81789. */
  81790. serialize(): any;
  81791. /**
  81792. * Creates a material from parsed material data
  81793. * @param parsedMaterial defines parsed material data
  81794. * @param scene defines the hosting scene
  81795. * @param rootUrl defines the root URL to use to load textures
  81796. * @returns a new material
  81797. */
  81798. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  81799. }
  81800. }
  81801. declare module BABYLON {
  81802. /**
  81803. * Base class for submeshes
  81804. */
  81805. export class BaseSubMesh {
  81806. /** @hidden */
  81807. _materialDefines: Nullable<MaterialDefines>;
  81808. /** @hidden */
  81809. _materialEffect: Nullable<Effect>;
  81810. /**
  81811. * Gets associated effect
  81812. */
  81813. readonly effect: Nullable<Effect>;
  81814. /**
  81815. * Sets associated effect (effect used to render this submesh)
  81816. * @param effect defines the effect to associate with
  81817. * @param defines defines the set of defines used to compile this effect
  81818. */
  81819. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  81820. }
  81821. /**
  81822. * Defines a subdivision inside a mesh
  81823. */
  81824. export class SubMesh extends BaseSubMesh implements ICullable {
  81825. /** the material index to use */
  81826. materialIndex: number;
  81827. /** vertex index start */
  81828. verticesStart: number;
  81829. /** vertices count */
  81830. verticesCount: number;
  81831. /** index start */
  81832. indexStart: number;
  81833. /** indices count */
  81834. indexCount: number;
  81835. /** @hidden */
  81836. _linesIndexCount: number;
  81837. private _mesh;
  81838. private _renderingMesh;
  81839. private _boundingInfo;
  81840. private _linesIndexBuffer;
  81841. /** @hidden */
  81842. _lastColliderWorldVertices: Nullable<Vector3[]>;
  81843. /** @hidden */
  81844. _trianglePlanes: Plane[];
  81845. /** @hidden */
  81846. _lastColliderTransformMatrix: Nullable<Matrix>;
  81847. /** @hidden */
  81848. _renderId: number;
  81849. /** @hidden */
  81850. _alphaIndex: number;
  81851. /** @hidden */
  81852. _distanceToCamera: number;
  81853. /** @hidden */
  81854. _id: number;
  81855. private _currentMaterial;
  81856. /**
  81857. * Add a new submesh to a mesh
  81858. * @param materialIndex defines the material index to use
  81859. * @param verticesStart defines vertex index start
  81860. * @param verticesCount defines vertices count
  81861. * @param indexStart defines index start
  81862. * @param indexCount defines indices count
  81863. * @param mesh defines the parent mesh
  81864. * @param renderingMesh defines an optional rendering mesh
  81865. * @param createBoundingBox defines if bounding box should be created for this submesh
  81866. * @returns the new submesh
  81867. */
  81868. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  81869. /**
  81870. * Creates a new submesh
  81871. * @param materialIndex defines the material index to use
  81872. * @param verticesStart defines vertex index start
  81873. * @param verticesCount defines vertices count
  81874. * @param indexStart defines index start
  81875. * @param indexCount defines indices count
  81876. * @param mesh defines the parent mesh
  81877. * @param renderingMesh defines an optional rendering mesh
  81878. * @param createBoundingBox defines if bounding box should be created for this submesh
  81879. */
  81880. constructor(
  81881. /** the material index to use */
  81882. materialIndex: number,
  81883. /** vertex index start */
  81884. verticesStart: number,
  81885. /** vertices count */
  81886. verticesCount: number,
  81887. /** index start */
  81888. indexStart: number,
  81889. /** indices count */
  81890. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean);
  81891. /**
  81892. * Returns true if this submesh covers the entire parent mesh
  81893. * @ignorenaming
  81894. */
  81895. readonly IsGlobal: boolean;
  81896. /**
  81897. * Returns the submesh BoudingInfo object
  81898. * @returns current bounding info (or mesh's one if the submesh is global)
  81899. */
  81900. getBoundingInfo(): BoundingInfo;
  81901. /**
  81902. * Sets the submesh BoundingInfo
  81903. * @param boundingInfo defines the new bounding info to use
  81904. * @returns the SubMesh
  81905. */
  81906. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  81907. /**
  81908. * Returns the mesh of the current submesh
  81909. * @return the parent mesh
  81910. */
  81911. getMesh(): AbstractMesh;
  81912. /**
  81913. * Returns the rendering mesh of the submesh
  81914. * @returns the rendering mesh (could be different from parent mesh)
  81915. */
  81916. getRenderingMesh(): Mesh;
  81917. /**
  81918. * Returns the submesh material
  81919. * @returns null or the current material
  81920. */
  81921. getMaterial(): Nullable<Material>;
  81922. /**
  81923. * Sets a new updated BoundingInfo object to the submesh
  81924. * @returns the SubMesh
  81925. */
  81926. refreshBoundingInfo(): SubMesh;
  81927. /** @hidden */
  81928. _checkCollision(collider: Collider): boolean;
  81929. /**
  81930. * Updates the submesh BoundingInfo
  81931. * @param world defines the world matrix to use to update the bounding info
  81932. * @returns the submesh
  81933. */
  81934. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  81935. /**
  81936. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  81937. * @param frustumPlanes defines the frustum planes
  81938. * @returns true if the submesh is intersecting with the frustum
  81939. */
  81940. isInFrustum(frustumPlanes: Plane[]): boolean;
  81941. /**
  81942. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  81943. * @param frustumPlanes defines the frustum planes
  81944. * @returns true if the submesh is inside the frustum
  81945. */
  81946. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  81947. /**
  81948. * Renders the submesh
  81949. * @param enableAlphaMode defines if alpha needs to be used
  81950. * @returns the submesh
  81951. */
  81952. render(enableAlphaMode: boolean): SubMesh;
  81953. /**
  81954. * @hidden
  81955. */
  81956. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): WebGLBuffer;
  81957. /**
  81958. * Checks if the submesh intersects with a ray
  81959. * @param ray defines the ray to test
  81960. * @returns true is the passed ray intersects the submesh bounding box
  81961. */
  81962. canIntersects(ray: Ray): boolean;
  81963. /**
  81964. * Intersects current submesh with a ray
  81965. * @param ray defines the ray to test
  81966. * @param positions defines mesh's positions array
  81967. * @param indices defines mesh's indices array
  81968. * @param fastCheck defines if only bounding info should be used
  81969. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  81970. * @returns intersection info or null if no intersection
  81971. */
  81972. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  81973. /** @hidden */
  81974. private _intersectLines;
  81975. /** @hidden */
  81976. private _intersectTriangles;
  81977. /** @hidden */
  81978. _rebuild(): void;
  81979. /**
  81980. * Creates a new submesh from the passed mesh
  81981. * @param newMesh defines the new hosting mesh
  81982. * @param newRenderingMesh defines an optional rendering mesh
  81983. * @returns the new submesh
  81984. */
  81985. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  81986. /**
  81987. * Release associated resources
  81988. */
  81989. dispose(): void;
  81990. /**
  81991. * Gets the class name
  81992. * @returns the string "SubMesh".
  81993. */
  81994. getClassName(): string;
  81995. /**
  81996. * Creates a new submesh from indices data
  81997. * @param materialIndex the index of the main mesh material
  81998. * @param startIndex the index where to start the copy in the mesh indices array
  81999. * @param indexCount the number of indices to copy then from the startIndex
  82000. * @param mesh the main mesh to create the submesh from
  82001. * @param renderingMesh the optional rendering mesh
  82002. * @returns a new submesh
  82003. */
  82004. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  82005. }
  82006. }
  82007. declare module BABYLON {
  82008. /**
  82009. * Class used to store geometry data (vertex buffers + index buffer)
  82010. */
  82011. export class Geometry implements IGetSetVerticesData {
  82012. /**
  82013. * Gets or sets the ID of the geometry
  82014. */
  82015. id: string;
  82016. /**
  82017. * Gets or sets the unique ID of the geometry
  82018. */
  82019. uniqueId: number;
  82020. /**
  82021. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82022. */
  82023. delayLoadState: number;
  82024. /**
  82025. * Gets the file containing the data to load when running in delay load state
  82026. */
  82027. delayLoadingFile: Nullable<string>;
  82028. /**
  82029. * Callback called when the geometry is updated
  82030. */
  82031. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  82032. private _scene;
  82033. private _engine;
  82034. private _meshes;
  82035. private _totalVertices;
  82036. /** @hidden */
  82037. _indices: IndicesArray;
  82038. /** @hidden */
  82039. _vertexBuffers: {
  82040. [key: string]: VertexBuffer;
  82041. };
  82042. private _isDisposed;
  82043. private _extend;
  82044. private _boundingBias;
  82045. /** @hidden */
  82046. _delayInfo: Array<string>;
  82047. private _indexBuffer;
  82048. private _indexBufferIsUpdatable;
  82049. /** @hidden */
  82050. _boundingInfo: Nullable<BoundingInfo>;
  82051. /** @hidden */
  82052. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  82053. /** @hidden */
  82054. _softwareSkinningFrameId: number;
  82055. private _vertexArrayObjects;
  82056. private _updatable;
  82057. /** @hidden */
  82058. _positions: Nullable<Vector3[]>;
  82059. /**
  82060. * 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
  82061. */
  82062. /**
  82063. * 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
  82064. */
  82065. boundingBias: Vector2;
  82066. /**
  82067. * Static function used to attach a new empty geometry to a mesh
  82068. * @param mesh defines the mesh to attach the geometry to
  82069. * @returns the new Geometry
  82070. */
  82071. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  82072. /**
  82073. * Creates a new geometry
  82074. * @param id defines the unique ID
  82075. * @param scene defines the hosting scene
  82076. * @param vertexData defines the VertexData used to get geometry data
  82077. * @param updatable defines if geometry must be updatable (false by default)
  82078. * @param mesh defines the mesh that will be associated with the geometry
  82079. */
  82080. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  82081. /**
  82082. * Gets the current extend of the geometry
  82083. */
  82084. readonly extend: {
  82085. minimum: Vector3;
  82086. maximum: Vector3;
  82087. };
  82088. /**
  82089. * Gets the hosting scene
  82090. * @returns the hosting Scene
  82091. */
  82092. getScene(): Scene;
  82093. /**
  82094. * Gets the hosting engine
  82095. * @returns the hosting Engine
  82096. */
  82097. getEngine(): Engine;
  82098. /**
  82099. * Defines if the geometry is ready to use
  82100. * @returns true if the geometry is ready to be used
  82101. */
  82102. isReady(): boolean;
  82103. /**
  82104. * Gets a value indicating that the geometry should not be serialized
  82105. */
  82106. readonly doNotSerialize: boolean;
  82107. /** @hidden */
  82108. _rebuild(): void;
  82109. /**
  82110. * Affects all geometry data in one call
  82111. * @param vertexData defines the geometry data
  82112. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82113. */
  82114. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  82115. /**
  82116. * Set specific vertex data
  82117. * @param kind defines the data kind (Position, normal, etc...)
  82118. * @param data defines the vertex data to use
  82119. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82120. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82121. */
  82122. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  82123. /**
  82124. * Removes a specific vertex data
  82125. * @param kind defines the data kind (Position, normal, etc...)
  82126. */
  82127. removeVerticesData(kind: string): void;
  82128. /**
  82129. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82130. * @param buffer defines the vertex buffer to use
  82131. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82132. */
  82133. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  82134. /**
  82135. * Update a specific vertex buffer
  82136. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  82137. * It will do nothing if the buffer is not updatable
  82138. * @param kind defines the data kind (Position, normal, etc...)
  82139. * @param data defines the data to use
  82140. * @param offset defines the offset in the target buffer where to store the data
  82141. * @param useBytes set to true if the offset is in bytes
  82142. */
  82143. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  82144. /**
  82145. * Update a specific vertex buffer
  82146. * This function will create a new buffer if the current one is not updatable
  82147. * @param kind defines the data kind (Position, normal, etc...)
  82148. * @param data defines the data to use
  82149. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82150. */
  82151. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  82152. private _updateBoundingInfo;
  82153. /** @hidden */
  82154. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<WebGLBuffer>): void;
  82155. /**
  82156. * Gets total number of vertices
  82157. * @returns the total number of vertices
  82158. */
  82159. getTotalVertices(): number;
  82160. /**
  82161. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82162. * @param kind defines the data kind (Position, normal, etc...)
  82163. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82164. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82165. * @returns a float array containing vertex data
  82166. */
  82167. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82168. /**
  82169. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82170. * @param kind defines the data kind (Position, normal, etc...)
  82171. * @returns true if the vertex buffer with the specified kind is updatable
  82172. */
  82173. isVertexBufferUpdatable(kind: string): boolean;
  82174. /**
  82175. * Gets a specific vertex buffer
  82176. * @param kind defines the data kind (Position, normal, etc...)
  82177. * @returns a VertexBuffer
  82178. */
  82179. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  82180. /**
  82181. * Returns all vertex buffers
  82182. * @return an object holding all vertex buffers indexed by kind
  82183. */
  82184. getVertexBuffers(): Nullable<{
  82185. [key: string]: VertexBuffer;
  82186. }>;
  82187. /**
  82188. * Gets a boolean indicating if specific vertex buffer is present
  82189. * @param kind defines the data kind (Position, normal, etc...)
  82190. * @returns true if data is present
  82191. */
  82192. isVerticesDataPresent(kind: string): boolean;
  82193. /**
  82194. * Gets a list of all attached data kinds (Position, normal, etc...)
  82195. * @returns a list of string containing all kinds
  82196. */
  82197. getVerticesDataKinds(): string[];
  82198. /**
  82199. * Update index buffer
  82200. * @param indices defines the indices to store in the index buffer
  82201. * @param offset defines the offset in the target buffer where to store the data
  82202. * @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)
  82203. */
  82204. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  82205. /**
  82206. * Creates a new index buffer
  82207. * @param indices defines the indices to store in the index buffer
  82208. * @param totalVertices defines the total number of vertices (could be null)
  82209. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82210. */
  82211. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  82212. /**
  82213. * Return the total number of indices
  82214. * @returns the total number of indices
  82215. */
  82216. getTotalIndices(): number;
  82217. /**
  82218. * Gets the index buffer array
  82219. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82220. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82221. * @returns the index buffer array
  82222. */
  82223. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82224. /**
  82225. * Gets the index buffer
  82226. * @return the index buffer
  82227. */
  82228. getIndexBuffer(): Nullable<WebGLBuffer>;
  82229. /** @hidden */
  82230. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  82231. /**
  82232. * Release the associated resources for a specific mesh
  82233. * @param mesh defines the source mesh
  82234. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82235. */
  82236. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  82237. /**
  82238. * Apply current geometry to a given mesh
  82239. * @param mesh defines the mesh to apply geometry to
  82240. */
  82241. applyToMesh(mesh: Mesh): void;
  82242. private _updateExtend;
  82243. private _applyToMesh;
  82244. private notifyUpdate;
  82245. /**
  82246. * Load the geometry if it was flagged as delay loaded
  82247. * @param scene defines the hosting scene
  82248. * @param onLoaded defines a callback called when the geometry is loaded
  82249. */
  82250. load(scene: Scene, onLoaded?: () => void): void;
  82251. private _queueLoad;
  82252. /**
  82253. * Invert the geometry to move from a right handed system to a left handed one.
  82254. */
  82255. toLeftHanded(): void;
  82256. /** @hidden */
  82257. _resetPointsArrayCache(): void;
  82258. /** @hidden */
  82259. _generatePointsArray(): boolean;
  82260. /**
  82261. * Gets a value indicating if the geometry is disposed
  82262. * @returns true if the geometry was disposed
  82263. */
  82264. isDisposed(): boolean;
  82265. private _disposeVertexArrayObjects;
  82266. /**
  82267. * Free all associated resources
  82268. */
  82269. dispose(): void;
  82270. /**
  82271. * Clone the current geometry into a new geometry
  82272. * @param id defines the unique ID of the new geometry
  82273. * @returns a new geometry object
  82274. */
  82275. copy(id: string): Geometry;
  82276. /**
  82277. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82278. * @return a JSON representation of the current geometry data (without the vertices data)
  82279. */
  82280. serialize(): any;
  82281. private toNumberArray;
  82282. /**
  82283. * Serialize all vertices data into a JSON oject
  82284. * @returns a JSON representation of the current geometry data
  82285. */
  82286. serializeVerticeData(): any;
  82287. /**
  82288. * Extracts a clone of a mesh geometry
  82289. * @param mesh defines the source mesh
  82290. * @param id defines the unique ID of the new geometry object
  82291. * @returns the new geometry object
  82292. */
  82293. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  82294. /**
  82295. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82296. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82297. * Be aware Math.random() could cause collisions, but:
  82298. * "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"
  82299. * @returns a string containing a new GUID
  82300. */
  82301. static RandomId(): string;
  82302. /** @hidden */
  82303. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  82304. private static _CleanMatricesWeights;
  82305. /**
  82306. * Create a new geometry from persisted data (Using .babylon file format)
  82307. * @param parsedVertexData defines the persisted data
  82308. * @param scene defines the hosting scene
  82309. * @param rootUrl defines the root url to use to load assets (like delayed data)
  82310. * @returns the new geometry object
  82311. */
  82312. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  82313. }
  82314. }
  82315. declare module BABYLON {
  82316. /**
  82317. * Define an interface for all classes that will get and set the data on vertices
  82318. */
  82319. export interface IGetSetVerticesData {
  82320. /**
  82321. * Gets a boolean indicating if specific vertex data is present
  82322. * @param kind defines the vertex data kind to use
  82323. * @returns true is data kind is present
  82324. */
  82325. isVerticesDataPresent(kind: string): boolean;
  82326. /**
  82327. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82328. * @param kind defines the data kind (Position, normal, etc...)
  82329. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82330. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82331. * @returns a float array containing vertex data
  82332. */
  82333. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  82334. /**
  82335. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  82336. * @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.
  82337. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82338. * @returns the indices array or an empty array if the mesh has no geometry
  82339. */
  82340. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  82341. /**
  82342. * Set specific vertex data
  82343. * @param kind defines the data kind (Position, normal, etc...)
  82344. * @param data defines the vertex data to use
  82345. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82346. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82347. */
  82348. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  82349. /**
  82350. * Update a specific associated vertex buffer
  82351. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  82352. * - VertexBuffer.PositionKind
  82353. * - VertexBuffer.UVKind
  82354. * - VertexBuffer.UV2Kind
  82355. * - VertexBuffer.UV3Kind
  82356. * - VertexBuffer.UV4Kind
  82357. * - VertexBuffer.UV5Kind
  82358. * - VertexBuffer.UV6Kind
  82359. * - VertexBuffer.ColorKind
  82360. * - VertexBuffer.MatricesIndicesKind
  82361. * - VertexBuffer.MatricesIndicesExtraKind
  82362. * - VertexBuffer.MatricesWeightsKind
  82363. * - VertexBuffer.MatricesWeightsExtraKind
  82364. * @param data defines the data source
  82365. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  82366. * @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)
  82367. */
  82368. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  82369. /**
  82370. * Creates a new index buffer
  82371. * @param indices defines the indices to store in the index buffer
  82372. * @param totalVertices defines the total number of vertices (could be null)
  82373. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82374. */
  82375. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  82376. }
  82377. /**
  82378. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  82379. */
  82380. export class VertexData {
  82381. /**
  82382. * Mesh side orientation : usually the external or front surface
  82383. */
  82384. static readonly FRONTSIDE: number;
  82385. /**
  82386. * Mesh side orientation : usually the internal or back surface
  82387. */
  82388. static readonly BACKSIDE: number;
  82389. /**
  82390. * Mesh side orientation : both internal and external or front and back surfaces
  82391. */
  82392. static readonly DOUBLESIDE: number;
  82393. /**
  82394. * Mesh side orientation : by default, `FRONTSIDE`
  82395. */
  82396. static readonly DEFAULTSIDE: number;
  82397. /**
  82398. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  82399. */
  82400. positions: Nullable<FloatArray>;
  82401. /**
  82402. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  82403. */
  82404. normals: Nullable<FloatArray>;
  82405. /**
  82406. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  82407. */
  82408. tangents: Nullable<FloatArray>;
  82409. /**
  82410. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82411. */
  82412. uvs: Nullable<FloatArray>;
  82413. /**
  82414. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82415. */
  82416. uvs2: Nullable<FloatArray>;
  82417. /**
  82418. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82419. */
  82420. uvs3: Nullable<FloatArray>;
  82421. /**
  82422. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82423. */
  82424. uvs4: Nullable<FloatArray>;
  82425. /**
  82426. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82427. */
  82428. uvs5: Nullable<FloatArray>;
  82429. /**
  82430. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  82431. */
  82432. uvs6: Nullable<FloatArray>;
  82433. /**
  82434. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  82435. */
  82436. colors: Nullable<FloatArray>;
  82437. /**
  82438. * 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).
  82439. */
  82440. matricesIndices: Nullable<FloatArray>;
  82441. /**
  82442. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  82443. */
  82444. matricesWeights: Nullable<FloatArray>;
  82445. /**
  82446. * An array extending the number of possible indices
  82447. */
  82448. matricesIndicesExtra: Nullable<FloatArray>;
  82449. /**
  82450. * An array extending the number of possible weights when the number of indices is extended
  82451. */
  82452. matricesWeightsExtra: Nullable<FloatArray>;
  82453. /**
  82454. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  82455. */
  82456. indices: Nullable<IndicesArray>;
  82457. /**
  82458. * Uses the passed data array to set the set the values for the specified kind of data
  82459. * @param data a linear array of floating numbers
  82460. * @param kind the type of data that is being set, eg positions, colors etc
  82461. */
  82462. set(data: FloatArray, kind: string): void;
  82463. /**
  82464. * Associates the vertexData to the passed Mesh.
  82465. * Sets it as updatable or not (default `false`)
  82466. * @param mesh the mesh the vertexData is applied to
  82467. * @param updatable when used and having the value true allows new data to update the vertexData
  82468. * @returns the VertexData
  82469. */
  82470. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  82471. /**
  82472. * Associates the vertexData to the passed Geometry.
  82473. * Sets it as updatable or not (default `false`)
  82474. * @param geometry the geometry the vertexData is applied to
  82475. * @param updatable when used and having the value true allows new data to update the vertexData
  82476. * @returns VertexData
  82477. */
  82478. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  82479. /**
  82480. * Updates the associated mesh
  82481. * @param mesh the mesh to be updated
  82482. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82483. * @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
  82484. * @returns VertexData
  82485. */
  82486. updateMesh(mesh: Mesh): VertexData;
  82487. /**
  82488. * Updates the associated geometry
  82489. * @param geometry the geometry to be updated
  82490. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  82491. * @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
  82492. * @returns VertexData.
  82493. */
  82494. updateGeometry(geometry: Geometry): VertexData;
  82495. private _applyTo;
  82496. private _update;
  82497. /**
  82498. * Transforms each position and each normal of the vertexData according to the passed Matrix
  82499. * @param matrix the transforming matrix
  82500. * @returns the VertexData
  82501. */
  82502. transform(matrix: Matrix): VertexData;
  82503. /**
  82504. * Merges the passed VertexData into the current one
  82505. * @param other the VertexData to be merged into the current one
  82506. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  82507. * @returns the modified VertexData
  82508. */
  82509. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  82510. private _mergeElement;
  82511. private _validate;
  82512. /**
  82513. * Serializes the VertexData
  82514. * @returns a serialized object
  82515. */
  82516. serialize(): any;
  82517. /**
  82518. * Extracts the vertexData from a mesh
  82519. * @param mesh the mesh from which to extract the VertexData
  82520. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  82521. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82522. * @returns the object VertexData associated to the passed mesh
  82523. */
  82524. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82525. /**
  82526. * Extracts the vertexData from the geometry
  82527. * @param geometry the geometry from which to extract the VertexData
  82528. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  82529. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  82530. * @returns the object VertexData associated to the passed mesh
  82531. */
  82532. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  82533. private static _ExtractFrom;
  82534. /**
  82535. * Creates the VertexData for a Ribbon
  82536. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  82537. * * pathArray array of paths, each of which an array of successive Vector3
  82538. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  82539. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  82540. * * 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
  82541. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82542. * * 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)
  82543. * * 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)
  82544. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  82545. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  82546. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  82547. * @returns the VertexData of the ribbon
  82548. */
  82549. static CreateRibbon(options: {
  82550. pathArray: Vector3[][];
  82551. closeArray?: boolean;
  82552. closePath?: boolean;
  82553. offset?: number;
  82554. sideOrientation?: number;
  82555. frontUVs?: Vector4;
  82556. backUVs?: Vector4;
  82557. invertUV?: boolean;
  82558. uvs?: Vector2[];
  82559. colors?: Color4[];
  82560. }): VertexData;
  82561. /**
  82562. * Creates the VertexData for a box
  82563. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82564. * * size sets the width, height and depth of the box to the value of size, optional default 1
  82565. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  82566. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  82567. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  82568. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  82569. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  82570. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82571. * * 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)
  82572. * * 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)
  82573. * @returns the VertexData of the box
  82574. */
  82575. static CreateBox(options: {
  82576. size?: number;
  82577. width?: number;
  82578. height?: number;
  82579. depth?: number;
  82580. faceUV?: Vector4[];
  82581. faceColors?: Color4[];
  82582. sideOrientation?: number;
  82583. frontUVs?: Vector4;
  82584. backUVs?: Vector4;
  82585. }): VertexData;
  82586. /**
  82587. * Creates the VertexData for an ellipsoid, defaults to a sphere
  82588. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82589. * * segments sets the number of horizontal strips optional, default 32
  82590. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  82591. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  82592. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  82593. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  82594. * * 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
  82595. * * 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
  82596. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82597. * * 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)
  82598. * * 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)
  82599. * @returns the VertexData of the ellipsoid
  82600. */
  82601. static CreateSphere(options: {
  82602. segments?: number;
  82603. diameter?: number;
  82604. diameterX?: number;
  82605. diameterY?: number;
  82606. diameterZ?: number;
  82607. arc?: number;
  82608. slice?: number;
  82609. sideOrientation?: number;
  82610. frontUVs?: Vector4;
  82611. backUVs?: Vector4;
  82612. }): VertexData;
  82613. /**
  82614. * Creates the VertexData for a cylinder, cone or prism
  82615. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82616. * * height sets the height (y direction) of the cylinder, optional, default 2
  82617. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  82618. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  82619. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  82620. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82621. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  82622. * * 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
  82623. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82624. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82625. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  82626. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  82627. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82628. * * 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)
  82629. * * 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)
  82630. * @returns the VertexData of the cylinder, cone or prism
  82631. */
  82632. static CreateCylinder(options: {
  82633. height?: number;
  82634. diameterTop?: number;
  82635. diameterBottom?: number;
  82636. diameter?: number;
  82637. tessellation?: number;
  82638. subdivisions?: number;
  82639. arc?: number;
  82640. faceColors?: Color4[];
  82641. faceUV?: Vector4[];
  82642. hasRings?: boolean;
  82643. enclose?: boolean;
  82644. sideOrientation?: number;
  82645. frontUVs?: Vector4;
  82646. backUVs?: Vector4;
  82647. }): VertexData;
  82648. /**
  82649. * Creates the VertexData for a torus
  82650. * @param options an object used to set the following optional parameters for the box, required but can be empty
  82651. * * diameter the diameter of the torus, optional default 1
  82652. * * thickness the diameter of the tube forming the torus, optional default 0.5
  82653. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  82654. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82655. * * 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)
  82656. * * 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)
  82657. * @returns the VertexData of the torus
  82658. */
  82659. static CreateTorus(options: {
  82660. diameter?: number;
  82661. thickness?: number;
  82662. tessellation?: number;
  82663. sideOrientation?: number;
  82664. frontUVs?: Vector4;
  82665. backUVs?: Vector4;
  82666. }): VertexData;
  82667. /**
  82668. * Creates the VertexData of the LineSystem
  82669. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  82670. * - lines an array of lines, each line being an array of successive Vector3
  82671. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  82672. * @returns the VertexData of the LineSystem
  82673. */
  82674. static CreateLineSystem(options: {
  82675. lines: Vector3[][];
  82676. colors?: Nullable<Color4[][]>;
  82677. }): VertexData;
  82678. /**
  82679. * Create the VertexData for a DashedLines
  82680. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  82681. * - points an array successive Vector3
  82682. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  82683. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  82684. * - dashNb the intended total number of dashes, optional, default 200
  82685. * @returns the VertexData for the DashedLines
  82686. */
  82687. static CreateDashedLines(options: {
  82688. points: Vector3[];
  82689. dashSize?: number;
  82690. gapSize?: number;
  82691. dashNb?: number;
  82692. }): VertexData;
  82693. /**
  82694. * Creates the VertexData for a Ground
  82695. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82696. * - width the width (x direction) of the ground, optional, default 1
  82697. * - height the height (z direction) of the ground, optional, default 1
  82698. * - subdivisions the number of subdivisions per side, optional, default 1
  82699. * @returns the VertexData of the Ground
  82700. */
  82701. static CreateGround(options: {
  82702. width?: number;
  82703. height?: number;
  82704. subdivisions?: number;
  82705. subdivisionsX?: number;
  82706. subdivisionsY?: number;
  82707. }): VertexData;
  82708. /**
  82709. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  82710. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  82711. * * xmin the ground minimum X coordinate, optional, default -1
  82712. * * zmin the ground minimum Z coordinate, optional, default -1
  82713. * * xmax the ground maximum X coordinate, optional, default 1
  82714. * * zmax the ground maximum Z coordinate, optional, default 1
  82715. * * 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}
  82716. * * 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}
  82717. * @returns the VertexData of the TiledGround
  82718. */
  82719. static CreateTiledGround(options: {
  82720. xmin: number;
  82721. zmin: number;
  82722. xmax: number;
  82723. zmax: number;
  82724. subdivisions?: {
  82725. w: number;
  82726. h: number;
  82727. };
  82728. precision?: {
  82729. w: number;
  82730. h: number;
  82731. };
  82732. }): VertexData;
  82733. /**
  82734. * Creates the VertexData of the Ground designed from a heightmap
  82735. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  82736. * * width the width (x direction) of the ground
  82737. * * height the height (z direction) of the ground
  82738. * * subdivisions the number of subdivisions per side
  82739. * * minHeight the minimum altitude on the ground, optional, default 0
  82740. * * maxHeight the maximum altitude on the ground, optional default 1
  82741. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  82742. * * buffer the array holding the image color data
  82743. * * bufferWidth the width of image
  82744. * * bufferHeight the height of image
  82745. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  82746. * @returns the VertexData of the Ground designed from a heightmap
  82747. */
  82748. static CreateGroundFromHeightMap(options: {
  82749. width: number;
  82750. height: number;
  82751. subdivisions: number;
  82752. minHeight: number;
  82753. maxHeight: number;
  82754. colorFilter: Color3;
  82755. buffer: Uint8Array;
  82756. bufferWidth: number;
  82757. bufferHeight: number;
  82758. alphaFilter: number;
  82759. }): VertexData;
  82760. /**
  82761. * Creates the VertexData for a Plane
  82762. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  82763. * * size sets the width and height of the plane to the value of size, optional default 1
  82764. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  82765. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  82766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82767. * * 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)
  82768. * * 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)
  82769. * @returns the VertexData of the box
  82770. */
  82771. static CreatePlane(options: {
  82772. size?: number;
  82773. width?: number;
  82774. height?: number;
  82775. sideOrientation?: number;
  82776. frontUVs?: Vector4;
  82777. backUVs?: Vector4;
  82778. }): VertexData;
  82779. /**
  82780. * Creates the VertexData of the Disc or regular Polygon
  82781. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  82782. * * radius the radius of the disc, optional default 0.5
  82783. * * tessellation the number of polygon sides, optional, default 64
  82784. * * 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
  82785. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82786. * * 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)
  82787. * * 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)
  82788. * @returns the VertexData of the box
  82789. */
  82790. static CreateDisc(options: {
  82791. radius?: number;
  82792. tessellation?: number;
  82793. arc?: number;
  82794. sideOrientation?: number;
  82795. frontUVs?: Vector4;
  82796. backUVs?: Vector4;
  82797. }): VertexData;
  82798. /**
  82799. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  82800. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  82801. * @param polygon a mesh built from polygonTriangulation.build()
  82802. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82803. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82804. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82805. * @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)
  82806. * @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)
  82807. * @returns the VertexData of the Polygon
  82808. */
  82809. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4): VertexData;
  82810. /**
  82811. * Creates the VertexData of the IcoSphere
  82812. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  82813. * * radius the radius of the IcoSphere, optional default 1
  82814. * * radiusX allows stretching in the x direction, optional, default radius
  82815. * * radiusY allows stretching in the y direction, optional, default radius
  82816. * * radiusZ allows stretching in the z direction, optional, default radius
  82817. * * flat when true creates a flat shaded mesh, optional, default true
  82818. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82820. * * 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)
  82821. * * 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)
  82822. * @returns the VertexData of the IcoSphere
  82823. */
  82824. static CreateIcoSphere(options: {
  82825. radius?: number;
  82826. radiusX?: number;
  82827. radiusY?: number;
  82828. radiusZ?: number;
  82829. flat?: boolean;
  82830. subdivisions?: number;
  82831. sideOrientation?: number;
  82832. frontUVs?: Vector4;
  82833. backUVs?: Vector4;
  82834. }): VertexData;
  82835. /**
  82836. * Creates the VertexData for a Polyhedron
  82837. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  82838. * * type provided types are:
  82839. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  82840. * * 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)
  82841. * * size the size of the IcoSphere, optional default 1
  82842. * * sizeX allows stretching in the x direction, optional, default size
  82843. * * sizeY allows stretching in the y direction, optional, default size
  82844. * * sizeZ allows stretching in the z direction, optional, default size
  82845. * * 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
  82846. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  82847. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  82848. * * flat when true creates a flat shaded mesh, optional, default true
  82849. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  82850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82851. * * 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)
  82852. * * 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)
  82853. * @returns the VertexData of the Polyhedron
  82854. */
  82855. static CreatePolyhedron(options: {
  82856. type?: number;
  82857. size?: number;
  82858. sizeX?: number;
  82859. sizeY?: number;
  82860. sizeZ?: number;
  82861. custom?: any;
  82862. faceUV?: Vector4[];
  82863. faceColors?: Color4[];
  82864. flat?: boolean;
  82865. sideOrientation?: number;
  82866. frontUVs?: Vector4;
  82867. backUVs?: Vector4;
  82868. }): VertexData;
  82869. /**
  82870. * Creates the VertexData for a TorusKnot
  82871. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  82872. * * radius the radius of the torus knot, optional, default 2
  82873. * * tube the thickness of the tube, optional, default 0.5
  82874. * * radialSegments the number of sides on each tube segments, optional, default 32
  82875. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  82876. * * p the number of windings around the z axis, optional, default 2
  82877. * * q the number of windings around the x axis, optional, default 3
  82878. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  82879. * * 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)
  82880. * * 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)
  82881. * @returns the VertexData of the Torus Knot
  82882. */
  82883. static CreateTorusKnot(options: {
  82884. radius?: number;
  82885. tube?: number;
  82886. radialSegments?: number;
  82887. tubularSegments?: number;
  82888. p?: number;
  82889. q?: number;
  82890. sideOrientation?: number;
  82891. frontUVs?: Vector4;
  82892. backUVs?: Vector4;
  82893. }): VertexData;
  82894. /**
  82895. * Compute normals for given positions and indices
  82896. * @param positions an array of vertex positions, [...., x, y, z, ......]
  82897. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  82898. * @param normals an array of vertex normals, [...., x, y, z, ......]
  82899. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  82900. * * facetNormals : optional array of facet normals (vector3)
  82901. * * facetPositions : optional array of facet positions (vector3)
  82902. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  82903. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  82904. * * bInfo : optional bounding info, required for facetPartitioning computation
  82905. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  82906. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  82907. * * useRightHandedSystem: optional boolean to for right handed system computation
  82908. * * depthSort : optional boolean to enable the facet depth sort computation
  82909. * * distanceTo : optional Vector3 to compute the facet depth from this location
  82910. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  82911. */
  82912. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  82913. facetNormals?: any;
  82914. facetPositions?: any;
  82915. facetPartitioning?: any;
  82916. ratio?: number;
  82917. bInfo?: any;
  82918. bbSize?: Vector3;
  82919. subDiv?: any;
  82920. useRightHandedSystem?: boolean;
  82921. depthSort?: boolean;
  82922. distanceTo?: Vector3;
  82923. depthSortedFacets?: any;
  82924. }): void;
  82925. /** @hidden */
  82926. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  82927. /**
  82928. * Applies VertexData created from the imported parameters to the geometry
  82929. * @param parsedVertexData the parsed data from an imported file
  82930. * @param geometry the geometry to apply the VertexData to
  82931. */
  82932. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  82933. }
  82934. }
  82935. declare module BABYLON {
  82936. /**
  82937. * Class containing static functions to help procedurally build meshes
  82938. */
  82939. export class DiscBuilder {
  82940. /**
  82941. * Creates a plane polygonal mesh. By default, this is a disc
  82942. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  82943. * * 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
  82944. * * 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
  82945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  82946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  82947. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  82948. * @param name defines the name of the mesh
  82949. * @param options defines the options used to create the mesh
  82950. * @param scene defines the hosting scene
  82951. * @returns the plane polygonal mesh
  82952. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  82953. */
  82954. static CreateDisc(name: string, options: {
  82955. radius?: number;
  82956. tessellation?: number;
  82957. arc?: number;
  82958. updatable?: boolean;
  82959. sideOrientation?: number;
  82960. frontUVs?: Vector4;
  82961. backUVs?: Vector4;
  82962. }, scene?: Nullable<Scene>): Mesh;
  82963. }
  82964. }
  82965. declare module BABYLON {
  82966. /**
  82967. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  82968. *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.
  82969. * The SPS is also a particle system. It provides some methods to manage the particles.
  82970. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  82971. *
  82972. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  82973. */
  82974. export class SolidParticleSystem implements IDisposable {
  82975. /**
  82976. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  82977. * Example : var p = SPS.particles[i];
  82978. */
  82979. particles: SolidParticle[];
  82980. /**
  82981. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  82982. */
  82983. nbParticles: number;
  82984. /**
  82985. * If the particles must ever face the camera (default false). Useful for planar particles.
  82986. */
  82987. billboard: boolean;
  82988. /**
  82989. * Recompute normals when adding a shape
  82990. */
  82991. recomputeNormals: boolean;
  82992. /**
  82993. * This a counter ofr your own usage. It's not set by any SPS functions.
  82994. */
  82995. counter: number;
  82996. /**
  82997. * The SPS name. This name is also given to the underlying mesh.
  82998. */
  82999. name: string;
  83000. /**
  83001. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  83002. */
  83003. mesh: Mesh;
  83004. /**
  83005. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  83006. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  83007. */
  83008. vars: any;
  83009. /**
  83010. * This array is populated when the SPS is set as 'pickable'.
  83011. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  83012. * Each element of this array is an object `{idx: int, faceId: int}`.
  83013. * `idx` is the picked particle index in the `SPS.particles` array
  83014. * `faceId` is the picked face index counted within this particle.
  83015. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#pickable-particles
  83016. */
  83017. pickedParticles: {
  83018. idx: number;
  83019. faceId: number;
  83020. }[];
  83021. /**
  83022. * This array is populated when `enableDepthSort` is set to true.
  83023. * Each element of this array is an instance of the class DepthSortedParticle.
  83024. */
  83025. depthSortedParticles: DepthSortedParticle[];
  83026. /**
  83027. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  83028. * @hidden
  83029. */
  83030. _bSphereOnly: boolean;
  83031. /**
  83032. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  83033. * @hidden
  83034. */
  83035. _bSphereRadiusFactor: number;
  83036. private _scene;
  83037. private _positions;
  83038. private _indices;
  83039. private _normals;
  83040. private _colors;
  83041. private _uvs;
  83042. private _indices32;
  83043. private _positions32;
  83044. private _normals32;
  83045. private _fixedNormal32;
  83046. private _colors32;
  83047. private _uvs32;
  83048. private _index;
  83049. private _updatable;
  83050. private _pickable;
  83051. private _isVisibilityBoxLocked;
  83052. private _alwaysVisible;
  83053. private _depthSort;
  83054. private _shapeCounter;
  83055. private _copy;
  83056. private _color;
  83057. private _computeParticleColor;
  83058. private _computeParticleTexture;
  83059. private _computeParticleRotation;
  83060. private _computeParticleVertex;
  83061. private _computeBoundingBox;
  83062. private _depthSortParticles;
  83063. private _camera;
  83064. private _mustUnrotateFixedNormals;
  83065. private _particlesIntersect;
  83066. private _needs32Bits;
  83067. /**
  83068. * Creates a SPS (Solid Particle System) object.
  83069. * @param name (String) is the SPS name, this will be the underlying mesh name.
  83070. * @param scene (Scene) is the scene in which the SPS is added.
  83071. * @param options defines the options of the sps e.g.
  83072. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  83073. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  83074. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  83075. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  83076. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  83077. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  83078. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  83079. */
  83080. constructor(name: string, scene: Scene, options?: {
  83081. updatable?: boolean;
  83082. isPickable?: boolean;
  83083. enableDepthSort?: boolean;
  83084. particleIntersection?: boolean;
  83085. boundingSphereOnly?: boolean;
  83086. bSphereRadiusFactor?: number;
  83087. });
  83088. /**
  83089. * Builds the SPS underlying mesh. Returns a standard Mesh.
  83090. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  83091. * @returns the created mesh
  83092. */
  83093. buildMesh(): Mesh;
  83094. /**
  83095. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  83096. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  83097. * Thus the particles generated from `digest()` have their property `position` set yet.
  83098. * @param mesh ( Mesh ) is the mesh to be digested
  83099. * @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
  83100. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  83101. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  83102. * @returns the current SPS
  83103. */
  83104. digest(mesh: Mesh, options?: {
  83105. facetNb?: number;
  83106. number?: number;
  83107. delta?: number;
  83108. }): SolidParticleSystem;
  83109. private _unrotateFixedNormals;
  83110. private _resetCopy;
  83111. private _meshBuilder;
  83112. private _posToShape;
  83113. private _uvsToShapeUV;
  83114. private _addParticle;
  83115. /**
  83116. * Adds some particles to the SPS from the model shape. Returns the shape id.
  83117. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  83118. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  83119. * @param nb (positive integer) the number of particles to be created from this model
  83120. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  83121. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  83122. * @returns the number of shapes in the system
  83123. */
  83124. addShape(mesh: Mesh, nb: number, options?: {
  83125. positionFunction?: any;
  83126. vertexFunction?: any;
  83127. }): number;
  83128. private _rebuildParticle;
  83129. /**
  83130. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  83131. * @returns the SPS.
  83132. */
  83133. rebuildMesh(): SolidParticleSystem;
  83134. /**
  83135. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  83136. * This method calls `updateParticle()` for each particle of the SPS.
  83137. * For an animated SPS, it is usually called within the render loop.
  83138. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  83139. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  83140. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  83141. * @returns the SPS.
  83142. */
  83143. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  83144. /**
  83145. * Disposes the SPS.
  83146. */
  83147. dispose(): void;
  83148. /**
  83149. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  83150. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83151. * @returns the SPS.
  83152. */
  83153. refreshVisibleSize(): SolidParticleSystem;
  83154. /**
  83155. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  83156. * @param size the size (float) of the visibility box
  83157. * note : this doesn't lock the SPS mesh bounding box.
  83158. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83159. */
  83160. setVisibilityBox(size: number): void;
  83161. /**
  83162. * Gets whether the SPS as always visible or not
  83163. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83164. */
  83165. /**
  83166. * Sets the SPS as always visible or not
  83167. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83168. */
  83169. isAlwaysVisible: boolean;
  83170. /**
  83171. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83172. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83173. */
  83174. /**
  83175. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  83176. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  83177. */
  83178. isVisibilityBoxLocked: boolean;
  83179. /**
  83180. * Tells to `setParticles()` to compute the particle rotations or not.
  83181. * Default value : true. The SPS is faster when it's set to false.
  83182. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83183. */
  83184. /**
  83185. * Gets if `setParticles()` computes the particle rotations or not.
  83186. * Default value : true. The SPS is faster when it's set to false.
  83187. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  83188. */
  83189. computeParticleRotation: boolean;
  83190. /**
  83191. * Tells to `setParticles()` to compute the particle colors or not.
  83192. * Default value : true. The SPS is faster when it's set to false.
  83193. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83194. */
  83195. /**
  83196. * Gets if `setParticles()` computes the particle colors or not.
  83197. * Default value : true. The SPS is faster when it's set to false.
  83198. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  83199. */
  83200. computeParticleColor: boolean;
  83201. /**
  83202. * Gets if `setParticles()` computes the particle textures or not.
  83203. * Default value : true. The SPS is faster when it's set to false.
  83204. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  83205. */
  83206. computeParticleTexture: boolean;
  83207. /**
  83208. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  83209. * Default value : false. The SPS is faster when it's set to false.
  83210. * Note : the particle custom vertex positions aren't stored values.
  83211. */
  83212. /**
  83213. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  83214. * Default value : false. The SPS is faster when it's set to false.
  83215. * Note : the particle custom vertex positions aren't stored values.
  83216. */
  83217. computeParticleVertex: boolean;
  83218. /**
  83219. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  83220. */
  83221. /**
  83222. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  83223. */
  83224. computeBoundingBox: boolean;
  83225. /**
  83226. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  83227. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83228. * Default : `true`
  83229. */
  83230. /**
  83231. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  83232. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  83233. * Default : `true`
  83234. */
  83235. depthSortParticles: boolean;
  83236. /**
  83237. * This function does nothing. It may be overwritten to set all the particle first values.
  83238. * The SPS doesn't call this function, you may have to call it by your own.
  83239. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83240. */
  83241. initParticles(): void;
  83242. /**
  83243. * This function does nothing. It may be overwritten to recycle a particle.
  83244. * The SPS doesn't call this function, you may have to call it by your own.
  83245. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83246. * @param particle The particle to recycle
  83247. * @returns the recycled particle
  83248. */
  83249. recycleParticle(particle: SolidParticle): SolidParticle;
  83250. /**
  83251. * Updates a particle : this function should be overwritten by the user.
  83252. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  83253. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  83254. * @example : just set a particle position or velocity and recycle conditions
  83255. * @param particle The particle to update
  83256. * @returns the updated particle
  83257. */
  83258. updateParticle(particle: SolidParticle): SolidParticle;
  83259. /**
  83260. * Updates a vertex of a particle : it can be overwritten by the user.
  83261. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  83262. * @param particle the current particle
  83263. * @param vertex the current index of the current particle
  83264. * @param pt the index of the current vertex in the particle shape
  83265. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  83266. * @example : just set a vertex particle position
  83267. * @returns the updated vertex
  83268. */
  83269. updateParticleVertex(particle: SolidParticle, vertex: Vector3, pt: number): Vector3;
  83270. /**
  83271. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  83272. * This does nothing and may be overwritten by the user.
  83273. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83274. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83275. * @param update the boolean update value actually passed to setParticles()
  83276. */
  83277. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83278. /**
  83279. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  83280. * This will be passed three parameters.
  83281. * This does nothing and may be overwritten by the user.
  83282. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83283. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  83284. * @param update the boolean update value actually passed to setParticles()
  83285. */
  83286. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  83287. }
  83288. }
  83289. declare module BABYLON {
  83290. /**
  83291. * Represents one particle of a solid particle system.
  83292. */
  83293. export class SolidParticle {
  83294. /**
  83295. * particle global index
  83296. */
  83297. idx: number;
  83298. /**
  83299. * The color of the particle
  83300. */
  83301. color: Nullable<Color4>;
  83302. /**
  83303. * The world space position of the particle.
  83304. */
  83305. position: Vector3;
  83306. /**
  83307. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  83308. */
  83309. rotation: Vector3;
  83310. /**
  83311. * The world space rotation quaternion of the particle.
  83312. */
  83313. rotationQuaternion: Nullable<Quaternion>;
  83314. /**
  83315. * The scaling of the particle.
  83316. */
  83317. scaling: Vector3;
  83318. /**
  83319. * The uvs of the particle.
  83320. */
  83321. uvs: Vector4;
  83322. /**
  83323. * The current speed of the particle.
  83324. */
  83325. velocity: Vector3;
  83326. /**
  83327. * The pivot point in the particle local space.
  83328. */
  83329. pivot: Vector3;
  83330. /**
  83331. * Must the particle be translated from its pivot point in its local space ?
  83332. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  83333. * Default : false
  83334. */
  83335. translateFromPivot: boolean;
  83336. /**
  83337. * Is the particle active or not ?
  83338. */
  83339. alive: boolean;
  83340. /**
  83341. * Is the particle visible or not ?
  83342. */
  83343. isVisible: boolean;
  83344. /**
  83345. * Index of this particle in the global "positions" array (Internal use)
  83346. * @hidden
  83347. */
  83348. _pos: number;
  83349. /**
  83350. * @hidden Index of this particle in the global "indices" array (Internal use)
  83351. */
  83352. _ind: number;
  83353. /**
  83354. * @hidden ModelShape of this particle (Internal use)
  83355. */
  83356. _model: ModelShape;
  83357. /**
  83358. * ModelShape id of this particle
  83359. */
  83360. shapeId: number;
  83361. /**
  83362. * Index of the particle in its shape id (Internal use)
  83363. */
  83364. idxInShape: number;
  83365. /**
  83366. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  83367. */
  83368. _modelBoundingInfo: BoundingInfo;
  83369. /**
  83370. * @hidden Particle BoundingInfo object (Internal use)
  83371. */
  83372. _boundingInfo: BoundingInfo;
  83373. /**
  83374. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  83375. */
  83376. _sps: SolidParticleSystem;
  83377. /**
  83378. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  83379. */
  83380. _stillInvisible: boolean;
  83381. /**
  83382. * @hidden Last computed particle rotation matrix
  83383. */
  83384. _rotationMatrix: number[];
  83385. /**
  83386. * Parent particle Id, if any.
  83387. * Default null.
  83388. */
  83389. parentId: Nullable<number>;
  83390. /**
  83391. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  83392. * The possible values are :
  83393. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83394. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83395. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83396. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83397. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83398. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  83399. * */
  83400. cullingStrategy: number;
  83401. /**
  83402. * @hidden Internal global position in the SPS.
  83403. */
  83404. _globalPosition: Vector3;
  83405. /**
  83406. * Creates a Solid Particle object.
  83407. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  83408. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  83409. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  83410. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  83411. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  83412. * @param shapeId (integer) is the model shape identifier in the SPS.
  83413. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  83414. * @param sps defines the sps it is associated to
  83415. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  83416. */
  83417. constructor(particleIndex: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>);
  83418. /**
  83419. * Legacy support, changed scale to scaling
  83420. */
  83421. /**
  83422. * Legacy support, changed scale to scaling
  83423. */
  83424. scale: Vector3;
  83425. /**
  83426. * Legacy support, changed quaternion to rotationQuaternion
  83427. */
  83428. /**
  83429. * Legacy support, changed quaternion to rotationQuaternion
  83430. */
  83431. quaternion: Nullable<Quaternion>;
  83432. /**
  83433. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  83434. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  83435. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  83436. * @returns true if it intersects
  83437. */
  83438. intersectsMesh(target: Mesh | SolidParticle): boolean;
  83439. /**
  83440. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  83441. * A particle is in the frustum if its bounding box intersects the frustum
  83442. * @param frustumPlanes defines the frustum to test
  83443. * @returns true if the particle is in the frustum planes
  83444. */
  83445. isInFrustum(frustumPlanes: Plane[]): boolean;
  83446. /**
  83447. * get the rotation matrix of the particle
  83448. * @hidden
  83449. */
  83450. getRotationMatrix(m: Matrix): void;
  83451. }
  83452. /**
  83453. * Represents the shape of the model used by one particle of a solid particle system.
  83454. * SPS internal tool, don't use it manually.
  83455. */
  83456. export class ModelShape {
  83457. /**
  83458. * The shape id
  83459. * @hidden
  83460. */
  83461. shapeID: number;
  83462. /**
  83463. * flat array of model positions (internal use)
  83464. * @hidden
  83465. */
  83466. _shape: Vector3[];
  83467. /**
  83468. * flat array of model UVs (internal use)
  83469. * @hidden
  83470. */
  83471. _shapeUV: number[];
  83472. /**
  83473. * length of the shape in the model indices array (internal use)
  83474. * @hidden
  83475. */
  83476. _indicesLength: number;
  83477. /**
  83478. * Custom position function (internal use)
  83479. * @hidden
  83480. */
  83481. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  83482. /**
  83483. * Custom vertex function (internal use)
  83484. * @hidden
  83485. */
  83486. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  83487. /**
  83488. * 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.
  83489. * SPS internal tool, don't use it manually.
  83490. * @hidden
  83491. */
  83492. 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>);
  83493. }
  83494. /**
  83495. * Represents a Depth Sorted Particle in the solid particle system.
  83496. */
  83497. export class DepthSortedParticle {
  83498. /**
  83499. * Index of the particle in the "indices" array
  83500. */
  83501. ind: number;
  83502. /**
  83503. * Length of the particle shape in the "indices" array
  83504. */
  83505. indicesLength: number;
  83506. /**
  83507. * Squared distance from the particle to the camera
  83508. */
  83509. sqDistance: number;
  83510. }
  83511. }
  83512. declare module BABYLON {
  83513. /**
  83514. * Class used to store all common mesh properties
  83515. */
  83516. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  83517. /** No occlusion */
  83518. static OCCLUSION_TYPE_NONE: number;
  83519. /** Occlusion set to optimisitic */
  83520. static OCCLUSION_TYPE_OPTIMISTIC: number;
  83521. /** Occlusion set to strict */
  83522. static OCCLUSION_TYPE_STRICT: number;
  83523. /** Use an accurante occlusion algorithm */
  83524. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  83525. /** Use a conservative occlusion algorithm */
  83526. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  83527. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  83528. * Test order :
  83529. * Is the bounding sphere outside the frustum ?
  83530. * If not, are the bounding box vertices outside the frustum ?
  83531. * It not, then the cullable object is in the frustum.
  83532. */
  83533. static readonly CULLINGSTRATEGY_STANDARD: number;
  83534. /** Culling strategy : Bounding Sphere Only.
  83535. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  83536. * It's also less accurate than the standard because some not visible objects can still be selected.
  83537. * Test : is the bounding sphere outside the frustum ?
  83538. * If not, then the cullable object is in the frustum.
  83539. */
  83540. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  83541. /** Culling strategy : Optimistic Inclusion.
  83542. * This in an inclusion test first, then the standard exclusion test.
  83543. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  83544. * 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.
  83545. * Anyway, it's as accurate as the standard strategy.
  83546. * Test :
  83547. * Is the cullable object bounding sphere center in the frustum ?
  83548. * If not, apply the default culling strategy.
  83549. */
  83550. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  83551. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  83552. * This in an inclusion test first, then the bounding sphere only exclusion test.
  83553. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  83554. * 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.
  83555. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  83556. * Test :
  83557. * Is the cullable object bounding sphere center in the frustum ?
  83558. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  83559. */
  83560. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  83561. /**
  83562. * No billboard
  83563. */
  83564. static readonly BILLBOARDMODE_NONE: number;
  83565. /** Billboard on X axis */
  83566. static readonly BILLBOARDMODE_X: number;
  83567. /** Billboard on Y axis */
  83568. static readonly BILLBOARDMODE_Y: number;
  83569. /** Billboard on Z axis */
  83570. static readonly BILLBOARDMODE_Z: number;
  83571. /** Billboard on all axes */
  83572. static readonly BILLBOARDMODE_ALL: number;
  83573. private _facetData;
  83574. /**
  83575. * The culling strategy to use to check whether the mesh must be rendered or not.
  83576. * This value can be changed at any time and will be used on the next render mesh selection.
  83577. * The possible values are :
  83578. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  83579. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  83580. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  83581. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  83582. * Please read each static variable documentation to get details about the culling process.
  83583. * */
  83584. cullingStrategy: number;
  83585. /**
  83586. * Gets the number of facets in the mesh
  83587. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83588. */
  83589. readonly facetNb: number;
  83590. /**
  83591. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  83592. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83593. */
  83594. partitioningSubdivisions: number;
  83595. /**
  83596. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  83597. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  83598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  83599. */
  83600. partitioningBBoxRatio: number;
  83601. /**
  83602. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  83603. * Works only for updatable meshes.
  83604. * Doesn't work with multi-materials
  83605. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83606. */
  83607. mustDepthSortFacets: boolean;
  83608. /**
  83609. * The location (Vector3) where the facet depth sort must be computed from.
  83610. * By default, the active camera position.
  83611. * Used only when facet depth sort is enabled
  83612. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  83613. */
  83614. facetDepthSortFrom: Vector3;
  83615. /**
  83616. * gets a boolean indicating if facetData is enabled
  83617. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  83618. */
  83619. readonly isFacetDataEnabled: boolean;
  83620. /** @hidden */
  83621. _updateNonUniformScalingState(value: boolean): boolean;
  83622. /**
  83623. * An event triggered when this mesh collides with another one
  83624. */
  83625. onCollideObservable: Observable<AbstractMesh>;
  83626. private _onCollideObserver;
  83627. /** Set a function to call when this mesh collides with another one */
  83628. onCollide: () => void;
  83629. /**
  83630. * An event triggered when the collision's position changes
  83631. */
  83632. onCollisionPositionChangeObservable: Observable<Vector3>;
  83633. private _onCollisionPositionChangeObserver;
  83634. /** Set a function to call when the collision's position changes */
  83635. onCollisionPositionChange: () => void;
  83636. /**
  83637. * An event triggered when material is changed
  83638. */
  83639. onMaterialChangedObservable: Observable<AbstractMesh>;
  83640. /**
  83641. * Gets or sets the orientation for POV movement & rotation
  83642. */
  83643. definedFacingForward: boolean;
  83644. /** @hidden */
  83645. _occlusionQuery: Nullable<WebGLQuery>;
  83646. private _visibility;
  83647. /** @hidden */
  83648. _isActive: boolean;
  83649. /** @hidden */
  83650. _renderingGroup: Nullable<RenderingGroup>;
  83651. /**
  83652. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83653. */
  83654. /**
  83655. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  83656. */
  83657. visibility: number;
  83658. /** Gets or sets the alpha index used to sort transparent meshes
  83659. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  83660. */
  83661. alphaIndex: number;
  83662. /**
  83663. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  83664. */
  83665. isVisible: boolean;
  83666. /**
  83667. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  83668. */
  83669. isPickable: boolean;
  83670. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  83671. showSubMeshesBoundingBox: boolean;
  83672. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  83673. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  83674. */
  83675. isBlocker: boolean;
  83676. /**
  83677. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  83678. */
  83679. enablePointerMoveEvents: boolean;
  83680. /**
  83681. * Specifies the rendering group id for this mesh (0 by default)
  83682. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  83683. */
  83684. renderingGroupId: number;
  83685. private _material;
  83686. /** Gets or sets current material */
  83687. material: Nullable<Material>;
  83688. private _receiveShadows;
  83689. /**
  83690. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  83691. * @see http://doc.babylonjs.com/babylon101/shadows
  83692. */
  83693. receiveShadows: boolean;
  83694. /** Defines color to use when rendering outline */
  83695. outlineColor: Color3;
  83696. /** Define width to use when rendering outline */
  83697. outlineWidth: number;
  83698. /** Defines color to use when rendering overlay */
  83699. overlayColor: Color3;
  83700. /** Defines alpha to use when rendering overlay */
  83701. overlayAlpha: number;
  83702. private _hasVertexAlpha;
  83703. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  83704. hasVertexAlpha: boolean;
  83705. private _useVertexColors;
  83706. /** 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) */
  83707. useVertexColors: boolean;
  83708. private _computeBonesUsingShaders;
  83709. /**
  83710. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  83711. */
  83712. computeBonesUsingShaders: boolean;
  83713. private _numBoneInfluencers;
  83714. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  83715. numBoneInfluencers: number;
  83716. private _applyFog;
  83717. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  83718. applyFog: boolean;
  83719. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  83720. useOctreeForRenderingSelection: boolean;
  83721. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  83722. useOctreeForPicking: boolean;
  83723. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  83724. useOctreeForCollisions: boolean;
  83725. private _layerMask;
  83726. /**
  83727. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  83728. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  83729. */
  83730. layerMask: number;
  83731. /**
  83732. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  83733. */
  83734. alwaysSelectAsActiveMesh: boolean;
  83735. /**
  83736. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  83737. */
  83738. doNotSyncBoundingInfo: boolean;
  83739. /**
  83740. * Gets or sets the current action manager
  83741. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  83742. */
  83743. actionManager: Nullable<AbstractActionManager>;
  83744. private _checkCollisions;
  83745. private _collisionMask;
  83746. private _collisionGroup;
  83747. /**
  83748. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  83749. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83750. */
  83751. ellipsoid: Vector3;
  83752. /**
  83753. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  83754. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  83755. */
  83756. ellipsoidOffset: Vector3;
  83757. private _collider;
  83758. private _oldPositionForCollisions;
  83759. private _diffPositionForCollisions;
  83760. /**
  83761. * Gets or sets a collision mask used to mask collisions (default is -1).
  83762. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83763. */
  83764. collisionMask: number;
  83765. /**
  83766. * Gets or sets the current collision group mask (-1 by default).
  83767. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  83768. */
  83769. collisionGroup: number;
  83770. /**
  83771. * Defines edge width used when edgesRenderer is enabled
  83772. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83773. */
  83774. edgesWidth: number;
  83775. /**
  83776. * Defines edge color used when edgesRenderer is enabled
  83777. * @see https://www.babylonjs-playground.com/#10OJSG#13
  83778. */
  83779. edgesColor: Color4;
  83780. /** @hidden */
  83781. _edgesRenderer: Nullable<IEdgesRenderer>;
  83782. /** @hidden */
  83783. _masterMesh: Nullable<AbstractMesh>;
  83784. /** @hidden */
  83785. _boundingInfo: Nullable<BoundingInfo>;
  83786. /** @hidden */
  83787. _renderId: number;
  83788. /**
  83789. * Gets or sets the list of subMeshes
  83790. * @see http://doc.babylonjs.com/how_to/multi_materials
  83791. */
  83792. subMeshes: SubMesh[];
  83793. /** @hidden */
  83794. _intersectionsInProgress: AbstractMesh[];
  83795. /** @hidden */
  83796. _unIndexed: boolean;
  83797. /** @hidden */
  83798. _lightSources: Light[];
  83799. /** @hidden */
  83800. readonly _positions: Nullable<Vector3[]>;
  83801. /** @hidden */
  83802. _waitingActions: Nullable<any>;
  83803. /** @hidden */
  83804. _waitingFreezeWorldMatrix: Nullable<boolean>;
  83805. private _skeleton;
  83806. /** @hidden */
  83807. _bonesTransformMatrices: Nullable<Float32Array>;
  83808. /**
  83809. * Gets or sets a skeleton to apply skining transformations
  83810. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  83811. */
  83812. skeleton: Nullable<Skeleton>;
  83813. /**
  83814. * An event triggered when the mesh is rebuilt.
  83815. */
  83816. onRebuildObservable: Observable<AbstractMesh>;
  83817. /**
  83818. * Creates a new AbstractMesh
  83819. * @param name defines the name of the mesh
  83820. * @param scene defines the hosting scene
  83821. */
  83822. constructor(name: string, scene?: Nullable<Scene>);
  83823. /**
  83824. * Returns the string "AbstractMesh"
  83825. * @returns "AbstractMesh"
  83826. */
  83827. getClassName(): string;
  83828. /**
  83829. * Gets a string representation of the current mesh
  83830. * @param fullDetails defines a boolean indicating if full details must be included
  83831. * @returns a string representation of the current mesh
  83832. */
  83833. toString(fullDetails?: boolean): string;
  83834. /**
  83835. * @hidden
  83836. */
  83837. protected _getEffectiveParent(): Nullable<Node>;
  83838. /** @hidden */
  83839. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  83840. /** @hidden */
  83841. _rebuild(): void;
  83842. /** @hidden */
  83843. _resyncLightSources(): void;
  83844. /** @hidden */
  83845. _resyncLighSource(light: Light): void;
  83846. /** @hidden */
  83847. _unBindEffect(): void;
  83848. /** @hidden */
  83849. _removeLightSource(light: Light): void;
  83850. private _markSubMeshesAsDirty;
  83851. /** @hidden */
  83852. _markSubMeshesAsLightDirty(): void;
  83853. /** @hidden */
  83854. _markSubMeshesAsAttributesDirty(): void;
  83855. /** @hidden */
  83856. _markSubMeshesAsMiscDirty(): void;
  83857. /**
  83858. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  83859. */
  83860. scaling: Vector3;
  83861. /**
  83862. * Returns true if the mesh is blocked. Implemented by child classes
  83863. */
  83864. readonly isBlocked: boolean;
  83865. /**
  83866. * Returns the mesh itself by default. Implemented by child classes
  83867. * @param camera defines the camera to use to pick the right LOD level
  83868. * @returns the currentAbstractMesh
  83869. */
  83870. getLOD(camera: Camera): Nullable<AbstractMesh>;
  83871. /**
  83872. * Returns 0 by default. Implemented by child classes
  83873. * @returns an integer
  83874. */
  83875. getTotalVertices(): number;
  83876. /**
  83877. * Returns a positive integer : the total number of indices in this mesh geometry.
  83878. * @returns the numner of indices or zero if the mesh has no geometry.
  83879. */
  83880. getTotalIndices(): number;
  83881. /**
  83882. * Returns null by default. Implemented by child classes
  83883. * @returns null
  83884. */
  83885. getIndices(): Nullable<IndicesArray>;
  83886. /**
  83887. * Returns the array of the requested vertex data kind. Implemented by child classes
  83888. * @param kind defines the vertex data kind to use
  83889. * @returns null
  83890. */
  83891. getVerticesData(kind: string): Nullable<FloatArray>;
  83892. /**
  83893. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83894. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83895. * Note that a new underlying VertexBuffer object is created each call.
  83896. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83897. * @param kind defines vertex data kind:
  83898. * * VertexBuffer.PositionKind
  83899. * * VertexBuffer.UVKind
  83900. * * VertexBuffer.UV2Kind
  83901. * * VertexBuffer.UV3Kind
  83902. * * VertexBuffer.UV4Kind
  83903. * * VertexBuffer.UV5Kind
  83904. * * VertexBuffer.UV6Kind
  83905. * * VertexBuffer.ColorKind
  83906. * * VertexBuffer.MatricesIndicesKind
  83907. * * VertexBuffer.MatricesIndicesExtraKind
  83908. * * VertexBuffer.MatricesWeightsKind
  83909. * * VertexBuffer.MatricesWeightsExtraKind
  83910. * @param data defines the data source
  83911. * @param updatable defines if the data must be flagged as updatable (or static)
  83912. * @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
  83913. * @returns the current mesh
  83914. */
  83915. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  83916. /**
  83917. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83918. * If the mesh has no geometry, it is simply returned as it is.
  83919. * @param kind defines vertex data kind:
  83920. * * VertexBuffer.PositionKind
  83921. * * VertexBuffer.UVKind
  83922. * * VertexBuffer.UV2Kind
  83923. * * VertexBuffer.UV3Kind
  83924. * * VertexBuffer.UV4Kind
  83925. * * VertexBuffer.UV5Kind
  83926. * * VertexBuffer.UV6Kind
  83927. * * VertexBuffer.ColorKind
  83928. * * VertexBuffer.MatricesIndicesKind
  83929. * * VertexBuffer.MatricesIndicesExtraKind
  83930. * * VertexBuffer.MatricesWeightsKind
  83931. * * VertexBuffer.MatricesWeightsExtraKind
  83932. * @param data defines the data source
  83933. * @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
  83934. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  83935. * @returns the current mesh
  83936. */
  83937. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  83938. /**
  83939. * Sets the mesh indices,
  83940. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83941. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  83942. * @param totalVertices Defines the total number of vertices
  83943. * @returns the current mesh
  83944. */
  83945. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  83946. /**
  83947. * Gets a boolean indicating if specific vertex data is present
  83948. * @param kind defines the vertex data kind to use
  83949. * @returns true is data kind is present
  83950. */
  83951. isVerticesDataPresent(kind: string): boolean;
  83952. /**
  83953. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  83954. * @returns a BoundingInfo
  83955. */
  83956. getBoundingInfo(): BoundingInfo;
  83957. /**
  83958. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  83959. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  83960. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  83961. * @returns the current mesh
  83962. */
  83963. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean): AbstractMesh;
  83964. /**
  83965. * Overwrite the current bounding info
  83966. * @param boundingInfo defines the new bounding info
  83967. * @returns the current mesh
  83968. */
  83969. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  83970. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  83971. readonly useBones: boolean;
  83972. /** @hidden */
  83973. _preActivate(): void;
  83974. /** @hidden */
  83975. _preActivateForIntermediateRendering(renderId: number): void;
  83976. /** @hidden */
  83977. _activate(renderId: number): boolean;
  83978. /** @hidden */
  83979. _freeze(): void;
  83980. /** @hidden */
  83981. _unFreeze(): void;
  83982. /**
  83983. * Gets the current world matrix
  83984. * @returns a Matrix
  83985. */
  83986. getWorldMatrix(): Matrix;
  83987. /** @hidden */
  83988. _getWorldMatrixDeterminant(): number;
  83989. /**
  83990. * Perform relative position change from the point of view of behind the front of the mesh.
  83991. * This is performed taking into account the meshes current rotation, so you do not have to care.
  83992. * Supports definition of mesh facing forward or backward
  83993. * @param amountRight defines the distance on the right axis
  83994. * @param amountUp defines the distance on the up axis
  83995. * @param amountForward defines the distance on the forward axis
  83996. * @returns the current mesh
  83997. */
  83998. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  83999. /**
  84000. * Calculate relative position change from the point of view of behind the front of the mesh.
  84001. * This is performed taking into account the meshes current rotation, so you do not have to care.
  84002. * Supports definition of mesh facing forward or backward
  84003. * @param amountRight defines the distance on the right axis
  84004. * @param amountUp defines the distance on the up axis
  84005. * @param amountForward defines the distance on the forward axis
  84006. * @returns the new displacement vector
  84007. */
  84008. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  84009. /**
  84010. * Perform relative rotation change from the point of view of behind the front of the mesh.
  84011. * Supports definition of mesh facing forward or backward
  84012. * @param flipBack defines the flip
  84013. * @param twirlClockwise defines the twirl
  84014. * @param tiltRight defines the tilt
  84015. * @returns the current mesh
  84016. */
  84017. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  84018. /**
  84019. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  84020. * Supports definition of mesh facing forward or backward.
  84021. * @param flipBack defines the flip
  84022. * @param twirlClockwise defines the twirl
  84023. * @param tiltRight defines the tilt
  84024. * @returns the new rotation vector
  84025. */
  84026. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  84027. /**
  84028. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84029. * This means the mesh underlying bounding box and sphere are recomputed.
  84030. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84031. * @returns the current mesh
  84032. */
  84033. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  84034. /** @hidden */
  84035. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  84036. /** @hidden */
  84037. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  84038. /** @hidden */
  84039. _updateBoundingInfo(): AbstractMesh;
  84040. /** @hidden */
  84041. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  84042. /** @hidden */
  84043. protected _afterComputeWorldMatrix(): void;
  84044. /** @hidden */
  84045. readonly _effectiveMesh: AbstractMesh;
  84046. /**
  84047. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  84048. * A mesh is in the frustum if its bounding box intersects the frustum
  84049. * @param frustumPlanes defines the frustum to test
  84050. * @returns true if the mesh is in the frustum planes
  84051. */
  84052. isInFrustum(frustumPlanes: Plane[]): boolean;
  84053. /**
  84054. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  84055. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  84056. * @param frustumPlanes defines the frustum to test
  84057. * @returns true if the mesh is completely in the frustum planes
  84058. */
  84059. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  84060. /**
  84061. * True if the mesh intersects another mesh or a SolidParticle object
  84062. * @param mesh defines a target mesh or SolidParticle to test
  84063. * @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)
  84064. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  84065. * @returns true if there is an intersection
  84066. */
  84067. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  84068. /**
  84069. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  84070. * @param point defines the point to test
  84071. * @returns true if there is an intersection
  84072. */
  84073. intersectsPoint(point: Vector3): boolean;
  84074. /**
  84075. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  84076. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84077. */
  84078. checkCollisions: boolean;
  84079. /**
  84080. * Gets Collider object used to compute collisions (not physics)
  84081. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84082. */
  84083. readonly collider: Nullable<Collider>;
  84084. /**
  84085. * Move the mesh using collision engine
  84086. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  84087. * @param displacement defines the requested displacement vector
  84088. * @returns the current mesh
  84089. */
  84090. moveWithCollisions(displacement: Vector3): AbstractMesh;
  84091. private _onCollisionPositionChange;
  84092. /** @hidden */
  84093. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  84094. /** @hidden */
  84095. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  84096. /** @hidden */
  84097. _checkCollision(collider: Collider): AbstractMesh;
  84098. /** @hidden */
  84099. _generatePointsArray(): boolean;
  84100. /**
  84101. * Checks if the passed Ray intersects with the mesh
  84102. * @param ray defines the ray to use
  84103. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  84104. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  84105. * @returns the picking info
  84106. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  84107. */
  84108. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): PickingInfo;
  84109. /**
  84110. * Clones the current mesh
  84111. * @param name defines the mesh name
  84112. * @param newParent defines the new mesh parent
  84113. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  84114. * @returns the new mesh
  84115. */
  84116. clone(name: string, newParent: Node, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  84117. /**
  84118. * Disposes all the submeshes of the current meshnp
  84119. * @returns the current mesh
  84120. */
  84121. releaseSubMeshes(): AbstractMesh;
  84122. /**
  84123. * Releases resources associated with this abstract mesh.
  84124. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84125. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84126. */
  84127. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84128. /**
  84129. * Adds the passed mesh as a child to the current mesh
  84130. * @param mesh defines the child mesh
  84131. * @returns the current mesh
  84132. */
  84133. addChild(mesh: AbstractMesh): AbstractMesh;
  84134. /**
  84135. * Removes the passed mesh from the current mesh children list
  84136. * @param mesh defines the child mesh
  84137. * @returns the current mesh
  84138. */
  84139. removeChild(mesh: AbstractMesh): AbstractMesh;
  84140. /** @hidden */
  84141. private _initFacetData;
  84142. /**
  84143. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  84144. * This method can be called within the render loop.
  84145. * 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
  84146. * @returns the current mesh
  84147. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84148. */
  84149. updateFacetData(): AbstractMesh;
  84150. /**
  84151. * Returns the facetLocalNormals array.
  84152. * The normals are expressed in the mesh local spac
  84153. * @returns an array of Vector3
  84154. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84155. */
  84156. getFacetLocalNormals(): Vector3[];
  84157. /**
  84158. * Returns the facetLocalPositions array.
  84159. * The facet positions are expressed in the mesh local space
  84160. * @returns an array of Vector3
  84161. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84162. */
  84163. getFacetLocalPositions(): Vector3[];
  84164. /**
  84165. * Returns the facetLocalPartioning array
  84166. * @returns an array of array of numbers
  84167. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84168. */
  84169. getFacetLocalPartitioning(): number[][];
  84170. /**
  84171. * Returns the i-th facet position in the world system.
  84172. * This method allocates a new Vector3 per call
  84173. * @param i defines the facet index
  84174. * @returns a new Vector3
  84175. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84176. */
  84177. getFacetPosition(i: number): Vector3;
  84178. /**
  84179. * Sets the reference Vector3 with the i-th facet position in the world system
  84180. * @param i defines the facet index
  84181. * @param ref defines the target vector
  84182. * @returns the current mesh
  84183. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84184. */
  84185. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  84186. /**
  84187. * Returns the i-th facet normal in the world system.
  84188. * This method allocates a new Vector3 per call
  84189. * @param i defines the facet index
  84190. * @returns a new Vector3
  84191. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84192. */
  84193. getFacetNormal(i: number): Vector3;
  84194. /**
  84195. * Sets the reference Vector3 with the i-th facet normal in the world system
  84196. * @param i defines the facet index
  84197. * @param ref defines the target vector
  84198. * @returns the current mesh
  84199. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84200. */
  84201. getFacetNormalToRef(i: number, ref: Vector3): this;
  84202. /**
  84203. * 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)
  84204. * @param x defines x coordinate
  84205. * @param y defines y coordinate
  84206. * @param z defines z coordinate
  84207. * @returns the array of facet indexes
  84208. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84209. */
  84210. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  84211. /**
  84212. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  84213. * @param projected sets as the (x,y,z) world projection on the facet
  84214. * @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
  84215. * @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
  84216. * @param x defines x coordinate
  84217. * @param y defines y coordinate
  84218. * @param z defines z coordinate
  84219. * @returns the face index if found (or null instead)
  84220. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84221. */
  84222. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84223. /**
  84224. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  84225. * @param projected sets as the (x,y,z) local projection on the facet
  84226. * @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
  84227. * @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
  84228. * @param x defines x coordinate
  84229. * @param y defines y coordinate
  84230. * @param z defines z coordinate
  84231. * @returns the face index if found (or null instead)
  84232. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84233. */
  84234. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  84235. /**
  84236. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  84237. * @returns the parameters
  84238. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84239. */
  84240. getFacetDataParameters(): any;
  84241. /**
  84242. * Disables the feature FacetData and frees the related memory
  84243. * @returns the current mesh
  84244. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  84245. */
  84246. disableFacetData(): AbstractMesh;
  84247. /**
  84248. * Updates the AbstractMesh indices array
  84249. * @param indices defines the data source
  84250. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  84251. * @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)
  84252. * @returns the current mesh
  84253. */
  84254. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  84255. /**
  84256. * Creates new normals data for the mesh
  84257. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  84258. * @returns the current mesh
  84259. */
  84260. createNormals(updatable: boolean): AbstractMesh;
  84261. /**
  84262. * Align the mesh with a normal
  84263. * @param normal defines the normal to use
  84264. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  84265. * @returns the current mesh
  84266. */
  84267. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  84268. /** @hidden */
  84269. _checkOcclusionQuery(): boolean;
  84270. }
  84271. }
  84272. declare module BABYLON {
  84273. /**
  84274. * Interface used to define ActionEvent
  84275. */
  84276. export interface IActionEvent {
  84277. /** The mesh or sprite that triggered the action */
  84278. source: any;
  84279. /** The X mouse cursor position at the time of the event */
  84280. pointerX: number;
  84281. /** The Y mouse cursor position at the time of the event */
  84282. pointerY: number;
  84283. /** The mesh that is currently pointed at (can be null) */
  84284. meshUnderPointer: Nullable<AbstractMesh>;
  84285. /** the original (browser) event that triggered the ActionEvent */
  84286. sourceEvent?: any;
  84287. /** additional data for the event */
  84288. additionalData?: any;
  84289. }
  84290. /**
  84291. * ActionEvent is the event being sent when an action is triggered.
  84292. */
  84293. export class ActionEvent implements IActionEvent {
  84294. /** The mesh or sprite that triggered the action */
  84295. source: any;
  84296. /** The X mouse cursor position at the time of the event */
  84297. pointerX: number;
  84298. /** The Y mouse cursor position at the time of the event */
  84299. pointerY: number;
  84300. /** The mesh that is currently pointed at (can be null) */
  84301. meshUnderPointer: Nullable<AbstractMesh>;
  84302. /** the original (browser) event that triggered the ActionEvent */
  84303. sourceEvent?: any;
  84304. /** additional data for the event */
  84305. additionalData?: any;
  84306. /**
  84307. * Creates a new ActionEvent
  84308. * @param source The mesh or sprite that triggered the action
  84309. * @param pointerX The X mouse cursor position at the time of the event
  84310. * @param pointerY The Y mouse cursor position at the time of the event
  84311. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  84312. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  84313. * @param additionalData additional data for the event
  84314. */
  84315. constructor(
  84316. /** The mesh or sprite that triggered the action */
  84317. source: any,
  84318. /** The X mouse cursor position at the time of the event */
  84319. pointerX: number,
  84320. /** The Y mouse cursor position at the time of the event */
  84321. pointerY: number,
  84322. /** The mesh that is currently pointed at (can be null) */
  84323. meshUnderPointer: Nullable<AbstractMesh>,
  84324. /** the original (browser) event that triggered the ActionEvent */
  84325. sourceEvent?: any,
  84326. /** additional data for the event */
  84327. additionalData?: any);
  84328. /**
  84329. * Helper function to auto-create an ActionEvent from a source mesh.
  84330. * @param source The source mesh that triggered the event
  84331. * @param evt The original (browser) event
  84332. * @param additionalData additional data for the event
  84333. * @returns the new ActionEvent
  84334. */
  84335. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  84336. /**
  84337. * Helper function to auto-create an ActionEvent from a source sprite
  84338. * @param source The source sprite that triggered the event
  84339. * @param scene Scene associated with the sprite
  84340. * @param evt The original (browser) event
  84341. * @param additionalData additional data for the event
  84342. * @returns the new ActionEvent
  84343. */
  84344. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  84345. /**
  84346. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  84347. * @param scene the scene where the event occurred
  84348. * @param evt The original (browser) event
  84349. * @returns the new ActionEvent
  84350. */
  84351. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  84352. /**
  84353. * Helper function to auto-create an ActionEvent from a primitive
  84354. * @param prim defines the target primitive
  84355. * @param pointerPos defines the pointer position
  84356. * @param evt The original (browser) event
  84357. * @param additionalData additional data for the event
  84358. * @returns the new ActionEvent
  84359. */
  84360. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  84361. }
  84362. }
  84363. declare module BABYLON {
  84364. /**
  84365. * Abstract class used to decouple action Manager from scene and meshes.
  84366. * Do not instantiate.
  84367. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  84368. */
  84369. export abstract class AbstractActionManager implements IDisposable {
  84370. /** Gets the list of active triggers */
  84371. static Triggers: {
  84372. [key: string]: number;
  84373. };
  84374. /** Gets the cursor to use when hovering items */
  84375. hoverCursor: string;
  84376. /** Gets the list of actions */
  84377. actions: IAction[];
  84378. /**
  84379. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  84380. */
  84381. isRecursive: boolean;
  84382. /**
  84383. * Releases all associated resources
  84384. */
  84385. abstract dispose(): void;
  84386. /**
  84387. * Does this action manager has pointer triggers
  84388. */
  84389. abstract readonly hasPointerTriggers: boolean;
  84390. /**
  84391. * Does this action manager has pick triggers
  84392. */
  84393. abstract readonly hasPickTriggers: boolean;
  84394. /**
  84395. * Process a specific trigger
  84396. * @param trigger defines the trigger to process
  84397. * @param evt defines the event details to be processed
  84398. */
  84399. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  84400. /**
  84401. * Does this action manager handles actions of any of the given triggers
  84402. * @param triggers defines the triggers to be tested
  84403. * @return a boolean indicating whether one (or more) of the triggers is handled
  84404. */
  84405. abstract hasSpecificTriggers(triggers: number[]): boolean;
  84406. /**
  84407. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  84408. * speed.
  84409. * @param triggerA defines the trigger to be tested
  84410. * @param triggerB defines the trigger to be tested
  84411. * @return a boolean indicating whether one (or more) of the triggers is handled
  84412. */
  84413. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  84414. /**
  84415. * Does this action manager handles actions of a given trigger
  84416. * @param trigger defines the trigger to be tested
  84417. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  84418. * @return whether the trigger is handled
  84419. */
  84420. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  84421. /**
  84422. * Serialize this manager to a JSON object
  84423. * @param name defines the property name to store this manager
  84424. * @returns a JSON representation of this manager
  84425. */
  84426. abstract serialize(name: string): any;
  84427. /**
  84428. * Registers an action to this action manager
  84429. * @param action defines the action to be registered
  84430. * @return the action amended (prepared) after registration
  84431. */
  84432. abstract registerAction(action: IAction): Nullable<IAction>;
  84433. /**
  84434. * Unregisters an action to this action manager
  84435. * @param action defines the action to be unregistered
  84436. * @return a boolean indicating whether the action has been unregistered
  84437. */
  84438. abstract unregisterAction(action: IAction): Boolean;
  84439. /**
  84440. * Does exist one action manager with at least one trigger
  84441. **/
  84442. static readonly HasTriggers: boolean;
  84443. /**
  84444. * Does exist one action manager with at least one pick trigger
  84445. **/
  84446. static readonly HasPickTriggers: boolean;
  84447. /**
  84448. * Does exist one action manager that handles actions of a given trigger
  84449. * @param trigger defines the trigger to be tested
  84450. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  84451. **/
  84452. static HasSpecificTrigger(trigger: number): boolean;
  84453. }
  84454. }
  84455. declare module BABYLON {
  84456. /**
  84457. * Defines how a node can be built from a string name.
  84458. */
  84459. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  84460. /**
  84461. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  84462. */
  84463. export class Node implements IBehaviorAware<Node> {
  84464. /** @hidden */
  84465. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  84466. private static _NodeConstructors;
  84467. /**
  84468. * Add a new node constructor
  84469. * @param type defines the type name of the node to construct
  84470. * @param constructorFunc defines the constructor function
  84471. */
  84472. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  84473. /**
  84474. * Returns a node constructor based on type name
  84475. * @param type defines the type name
  84476. * @param name defines the new node name
  84477. * @param scene defines the hosting scene
  84478. * @param options defines optional options to transmit to constructors
  84479. * @returns the new constructor or null
  84480. */
  84481. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  84482. /**
  84483. * Gets or sets the name of the node
  84484. */
  84485. name: string;
  84486. /**
  84487. * Gets or sets the id of the node
  84488. */
  84489. id: string;
  84490. /**
  84491. * Gets or sets the unique id of the node
  84492. */
  84493. uniqueId: number;
  84494. /**
  84495. * Gets or sets a string used to store user defined state for the node
  84496. */
  84497. state: string;
  84498. /**
  84499. * Gets or sets an object used to store user defined information for the node
  84500. */
  84501. metadata: any;
  84502. /**
  84503. * For internal use only. Please do not use.
  84504. */
  84505. reservedDataStore: any;
  84506. /**
  84507. * List of inspectable custom properties (used by the Inspector)
  84508. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  84509. */
  84510. inspectableCustomProperties: IInspectable[];
  84511. /**
  84512. * Gets or sets a boolean used to define if the node must be serialized
  84513. */
  84514. doNotSerialize: boolean;
  84515. /** @hidden */
  84516. _isDisposed: boolean;
  84517. /**
  84518. * Gets a list of Animations associated with the node
  84519. */
  84520. animations: Animation[];
  84521. protected _ranges: {
  84522. [name: string]: Nullable<AnimationRange>;
  84523. };
  84524. /**
  84525. * Callback raised when the node is ready to be used
  84526. */
  84527. onReady: Nullable<(node: Node) => void>;
  84528. private _isEnabled;
  84529. private _isParentEnabled;
  84530. private _isReady;
  84531. /** @hidden */
  84532. _currentRenderId: number;
  84533. private _parentUpdateId;
  84534. /** @hidden */
  84535. _childUpdateId: number;
  84536. /** @hidden */
  84537. _waitingParentId: Nullable<string>;
  84538. /** @hidden */
  84539. _scene: Scene;
  84540. /** @hidden */
  84541. _cache: any;
  84542. private _parentNode;
  84543. private _children;
  84544. /** @hidden */
  84545. _worldMatrix: Matrix;
  84546. /** @hidden */
  84547. _worldMatrixDeterminant: number;
  84548. /** @hidden */
  84549. _worldMatrixDeterminantIsDirty: boolean;
  84550. /** @hidden */
  84551. private _sceneRootNodesIndex;
  84552. /**
  84553. * Gets a boolean indicating if the node has been disposed
  84554. * @returns true if the node was disposed
  84555. */
  84556. isDisposed(): boolean;
  84557. /**
  84558. * Gets or sets the parent of the node (without keeping the current position in the scene)
  84559. * @see https://doc.babylonjs.com/how_to/parenting
  84560. */
  84561. parent: Nullable<Node>;
  84562. private addToSceneRootNodes;
  84563. private removeFromSceneRootNodes;
  84564. private _animationPropertiesOverride;
  84565. /**
  84566. * Gets or sets the animation properties override
  84567. */
  84568. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  84569. /**
  84570. * Gets a string idenfifying the name of the class
  84571. * @returns "Node" string
  84572. */
  84573. getClassName(): string;
  84574. /** @hidden */
  84575. readonly _isNode: boolean;
  84576. /**
  84577. * An event triggered when the mesh is disposed
  84578. */
  84579. onDisposeObservable: Observable<Node>;
  84580. private _onDisposeObserver;
  84581. /**
  84582. * Sets a callback that will be raised when the node will be disposed
  84583. */
  84584. onDispose: () => void;
  84585. /**
  84586. * Creates a new Node
  84587. * @param name the name and id to be given to this node
  84588. * @param scene the scene this node will be added to
  84589. * @param addToRootNodes the node will be added to scene.rootNodes
  84590. */
  84591. constructor(name: string, scene?: Nullable<Scene>, addToRootNodes?: boolean);
  84592. /**
  84593. * Gets the scene of the node
  84594. * @returns a scene
  84595. */
  84596. getScene(): Scene;
  84597. /**
  84598. * Gets the engine of the node
  84599. * @returns a Engine
  84600. */
  84601. getEngine(): Engine;
  84602. private _behaviors;
  84603. /**
  84604. * Attach a behavior to the node
  84605. * @see http://doc.babylonjs.com/features/behaviour
  84606. * @param behavior defines the behavior to attach
  84607. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  84608. * @returns the current Node
  84609. */
  84610. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  84611. /**
  84612. * Remove an attached behavior
  84613. * @see http://doc.babylonjs.com/features/behaviour
  84614. * @param behavior defines the behavior to attach
  84615. * @returns the current Node
  84616. */
  84617. removeBehavior(behavior: Behavior<Node>): Node;
  84618. /**
  84619. * Gets the list of attached behaviors
  84620. * @see http://doc.babylonjs.com/features/behaviour
  84621. */
  84622. readonly behaviors: Behavior<Node>[];
  84623. /**
  84624. * Gets an attached behavior by name
  84625. * @param name defines the name of the behavior to look for
  84626. * @see http://doc.babylonjs.com/features/behaviour
  84627. * @returns null if behavior was not found else the requested behavior
  84628. */
  84629. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  84630. /**
  84631. * Returns the latest update of the World matrix
  84632. * @returns a Matrix
  84633. */
  84634. getWorldMatrix(): Matrix;
  84635. /** @hidden */
  84636. _getWorldMatrixDeterminant(): number;
  84637. /**
  84638. * Returns directly the latest state of the mesh World matrix.
  84639. * A Matrix is returned.
  84640. */
  84641. readonly worldMatrixFromCache: Matrix;
  84642. /** @hidden */
  84643. _initCache(): void;
  84644. /** @hidden */
  84645. updateCache(force?: boolean): void;
  84646. /** @hidden */
  84647. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  84648. /** @hidden */
  84649. _updateCache(ignoreParentClass?: boolean): void;
  84650. /** @hidden */
  84651. _isSynchronized(): boolean;
  84652. /** @hidden */
  84653. _markSyncedWithParent(): void;
  84654. /** @hidden */
  84655. isSynchronizedWithParent(): boolean;
  84656. /** @hidden */
  84657. isSynchronized(): boolean;
  84658. /**
  84659. * Is this node ready to be used/rendered
  84660. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84661. * @return true if the node is ready
  84662. */
  84663. isReady(completeCheck?: boolean): boolean;
  84664. /**
  84665. * Is this node enabled?
  84666. * 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
  84667. * @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
  84668. * @return whether this node (and its parent) is enabled
  84669. */
  84670. isEnabled(checkAncestors?: boolean): boolean;
  84671. /** @hidden */
  84672. protected _syncParentEnabledState(): void;
  84673. /**
  84674. * Set the enabled state of this node
  84675. * @param value defines the new enabled state
  84676. */
  84677. setEnabled(value: boolean): void;
  84678. /**
  84679. * Is this node a descendant of the given node?
  84680. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  84681. * @param ancestor defines the parent node to inspect
  84682. * @returns a boolean indicating if this node is a descendant of the given node
  84683. */
  84684. isDescendantOf(ancestor: Node): boolean;
  84685. /** @hidden */
  84686. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  84687. /**
  84688. * Will return all nodes that have this node as ascendant
  84689. * @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
  84690. * @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
  84691. * @return all children nodes of all types
  84692. */
  84693. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  84694. /**
  84695. * Get all child-meshes of this node
  84696. * @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)
  84697. * @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
  84698. * @returns an array of AbstractMesh
  84699. */
  84700. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  84701. /**
  84702. * Get all direct children of this node
  84703. * @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
  84704. * @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)
  84705. * @returns an array of Node
  84706. */
  84707. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  84708. /** @hidden */
  84709. _setReady(state: boolean): void;
  84710. /**
  84711. * Get an animation by name
  84712. * @param name defines the name of the animation to look for
  84713. * @returns null if not found else the requested animation
  84714. */
  84715. getAnimationByName(name: string): Nullable<Animation>;
  84716. /**
  84717. * Creates an animation range for this node
  84718. * @param name defines the name of the range
  84719. * @param from defines the starting key
  84720. * @param to defines the end key
  84721. */
  84722. createAnimationRange(name: string, from: number, to: number): void;
  84723. /**
  84724. * Delete a specific animation range
  84725. * @param name defines the name of the range to delete
  84726. * @param deleteFrames defines if animation frames from the range must be deleted as well
  84727. */
  84728. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  84729. /**
  84730. * Get an animation range by name
  84731. * @param name defines the name of the animation range to look for
  84732. * @returns null if not found else the requested animation range
  84733. */
  84734. getAnimationRange(name: string): Nullable<AnimationRange>;
  84735. /**
  84736. * Gets the list of all animation ranges defined on this node
  84737. * @returns an array
  84738. */
  84739. getAnimationRanges(): Nullable<AnimationRange>[];
  84740. /**
  84741. * Will start the animation sequence
  84742. * @param name defines the range frames for animation sequence
  84743. * @param loop defines if the animation should loop (false by default)
  84744. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  84745. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  84746. * @returns the object created for this animation. If range does not exist, it will return null
  84747. */
  84748. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  84749. /**
  84750. * Serialize animation ranges into a JSON compatible object
  84751. * @returns serialization object
  84752. */
  84753. serializeAnimationRanges(): any;
  84754. /**
  84755. * Computes the world matrix of the node
  84756. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  84757. * @returns the world matrix
  84758. */
  84759. computeWorldMatrix(force?: boolean): Matrix;
  84760. /**
  84761. * Releases resources associated with this node.
  84762. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  84763. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  84764. */
  84765. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  84766. /**
  84767. * Parse animation range data from a serialization object and store them into a given node
  84768. * @param node defines where to store the animation ranges
  84769. * @param parsedNode defines the serialization object to read data from
  84770. * @param scene defines the hosting scene
  84771. */
  84772. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  84773. /**
  84774. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  84775. * @param includeDescendants Include bounding info from descendants as well (true by default)
  84776. * @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
  84777. * @returns the new bounding vectors
  84778. */
  84779. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  84780. min: Vector3;
  84781. max: Vector3;
  84782. };
  84783. }
  84784. }
  84785. declare module BABYLON {
  84786. /**
  84787. * @hidden
  84788. */
  84789. export class _IAnimationState {
  84790. key: number;
  84791. repeatCount: number;
  84792. workValue?: any;
  84793. loopMode?: number;
  84794. offsetValue?: any;
  84795. highLimitValue?: any;
  84796. }
  84797. /**
  84798. * Class used to store any kind of animation
  84799. */
  84800. export class Animation {
  84801. /**Name of the animation */
  84802. name: string;
  84803. /**Property to animate */
  84804. targetProperty: string;
  84805. /**The frames per second of the animation */
  84806. framePerSecond: number;
  84807. /**The data type of the animation */
  84808. dataType: number;
  84809. /**The loop mode of the animation */
  84810. loopMode?: number | undefined;
  84811. /**Specifies if blending should be enabled */
  84812. enableBlending?: boolean | undefined;
  84813. /**
  84814. * Use matrix interpolation instead of using direct key value when animating matrices
  84815. */
  84816. static AllowMatricesInterpolation: boolean;
  84817. /**
  84818. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  84819. */
  84820. static AllowMatrixDecomposeForInterpolation: boolean;
  84821. /**
  84822. * Stores the key frames of the animation
  84823. */
  84824. private _keys;
  84825. /**
  84826. * Stores the easing function of the animation
  84827. */
  84828. private _easingFunction;
  84829. /**
  84830. * @hidden Internal use only
  84831. */
  84832. _runtimeAnimations: RuntimeAnimation[];
  84833. /**
  84834. * The set of event that will be linked to this animation
  84835. */
  84836. private _events;
  84837. /**
  84838. * Stores an array of target property paths
  84839. */
  84840. targetPropertyPath: string[];
  84841. /**
  84842. * Stores the blending speed of the animation
  84843. */
  84844. blendingSpeed: number;
  84845. /**
  84846. * Stores the animation ranges for the animation
  84847. */
  84848. private _ranges;
  84849. /**
  84850. * @hidden Internal use
  84851. */
  84852. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  84853. /**
  84854. * Sets up an animation
  84855. * @param property The property to animate
  84856. * @param animationType The animation type to apply
  84857. * @param framePerSecond The frames per second of the animation
  84858. * @param easingFunction The easing function used in the animation
  84859. * @returns The created animation
  84860. */
  84861. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  84862. /**
  84863. * Create and start an animation on a node
  84864. * @param name defines the name of the global animation that will be run on all nodes
  84865. * @param node defines the root node where the animation will take place
  84866. * @param targetProperty defines property to animate
  84867. * @param framePerSecond defines the number of frame per second yo use
  84868. * @param totalFrame defines the number of frames in total
  84869. * @param from defines the initial value
  84870. * @param to defines the final value
  84871. * @param loopMode defines which loop mode you want to use (off by default)
  84872. * @param easingFunction defines the easing function to use (linear by default)
  84873. * @param onAnimationEnd defines the callback to call when animation end
  84874. * @returns the animatable created for this animation
  84875. */
  84876. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84877. /**
  84878. * Create and start an animation on a node and its descendants
  84879. * @param name defines the name of the global animation that will be run on all nodes
  84880. * @param node defines the root node where the animation will take place
  84881. * @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
  84882. * @param targetProperty defines property to animate
  84883. * @param framePerSecond defines the number of frame per second to use
  84884. * @param totalFrame defines the number of frames in total
  84885. * @param from defines the initial value
  84886. * @param to defines the final value
  84887. * @param loopMode defines which loop mode you want to use (off by default)
  84888. * @param easingFunction defines the easing function to use (linear by default)
  84889. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  84890. * @returns the list of animatables created for all nodes
  84891. * @example https://www.babylonjs-playground.com/#MH0VLI
  84892. */
  84893. 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[]>;
  84894. /**
  84895. * Creates a new animation, merges it with the existing animations and starts it
  84896. * @param name Name of the animation
  84897. * @param node Node which contains the scene that begins the animations
  84898. * @param targetProperty Specifies which property to animate
  84899. * @param framePerSecond The frames per second of the animation
  84900. * @param totalFrame The total number of frames
  84901. * @param from The frame at the beginning of the animation
  84902. * @param to The frame at the end of the animation
  84903. * @param loopMode Specifies the loop mode of the animation
  84904. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  84905. * @param onAnimationEnd Callback to run once the animation is complete
  84906. * @returns Nullable animation
  84907. */
  84908. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  84909. /**
  84910. * Transition property of an host to the target Value
  84911. * @param property The property to transition
  84912. * @param targetValue The target Value of the property
  84913. * @param host The object where the property to animate belongs
  84914. * @param scene Scene used to run the animation
  84915. * @param frameRate Framerate (in frame/s) to use
  84916. * @param transition The transition type we want to use
  84917. * @param duration The duration of the animation, in milliseconds
  84918. * @param onAnimationEnd Callback trigger at the end of the animation
  84919. * @returns Nullable animation
  84920. */
  84921. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  84922. /**
  84923. * Return the array of runtime animations currently using this animation
  84924. */
  84925. readonly runtimeAnimations: RuntimeAnimation[];
  84926. /**
  84927. * Specifies if any of the runtime animations are currently running
  84928. */
  84929. readonly hasRunningRuntimeAnimations: boolean;
  84930. /**
  84931. * Initializes the animation
  84932. * @param name Name of the animation
  84933. * @param targetProperty Property to animate
  84934. * @param framePerSecond The frames per second of the animation
  84935. * @param dataType The data type of the animation
  84936. * @param loopMode The loop mode of the animation
  84937. * @param enableBlending Specifies if blending should be enabled
  84938. */
  84939. constructor(
  84940. /**Name of the animation */
  84941. name: string,
  84942. /**Property to animate */
  84943. targetProperty: string,
  84944. /**The frames per second of the animation */
  84945. framePerSecond: number,
  84946. /**The data type of the animation */
  84947. dataType: number,
  84948. /**The loop mode of the animation */
  84949. loopMode?: number | undefined,
  84950. /**Specifies if blending should be enabled */
  84951. enableBlending?: boolean | undefined);
  84952. /**
  84953. * Converts the animation to a string
  84954. * @param fullDetails support for multiple levels of logging within scene loading
  84955. * @returns String form of the animation
  84956. */
  84957. toString(fullDetails?: boolean): string;
  84958. /**
  84959. * Add an event to this animation
  84960. * @param event Event to add
  84961. */
  84962. addEvent(event: AnimationEvent): void;
  84963. /**
  84964. * Remove all events found at the given frame
  84965. * @param frame The frame to remove events from
  84966. */
  84967. removeEvents(frame: number): void;
  84968. /**
  84969. * Retrieves all the events from the animation
  84970. * @returns Events from the animation
  84971. */
  84972. getEvents(): AnimationEvent[];
  84973. /**
  84974. * Creates an animation range
  84975. * @param name Name of the animation range
  84976. * @param from Starting frame of the animation range
  84977. * @param to Ending frame of the animation
  84978. */
  84979. createRange(name: string, from: number, to: number): void;
  84980. /**
  84981. * Deletes an animation range by name
  84982. * @param name Name of the animation range to delete
  84983. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  84984. */
  84985. deleteRange(name: string, deleteFrames?: boolean): void;
  84986. /**
  84987. * Gets the animation range by name, or null if not defined
  84988. * @param name Name of the animation range
  84989. * @returns Nullable animation range
  84990. */
  84991. getRange(name: string): Nullable<AnimationRange>;
  84992. /**
  84993. * Gets the key frames from the animation
  84994. * @returns The key frames of the animation
  84995. */
  84996. getKeys(): Array<IAnimationKey>;
  84997. /**
  84998. * Gets the highest frame rate of the animation
  84999. * @returns Highest frame rate of the animation
  85000. */
  85001. getHighestFrame(): number;
  85002. /**
  85003. * Gets the easing function of the animation
  85004. * @returns Easing function of the animation
  85005. */
  85006. getEasingFunction(): IEasingFunction;
  85007. /**
  85008. * Sets the easing function of the animation
  85009. * @param easingFunction A custom mathematical formula for animation
  85010. */
  85011. setEasingFunction(easingFunction: EasingFunction): void;
  85012. /**
  85013. * Interpolates a scalar linearly
  85014. * @param startValue Start value of the animation curve
  85015. * @param endValue End value of the animation curve
  85016. * @param gradient Scalar amount to interpolate
  85017. * @returns Interpolated scalar value
  85018. */
  85019. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  85020. /**
  85021. * Interpolates a scalar cubically
  85022. * @param startValue Start value of the animation curve
  85023. * @param outTangent End tangent of the animation
  85024. * @param endValue End value of the animation curve
  85025. * @param inTangent Start tangent of the animation curve
  85026. * @param gradient Scalar amount to interpolate
  85027. * @returns Interpolated scalar value
  85028. */
  85029. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  85030. /**
  85031. * Interpolates a quaternion using a spherical linear interpolation
  85032. * @param startValue Start value of the animation curve
  85033. * @param endValue End value of the animation curve
  85034. * @param gradient Scalar amount to interpolate
  85035. * @returns Interpolated quaternion value
  85036. */
  85037. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  85038. /**
  85039. * Interpolates a quaternion cubically
  85040. * @param startValue Start value of the animation curve
  85041. * @param outTangent End tangent of the animation curve
  85042. * @param endValue End value of the animation curve
  85043. * @param inTangent Start tangent of the animation curve
  85044. * @param gradient Scalar amount to interpolate
  85045. * @returns Interpolated quaternion value
  85046. */
  85047. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  85048. /**
  85049. * Interpolates a Vector3 linearl
  85050. * @param startValue Start value of the animation curve
  85051. * @param endValue End value of the animation curve
  85052. * @param gradient Scalar amount to interpolate
  85053. * @returns Interpolated scalar value
  85054. */
  85055. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  85056. /**
  85057. * Interpolates a Vector3 cubically
  85058. * @param startValue Start value of the animation curve
  85059. * @param outTangent End tangent of the animation
  85060. * @param endValue End value of the animation curve
  85061. * @param inTangent Start tangent of the animation curve
  85062. * @param gradient Scalar amount to interpolate
  85063. * @returns InterpolatedVector3 value
  85064. */
  85065. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  85066. /**
  85067. * Interpolates a Vector2 linearly
  85068. * @param startValue Start value of the animation curve
  85069. * @param endValue End value of the animation curve
  85070. * @param gradient Scalar amount to interpolate
  85071. * @returns Interpolated Vector2 value
  85072. */
  85073. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  85074. /**
  85075. * Interpolates a Vector2 cubically
  85076. * @param startValue Start value of the animation curve
  85077. * @param outTangent End tangent of the animation
  85078. * @param endValue End value of the animation curve
  85079. * @param inTangent Start tangent of the animation curve
  85080. * @param gradient Scalar amount to interpolate
  85081. * @returns Interpolated Vector2 value
  85082. */
  85083. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  85084. /**
  85085. * Interpolates a size linearly
  85086. * @param startValue Start value of the animation curve
  85087. * @param endValue End value of the animation curve
  85088. * @param gradient Scalar amount to interpolate
  85089. * @returns Interpolated Size value
  85090. */
  85091. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  85092. /**
  85093. * Interpolates a Color3 linearly
  85094. * @param startValue Start value of the animation curve
  85095. * @param endValue End value of the animation curve
  85096. * @param gradient Scalar amount to interpolate
  85097. * @returns Interpolated Color3 value
  85098. */
  85099. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  85100. /**
  85101. * @hidden Internal use only
  85102. */
  85103. _getKeyValue(value: any): any;
  85104. /**
  85105. * @hidden Internal use only
  85106. */
  85107. _interpolate(currentFrame: number, state: _IAnimationState): any;
  85108. /**
  85109. * Defines the function to use to interpolate matrices
  85110. * @param startValue defines the start matrix
  85111. * @param endValue defines the end matrix
  85112. * @param gradient defines the gradient between both matrices
  85113. * @param result defines an optional target matrix where to store the interpolation
  85114. * @returns the interpolated matrix
  85115. */
  85116. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  85117. /**
  85118. * Makes a copy of the animation
  85119. * @returns Cloned animation
  85120. */
  85121. clone(): Animation;
  85122. /**
  85123. * Sets the key frames of the animation
  85124. * @param values The animation key frames to set
  85125. */
  85126. setKeys(values: Array<IAnimationKey>): void;
  85127. /**
  85128. * Serializes the animation to an object
  85129. * @returns Serialized object
  85130. */
  85131. serialize(): any;
  85132. /**
  85133. * Float animation type
  85134. */
  85135. private static _ANIMATIONTYPE_FLOAT;
  85136. /**
  85137. * Vector3 animation type
  85138. */
  85139. private static _ANIMATIONTYPE_VECTOR3;
  85140. /**
  85141. * Quaternion animation type
  85142. */
  85143. private static _ANIMATIONTYPE_QUATERNION;
  85144. /**
  85145. * Matrix animation type
  85146. */
  85147. private static _ANIMATIONTYPE_MATRIX;
  85148. /**
  85149. * Color3 animation type
  85150. */
  85151. private static _ANIMATIONTYPE_COLOR3;
  85152. /**
  85153. * Vector2 animation type
  85154. */
  85155. private static _ANIMATIONTYPE_VECTOR2;
  85156. /**
  85157. * Size animation type
  85158. */
  85159. private static _ANIMATIONTYPE_SIZE;
  85160. /**
  85161. * Relative Loop Mode
  85162. */
  85163. private static _ANIMATIONLOOPMODE_RELATIVE;
  85164. /**
  85165. * Cycle Loop Mode
  85166. */
  85167. private static _ANIMATIONLOOPMODE_CYCLE;
  85168. /**
  85169. * Constant Loop Mode
  85170. */
  85171. private static _ANIMATIONLOOPMODE_CONSTANT;
  85172. /**
  85173. * Get the float animation type
  85174. */
  85175. static readonly ANIMATIONTYPE_FLOAT: number;
  85176. /**
  85177. * Get the Vector3 animation type
  85178. */
  85179. static readonly ANIMATIONTYPE_VECTOR3: number;
  85180. /**
  85181. * Get the Vector2 animation type
  85182. */
  85183. static readonly ANIMATIONTYPE_VECTOR2: number;
  85184. /**
  85185. * Get the Size animation type
  85186. */
  85187. static readonly ANIMATIONTYPE_SIZE: number;
  85188. /**
  85189. * Get the Quaternion animation type
  85190. */
  85191. static readonly ANIMATIONTYPE_QUATERNION: number;
  85192. /**
  85193. * Get the Matrix animation type
  85194. */
  85195. static readonly ANIMATIONTYPE_MATRIX: number;
  85196. /**
  85197. * Get the Color3 animation type
  85198. */
  85199. static readonly ANIMATIONTYPE_COLOR3: number;
  85200. /**
  85201. * Get the Relative Loop Mode
  85202. */
  85203. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  85204. /**
  85205. * Get the Cycle Loop Mode
  85206. */
  85207. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  85208. /**
  85209. * Get the Constant Loop Mode
  85210. */
  85211. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  85212. /** @hidden */
  85213. static _UniversalLerp(left: any, right: any, amount: number): any;
  85214. /**
  85215. * Parses an animation object and creates an animation
  85216. * @param parsedAnimation Parsed animation object
  85217. * @returns Animation object
  85218. */
  85219. static Parse(parsedAnimation: any): Animation;
  85220. /**
  85221. * Appends the serialized animations from the source animations
  85222. * @param source Source containing the animations
  85223. * @param destination Target to store the animations
  85224. */
  85225. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  85226. }
  85227. }
  85228. declare module BABYLON {
  85229. /**
  85230. * Base class of all the textures in babylon.
  85231. * It groups all the common properties the materials, post process, lights... might need
  85232. * in order to make a correct use of the texture.
  85233. */
  85234. export class BaseTexture implements IAnimatable {
  85235. /**
  85236. * Default anisotropic filtering level for the application.
  85237. * It is set to 4 as a good tradeoff between perf and quality.
  85238. */
  85239. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  85240. /**
  85241. * Gets or sets the unique id of the texture
  85242. */
  85243. uniqueId: number;
  85244. /**
  85245. * Define the name of the texture.
  85246. */
  85247. name: string;
  85248. /**
  85249. * Gets or sets an object used to store user defined information.
  85250. */
  85251. metadata: any;
  85252. /**
  85253. * For internal use only. Please do not use.
  85254. */
  85255. reservedDataStore: any;
  85256. private _hasAlpha;
  85257. /**
  85258. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  85259. */
  85260. hasAlpha: boolean;
  85261. /**
  85262. * Defines if the alpha value should be determined via the rgb values.
  85263. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  85264. */
  85265. getAlphaFromRGB: boolean;
  85266. /**
  85267. * Intensity or strength of the texture.
  85268. * It is commonly used by materials to fine tune the intensity of the texture
  85269. */
  85270. level: number;
  85271. /**
  85272. * Define the UV chanel to use starting from 0 and defaulting to 0.
  85273. * This is part of the texture as textures usually maps to one uv set.
  85274. */
  85275. coordinatesIndex: number;
  85276. private _coordinatesMode;
  85277. /**
  85278. * How a texture is mapped.
  85279. *
  85280. * | Value | Type | Description |
  85281. * | ----- | ----------------------------------- | ----------- |
  85282. * | 0 | EXPLICIT_MODE | |
  85283. * | 1 | SPHERICAL_MODE | |
  85284. * | 2 | PLANAR_MODE | |
  85285. * | 3 | CUBIC_MODE | |
  85286. * | 4 | PROJECTION_MODE | |
  85287. * | 5 | SKYBOX_MODE | |
  85288. * | 6 | INVCUBIC_MODE | |
  85289. * | 7 | EQUIRECTANGULAR_MODE | |
  85290. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  85291. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  85292. */
  85293. coordinatesMode: number;
  85294. /**
  85295. * | Value | Type | Description |
  85296. * | ----- | ------------------ | ----------- |
  85297. * | 0 | CLAMP_ADDRESSMODE | |
  85298. * | 1 | WRAP_ADDRESSMODE | |
  85299. * | 2 | MIRROR_ADDRESSMODE | |
  85300. */
  85301. wrapU: number;
  85302. /**
  85303. * | Value | Type | Description |
  85304. * | ----- | ------------------ | ----------- |
  85305. * | 0 | CLAMP_ADDRESSMODE | |
  85306. * | 1 | WRAP_ADDRESSMODE | |
  85307. * | 2 | MIRROR_ADDRESSMODE | |
  85308. */
  85309. wrapV: number;
  85310. /**
  85311. * | Value | Type | Description |
  85312. * | ----- | ------------------ | ----------- |
  85313. * | 0 | CLAMP_ADDRESSMODE | |
  85314. * | 1 | WRAP_ADDRESSMODE | |
  85315. * | 2 | MIRROR_ADDRESSMODE | |
  85316. */
  85317. wrapR: number;
  85318. /**
  85319. * With compliant hardware and browser (supporting anisotropic filtering)
  85320. * this defines the level of anisotropic filtering in the texture.
  85321. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  85322. */
  85323. anisotropicFilteringLevel: number;
  85324. /**
  85325. * Define if the texture is a cube texture or if false a 2d texture.
  85326. */
  85327. isCube: boolean;
  85328. /**
  85329. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  85330. */
  85331. is3D: boolean;
  85332. /**
  85333. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  85334. * HDR texture are usually stored in linear space.
  85335. * This only impacts the PBR and Background materials
  85336. */
  85337. gammaSpace: boolean;
  85338. /**
  85339. * Gets whether or not the texture contains RGBD data.
  85340. */
  85341. readonly isRGBD: boolean;
  85342. /**
  85343. * Is Z inverted in the texture (useful in a cube texture).
  85344. */
  85345. invertZ: boolean;
  85346. /**
  85347. * Are mip maps generated for this texture or not.
  85348. */
  85349. readonly noMipmap: boolean;
  85350. /**
  85351. * @hidden
  85352. */
  85353. lodLevelInAlpha: boolean;
  85354. /**
  85355. * With prefiltered texture, defined the offset used during the prefiltering steps.
  85356. */
  85357. lodGenerationOffset: number;
  85358. /**
  85359. * With prefiltered texture, defined the scale used during the prefiltering steps.
  85360. */
  85361. lodGenerationScale: number;
  85362. /**
  85363. * Define if the texture is a render target.
  85364. */
  85365. isRenderTarget: boolean;
  85366. /**
  85367. * Define the unique id of the texture in the scene.
  85368. */
  85369. readonly uid: string;
  85370. /**
  85371. * Return a string representation of the texture.
  85372. * @returns the texture as a string
  85373. */
  85374. toString(): string;
  85375. /**
  85376. * Get the class name of the texture.
  85377. * @returns "BaseTexture"
  85378. */
  85379. getClassName(): string;
  85380. /**
  85381. * Define the list of animation attached to the texture.
  85382. */
  85383. animations: Animation[];
  85384. /**
  85385. * An event triggered when the texture is disposed.
  85386. */
  85387. onDisposeObservable: Observable<BaseTexture>;
  85388. private _onDisposeObserver;
  85389. /**
  85390. * Callback triggered when the texture has been disposed.
  85391. * Kept for back compatibility, you can use the onDisposeObservable instead.
  85392. */
  85393. onDispose: () => void;
  85394. /**
  85395. * Define the current state of the loading sequence when in delayed load mode.
  85396. */
  85397. delayLoadState: number;
  85398. private _scene;
  85399. /** @hidden */
  85400. _texture: Nullable<InternalTexture>;
  85401. private _uid;
  85402. /**
  85403. * Define if the texture is preventinga material to render or not.
  85404. * If not and the texture is not ready, the engine will use a default black texture instead.
  85405. */
  85406. readonly isBlocking: boolean;
  85407. /**
  85408. * Instantiates a new BaseTexture.
  85409. * Base class of all the textures in babylon.
  85410. * It groups all the common properties the materials, post process, lights... might need
  85411. * in order to make a correct use of the texture.
  85412. * @param scene Define the scene the texture blongs to
  85413. */
  85414. constructor(scene: Nullable<Scene>);
  85415. /**
  85416. * Get the scene the texture belongs to.
  85417. * @returns the scene or null if undefined
  85418. */
  85419. getScene(): Nullable<Scene>;
  85420. /**
  85421. * Get the texture transform matrix used to offset tile the texture for istance.
  85422. * @returns the transformation matrix
  85423. */
  85424. getTextureMatrix(): Matrix;
  85425. /**
  85426. * Get the texture reflection matrix used to rotate/transform the reflection.
  85427. * @returns the reflection matrix
  85428. */
  85429. getReflectionTextureMatrix(): Matrix;
  85430. /**
  85431. * Get the underlying lower level texture from Babylon.
  85432. * @returns the insternal texture
  85433. */
  85434. getInternalTexture(): Nullable<InternalTexture>;
  85435. /**
  85436. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  85437. * @returns true if ready or not blocking
  85438. */
  85439. isReadyOrNotBlocking(): boolean;
  85440. /**
  85441. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  85442. * @returns true if fully ready
  85443. */
  85444. isReady(): boolean;
  85445. private _cachedSize;
  85446. /**
  85447. * Get the size of the texture.
  85448. * @returns the texture size.
  85449. */
  85450. getSize(): ISize;
  85451. /**
  85452. * Get the base size of the texture.
  85453. * It can be different from the size if the texture has been resized for POT for instance
  85454. * @returns the base size
  85455. */
  85456. getBaseSize(): ISize;
  85457. /**
  85458. * Update the sampling mode of the texture.
  85459. * Default is Trilinear mode.
  85460. *
  85461. * | Value | Type | Description |
  85462. * | ----- | ------------------ | ----------- |
  85463. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  85464. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  85465. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  85466. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  85467. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  85468. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  85469. * | 7 | NEAREST_LINEAR | |
  85470. * | 8 | NEAREST_NEAREST | |
  85471. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  85472. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  85473. * | 11 | LINEAR_LINEAR | |
  85474. * | 12 | LINEAR_NEAREST | |
  85475. *
  85476. * > _mag_: magnification filter (close to the viewer)
  85477. * > _min_: minification filter (far from the viewer)
  85478. * > _mip_: filter used between mip map levels
  85479. *@param samplingMode Define the new sampling mode of the texture
  85480. */
  85481. updateSamplingMode(samplingMode: number): void;
  85482. /**
  85483. * Scales the texture if is `canRescale()`
  85484. * @param ratio the resize factor we want to use to rescale
  85485. */
  85486. scale(ratio: number): void;
  85487. /**
  85488. * Get if the texture can rescale.
  85489. */
  85490. readonly canRescale: boolean;
  85491. /** @hidden */
  85492. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  85493. /** @hidden */
  85494. _rebuild(): void;
  85495. /**
  85496. * Triggers the load sequence in delayed load mode.
  85497. */
  85498. delayLoad(): void;
  85499. /**
  85500. * Clones the texture.
  85501. * @returns the cloned texture
  85502. */
  85503. clone(): Nullable<BaseTexture>;
  85504. /**
  85505. * Get the texture underlying type (INT, FLOAT...)
  85506. */
  85507. readonly textureType: number;
  85508. /**
  85509. * Get the texture underlying format (RGB, RGBA...)
  85510. */
  85511. readonly textureFormat: number;
  85512. /**
  85513. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  85514. * This will returns an RGBA array buffer containing either in values (0-255) or
  85515. * float values (0-1) depending of the underlying buffer type.
  85516. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  85517. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  85518. * @param buffer defines a user defined buffer to fill with data (can be null)
  85519. * @returns The Array buffer containing the pixels data.
  85520. */
  85521. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  85522. /**
  85523. * Release and destroy the underlying lower level texture aka internalTexture.
  85524. */
  85525. releaseInternalTexture(): void;
  85526. /**
  85527. * Get the polynomial representation of the texture data.
  85528. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  85529. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  85530. */
  85531. sphericalPolynomial: Nullable<SphericalPolynomial>;
  85532. /** @hidden */
  85533. readonly _lodTextureHigh: Nullable<BaseTexture>;
  85534. /** @hidden */
  85535. readonly _lodTextureMid: Nullable<BaseTexture>;
  85536. /** @hidden */
  85537. readonly _lodTextureLow: Nullable<BaseTexture>;
  85538. /**
  85539. * Dispose the texture and release its associated resources.
  85540. */
  85541. dispose(): void;
  85542. /**
  85543. * Serialize the texture into a JSON representation that can be parsed later on.
  85544. * @returns the JSON representation of the texture
  85545. */
  85546. serialize(): any;
  85547. /**
  85548. * Helper function to be called back once a list of texture contains only ready textures.
  85549. * @param textures Define the list of textures to wait for
  85550. * @param callback Define the callback triggered once the entire list will be ready
  85551. */
  85552. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  85553. }
  85554. }
  85555. declare module BABYLON {
  85556. /**
  85557. * Uniform buffer objects.
  85558. *
  85559. * Handles blocks of uniform on the GPU.
  85560. *
  85561. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85562. *
  85563. * For more information, please refer to :
  85564. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85565. */
  85566. export class UniformBuffer {
  85567. private _engine;
  85568. private _buffer;
  85569. private _data;
  85570. private _bufferData;
  85571. private _dynamic?;
  85572. private _uniformLocations;
  85573. private _uniformSizes;
  85574. private _uniformLocationPointer;
  85575. private _needSync;
  85576. private _noUBO;
  85577. private _currentEffect;
  85578. private static _MAX_UNIFORM_SIZE;
  85579. private static _tempBuffer;
  85580. /**
  85581. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  85582. * This is dynamic to allow compat with webgl 1 and 2.
  85583. * You will need to pass the name of the uniform as well as the value.
  85584. */
  85585. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  85586. /**
  85587. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  85588. * This is dynamic to allow compat with webgl 1 and 2.
  85589. * You will need to pass the name of the uniform as well as the value.
  85590. */
  85591. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  85592. /**
  85593. * Lambda to Update a single float in a uniform buffer.
  85594. * This is dynamic to allow compat with webgl 1 and 2.
  85595. * You will need to pass the name of the uniform as well as the value.
  85596. */
  85597. updateFloat: (name: string, x: number) => void;
  85598. /**
  85599. * Lambda to Update a vec2 of float in a uniform buffer.
  85600. * This is dynamic to allow compat with webgl 1 and 2.
  85601. * You will need to pass the name of the uniform as well as the value.
  85602. */
  85603. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  85604. /**
  85605. * Lambda to Update a vec3 of float in a uniform buffer.
  85606. * This is dynamic to allow compat with webgl 1 and 2.
  85607. * You will need to pass the name of the uniform as well as the value.
  85608. */
  85609. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  85610. /**
  85611. * Lambda to Update a vec4 of float in a uniform buffer.
  85612. * This is dynamic to allow compat with webgl 1 and 2.
  85613. * You will need to pass the name of the uniform as well as the value.
  85614. */
  85615. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  85616. /**
  85617. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  85618. * This is dynamic to allow compat with webgl 1 and 2.
  85619. * You will need to pass the name of the uniform as well as the value.
  85620. */
  85621. updateMatrix: (name: string, mat: Matrix) => void;
  85622. /**
  85623. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  85624. * This is dynamic to allow compat with webgl 1 and 2.
  85625. * You will need to pass the name of the uniform as well as the value.
  85626. */
  85627. updateVector3: (name: string, vector: Vector3) => void;
  85628. /**
  85629. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  85630. * This is dynamic to allow compat with webgl 1 and 2.
  85631. * You will need to pass the name of the uniform as well as the value.
  85632. */
  85633. updateVector4: (name: string, vector: Vector4) => void;
  85634. /**
  85635. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  85636. * This is dynamic to allow compat with webgl 1 and 2.
  85637. * You will need to pass the name of the uniform as well as the value.
  85638. */
  85639. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  85640. /**
  85641. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  85642. * This is dynamic to allow compat with webgl 1 and 2.
  85643. * You will need to pass the name of the uniform as well as the value.
  85644. */
  85645. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  85646. /**
  85647. * Instantiates a new Uniform buffer objects.
  85648. *
  85649. * Handles blocks of uniform on the GPU.
  85650. *
  85651. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  85652. *
  85653. * For more information, please refer to :
  85654. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  85655. * @param engine Define the engine the buffer is associated with
  85656. * @param data Define the data contained in the buffer
  85657. * @param dynamic Define if the buffer is updatable
  85658. */
  85659. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  85660. /**
  85661. * Indicates if the buffer is using the WebGL2 UBO implementation,
  85662. * or just falling back on setUniformXXX calls.
  85663. */
  85664. readonly useUbo: boolean;
  85665. /**
  85666. * Indicates if the WebGL underlying uniform buffer is in sync
  85667. * with the javascript cache data.
  85668. */
  85669. readonly isSync: boolean;
  85670. /**
  85671. * Indicates if the WebGL underlying uniform buffer is dynamic.
  85672. * Also, a dynamic UniformBuffer will disable cache verification and always
  85673. * update the underlying WebGL uniform buffer to the GPU.
  85674. * @returns if Dynamic, otherwise false
  85675. */
  85676. isDynamic(): boolean;
  85677. /**
  85678. * The data cache on JS side.
  85679. * @returns the underlying data as a float array
  85680. */
  85681. getData(): Float32Array;
  85682. /**
  85683. * The underlying WebGL Uniform buffer.
  85684. * @returns the webgl buffer
  85685. */
  85686. getBuffer(): Nullable<WebGLBuffer>;
  85687. /**
  85688. * std140 layout specifies how to align data within an UBO structure.
  85689. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  85690. * for specs.
  85691. */
  85692. private _fillAlignment;
  85693. /**
  85694. * Adds an uniform in the buffer.
  85695. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  85696. * for the layout to be correct !
  85697. * @param name Name of the uniform, as used in the uniform block in the shader.
  85698. * @param size Data size, or data directly.
  85699. */
  85700. addUniform(name: string, size: number | number[]): void;
  85701. /**
  85702. * Adds a Matrix 4x4 to the uniform buffer.
  85703. * @param name Name of the uniform, as used in the uniform block in the shader.
  85704. * @param mat A 4x4 matrix.
  85705. */
  85706. addMatrix(name: string, mat: Matrix): void;
  85707. /**
  85708. * Adds a vec2 to the uniform buffer.
  85709. * @param name Name of the uniform, as used in the uniform block in the shader.
  85710. * @param x Define the x component value of the vec2
  85711. * @param y Define the y component value of the vec2
  85712. */
  85713. addFloat2(name: string, x: number, y: number): void;
  85714. /**
  85715. * Adds a vec3 to the uniform buffer.
  85716. * @param name Name of the uniform, as used in the uniform block in the shader.
  85717. * @param x Define the x component value of the vec3
  85718. * @param y Define the y component value of the vec3
  85719. * @param z Define the z component value of the vec3
  85720. */
  85721. addFloat3(name: string, x: number, y: number, z: number): void;
  85722. /**
  85723. * Adds a vec3 to the uniform buffer.
  85724. * @param name Name of the uniform, as used in the uniform block in the shader.
  85725. * @param color Define the vec3 from a Color
  85726. */
  85727. addColor3(name: string, color: Color3): void;
  85728. /**
  85729. * Adds a vec4 to the uniform buffer.
  85730. * @param name Name of the uniform, as used in the uniform block in the shader.
  85731. * @param color Define the rgb components from a Color
  85732. * @param alpha Define the a component of the vec4
  85733. */
  85734. addColor4(name: string, color: Color3, alpha: number): void;
  85735. /**
  85736. * Adds a vec3 to the uniform buffer.
  85737. * @param name Name of the uniform, as used in the uniform block in the shader.
  85738. * @param vector Define the vec3 components from a Vector
  85739. */
  85740. addVector3(name: string, vector: Vector3): void;
  85741. /**
  85742. * Adds a Matrix 3x3 to the uniform buffer.
  85743. * @param name Name of the uniform, as used in the uniform block in the shader.
  85744. */
  85745. addMatrix3x3(name: string): void;
  85746. /**
  85747. * Adds a Matrix 2x2 to the uniform buffer.
  85748. * @param name Name of the uniform, as used in the uniform block in the shader.
  85749. */
  85750. addMatrix2x2(name: string): void;
  85751. /**
  85752. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  85753. */
  85754. create(): void;
  85755. /** @hidden */
  85756. _rebuild(): void;
  85757. /**
  85758. * Updates the WebGL Uniform Buffer on the GPU.
  85759. * If the `dynamic` flag is set to true, no cache comparison is done.
  85760. * Otherwise, the buffer will be updated only if the cache differs.
  85761. */
  85762. update(): void;
  85763. /**
  85764. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  85765. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85766. * @param data Define the flattened data
  85767. * @param size Define the size of the data.
  85768. */
  85769. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  85770. private _updateMatrix3x3ForUniform;
  85771. private _updateMatrix3x3ForEffect;
  85772. private _updateMatrix2x2ForEffect;
  85773. private _updateMatrix2x2ForUniform;
  85774. private _updateFloatForEffect;
  85775. private _updateFloatForUniform;
  85776. private _updateFloat2ForEffect;
  85777. private _updateFloat2ForUniform;
  85778. private _updateFloat3ForEffect;
  85779. private _updateFloat3ForUniform;
  85780. private _updateFloat4ForEffect;
  85781. private _updateFloat4ForUniform;
  85782. private _updateMatrixForEffect;
  85783. private _updateMatrixForUniform;
  85784. private _updateVector3ForEffect;
  85785. private _updateVector3ForUniform;
  85786. private _updateVector4ForEffect;
  85787. private _updateVector4ForUniform;
  85788. private _updateColor3ForEffect;
  85789. private _updateColor3ForUniform;
  85790. private _updateColor4ForEffect;
  85791. private _updateColor4ForUniform;
  85792. /**
  85793. * Sets a sampler uniform on the effect.
  85794. * @param name Define the name of the sampler.
  85795. * @param texture Define the texture to set in the sampler
  85796. */
  85797. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  85798. /**
  85799. * Directly updates the value of the uniform in the cache AND on the GPU.
  85800. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  85801. * @param data Define the flattened data
  85802. */
  85803. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  85804. /**
  85805. * Binds this uniform buffer to an effect.
  85806. * @param effect Define the effect to bind the buffer to
  85807. * @param name Name of the uniform block in the shader.
  85808. */
  85809. bindToEffect(effect: Effect, name: string): void;
  85810. /**
  85811. * Disposes the uniform buffer.
  85812. */
  85813. dispose(): void;
  85814. }
  85815. }
  85816. declare module BABYLON {
  85817. /**
  85818. * This represents the required contract to create a new type of texture loader.
  85819. */
  85820. export interface IInternalTextureLoader {
  85821. /**
  85822. * Defines wether the loader supports cascade loading the different faces.
  85823. */
  85824. supportCascades: boolean;
  85825. /**
  85826. * This returns if the loader support the current file information.
  85827. * @param extension defines the file extension of the file being loaded
  85828. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85829. * @param fallback defines the fallback internal texture if any
  85830. * @param isBase64 defines whether the texture is encoded as a base64
  85831. * @param isBuffer defines whether the texture data are stored as a buffer
  85832. * @returns true if the loader can load the specified file
  85833. */
  85834. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  85835. /**
  85836. * Transform the url before loading if required.
  85837. * @param rootUrl the url of the texture
  85838. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85839. * @returns the transformed texture
  85840. */
  85841. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  85842. /**
  85843. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  85844. * @param rootUrl the url of the texture
  85845. * @param textureFormatInUse defines the current compressed format in use iun the engine
  85846. * @returns the fallback texture
  85847. */
  85848. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  85849. /**
  85850. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  85851. * @param data contains the texture data
  85852. * @param texture defines the BabylonJS internal texture
  85853. * @param createPolynomials will be true if polynomials have been requested
  85854. * @param onLoad defines the callback to trigger once the texture is ready
  85855. * @param onError defines the callback to trigger in case of error
  85856. */
  85857. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  85858. /**
  85859. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  85860. * @param data contains the texture data
  85861. * @param texture defines the BabylonJS internal texture
  85862. * @param callback defines the method to call once ready to upload
  85863. */
  85864. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  85865. }
  85866. }
  85867. declare module BABYLON {
  85868. /**
  85869. * Creation options of the multi render target texture.
  85870. */
  85871. export interface IMultiRenderTargetOptions {
  85872. /**
  85873. * Define if the texture needs to create mip maps after render.
  85874. */
  85875. generateMipMaps?: boolean;
  85876. /**
  85877. * Define the types of all the draw buffers we want to create
  85878. */
  85879. types?: number[];
  85880. /**
  85881. * Define the sampling modes of all the draw buffers we want to create
  85882. */
  85883. samplingModes?: number[];
  85884. /**
  85885. * Define if a depth buffer is required
  85886. */
  85887. generateDepthBuffer?: boolean;
  85888. /**
  85889. * Define if a stencil buffer is required
  85890. */
  85891. generateStencilBuffer?: boolean;
  85892. /**
  85893. * Define if a depth texture is required instead of a depth buffer
  85894. */
  85895. generateDepthTexture?: boolean;
  85896. /**
  85897. * Define the number of desired draw buffers
  85898. */
  85899. textureCount?: number;
  85900. /**
  85901. * Define if aspect ratio should be adapted to the texture or stay the scene one
  85902. */
  85903. doNotChangeAspectRatio?: boolean;
  85904. /**
  85905. * Define the default type of the buffers we are creating
  85906. */
  85907. defaultType?: number;
  85908. }
  85909. /**
  85910. * A multi render target, like a render target provides the ability to render to a texture.
  85911. * Unlike the render target, it can render to several draw buffers in one draw.
  85912. * This is specially interesting in deferred rendering or for any effects requiring more than
  85913. * just one color from a single pass.
  85914. */
  85915. export class MultiRenderTarget extends RenderTargetTexture {
  85916. private _internalTextures;
  85917. private _textures;
  85918. private _multiRenderTargetOptions;
  85919. /**
  85920. * Get if draw buffers are currently supported by the used hardware and browser.
  85921. */
  85922. readonly isSupported: boolean;
  85923. /**
  85924. * Get the list of textures generated by the multi render target.
  85925. */
  85926. readonly textures: Texture[];
  85927. /**
  85928. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  85929. */
  85930. readonly depthTexture: Texture;
  85931. /**
  85932. * Set the wrapping mode on U of all the textures we are rendering to.
  85933. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85934. */
  85935. wrapU: number;
  85936. /**
  85937. * Set the wrapping mode on V of all the textures we are rendering to.
  85938. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  85939. */
  85940. wrapV: number;
  85941. /**
  85942. * Instantiate a new multi render target texture.
  85943. * A multi render target, like a render target provides the ability to render to a texture.
  85944. * Unlike the render target, it can render to several draw buffers in one draw.
  85945. * This is specially interesting in deferred rendering or for any effects requiring more than
  85946. * just one color from a single pass.
  85947. * @param name Define the name of the texture
  85948. * @param size Define the size of the buffers to render to
  85949. * @param count Define the number of target we are rendering into
  85950. * @param scene Define the scene the texture belongs to
  85951. * @param options Define the options used to create the multi render target
  85952. */
  85953. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  85954. /** @hidden */
  85955. _rebuild(): void;
  85956. private _createInternalTextures;
  85957. private _createTextures;
  85958. /**
  85959. * Define the number of samples used if MSAA is enabled.
  85960. */
  85961. samples: number;
  85962. /**
  85963. * Resize all the textures in the multi render target.
  85964. * Be carrefull as it will recreate all the data in the new texture.
  85965. * @param size Define the new size
  85966. */
  85967. resize(size: any): void;
  85968. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  85969. /**
  85970. * Dispose the render targets and their associated resources
  85971. */
  85972. dispose(): void;
  85973. /**
  85974. * Release all the underlying texture used as draw buffers.
  85975. */
  85976. releaseInternalTextures(): void;
  85977. }
  85978. }
  85979. declare module BABYLON {
  85980. /**
  85981. * Class used to work with sound analyzer using fast fourier transform (FFT)
  85982. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  85983. */
  85984. export class Analyser {
  85985. /**
  85986. * Gets or sets the smoothing
  85987. * @ignorenaming
  85988. */
  85989. SMOOTHING: number;
  85990. /**
  85991. * Gets or sets the FFT table size
  85992. * @ignorenaming
  85993. */
  85994. FFT_SIZE: number;
  85995. /**
  85996. * Gets or sets the bar graph amplitude
  85997. * @ignorenaming
  85998. */
  85999. BARGRAPHAMPLITUDE: number;
  86000. /**
  86001. * Gets or sets the position of the debug canvas
  86002. * @ignorenaming
  86003. */
  86004. DEBUGCANVASPOS: {
  86005. x: number;
  86006. y: number;
  86007. };
  86008. /**
  86009. * Gets or sets the debug canvas size
  86010. * @ignorenaming
  86011. */
  86012. DEBUGCANVASSIZE: {
  86013. width: number;
  86014. height: number;
  86015. };
  86016. private _byteFreqs;
  86017. private _byteTime;
  86018. private _floatFreqs;
  86019. private _webAudioAnalyser;
  86020. private _debugCanvas;
  86021. private _debugCanvasContext;
  86022. private _scene;
  86023. private _registerFunc;
  86024. private _audioEngine;
  86025. /**
  86026. * Creates a new analyser
  86027. * @param scene defines hosting scene
  86028. */
  86029. constructor(scene: Scene);
  86030. /**
  86031. * Get the number of data values you will have to play with for the visualization
  86032. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  86033. * @returns a number
  86034. */
  86035. getFrequencyBinCount(): number;
  86036. /**
  86037. * Gets the current frequency data as a byte array
  86038. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86039. * @returns a Uint8Array
  86040. */
  86041. getByteFrequencyData(): Uint8Array;
  86042. /**
  86043. * Gets the current waveform as a byte array
  86044. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  86045. * @returns a Uint8Array
  86046. */
  86047. getByteTimeDomainData(): Uint8Array;
  86048. /**
  86049. * Gets the current frequency data as a float array
  86050. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  86051. * @returns a Float32Array
  86052. */
  86053. getFloatFrequencyData(): Float32Array;
  86054. /**
  86055. * Renders the debug canvas
  86056. */
  86057. drawDebugCanvas(): void;
  86058. /**
  86059. * Stops rendering the debug canvas and removes it
  86060. */
  86061. stopDebugCanvas(): void;
  86062. /**
  86063. * Connects two audio nodes
  86064. * @param inputAudioNode defines first node to connect
  86065. * @param outputAudioNode defines second node to connect
  86066. */
  86067. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  86068. /**
  86069. * Releases all associated resources
  86070. */
  86071. dispose(): void;
  86072. }
  86073. }
  86074. declare module BABYLON {
  86075. /**
  86076. * This represents an audio engine and it is responsible
  86077. * to play, synchronize and analyse sounds throughout the application.
  86078. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86079. */
  86080. export interface IAudioEngine extends IDisposable {
  86081. /**
  86082. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86083. */
  86084. readonly canUseWebAudio: boolean;
  86085. /**
  86086. * Gets the current AudioContext if available.
  86087. */
  86088. readonly audioContext: Nullable<AudioContext>;
  86089. /**
  86090. * The master gain node defines the global audio volume of your audio engine.
  86091. */
  86092. readonly masterGain: GainNode;
  86093. /**
  86094. * Gets whether or not mp3 are supported by your browser.
  86095. */
  86096. readonly isMP3supported: boolean;
  86097. /**
  86098. * Gets whether or not ogg are supported by your browser.
  86099. */
  86100. readonly isOGGsupported: boolean;
  86101. /**
  86102. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86103. * @ignoreNaming
  86104. */
  86105. WarnedWebAudioUnsupported: boolean;
  86106. /**
  86107. * Defines if the audio engine relies on a custom unlocked button.
  86108. * In this case, the embedded button will not be displayed.
  86109. */
  86110. useCustomUnlockedButton: boolean;
  86111. /**
  86112. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  86113. */
  86114. readonly unlocked: boolean;
  86115. /**
  86116. * Event raised when audio has been unlocked on the browser.
  86117. */
  86118. onAudioUnlockedObservable: Observable<AudioEngine>;
  86119. /**
  86120. * Event raised when audio has been locked on the browser.
  86121. */
  86122. onAudioLockedObservable: Observable<AudioEngine>;
  86123. /**
  86124. * Flags the audio engine in Locked state.
  86125. * This happens due to new browser policies preventing audio to autoplay.
  86126. */
  86127. lock(): void;
  86128. /**
  86129. * Unlocks the audio engine once a user action has been done on the dom.
  86130. * This is helpful to resume play once browser policies have been satisfied.
  86131. */
  86132. unlock(): void;
  86133. }
  86134. /**
  86135. * This represents the default audio engine used in babylon.
  86136. * It is responsible to play, synchronize and analyse sounds throughout the application.
  86137. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86138. */
  86139. export class AudioEngine implements IAudioEngine {
  86140. private _audioContext;
  86141. private _audioContextInitialized;
  86142. private _muteButton;
  86143. private _hostElement;
  86144. /**
  86145. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  86146. */
  86147. canUseWebAudio: boolean;
  86148. /**
  86149. * The master gain node defines the global audio volume of your audio engine.
  86150. */
  86151. masterGain: GainNode;
  86152. /**
  86153. * Defines if Babylon should emit a warning if WebAudio is not supported.
  86154. * @ignoreNaming
  86155. */
  86156. WarnedWebAudioUnsupported: boolean;
  86157. /**
  86158. * Gets whether or not mp3 are supported by your browser.
  86159. */
  86160. isMP3supported: boolean;
  86161. /**
  86162. * Gets whether or not ogg are supported by your browser.
  86163. */
  86164. isOGGsupported: boolean;
  86165. /**
  86166. * Gets whether audio has been unlocked on the device.
  86167. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  86168. * a user interaction has happened.
  86169. */
  86170. unlocked: boolean;
  86171. /**
  86172. * Defines if the audio engine relies on a custom unlocked button.
  86173. * In this case, the embedded button will not be displayed.
  86174. */
  86175. useCustomUnlockedButton: boolean;
  86176. /**
  86177. * Event raised when audio has been unlocked on the browser.
  86178. */
  86179. onAudioUnlockedObservable: Observable<AudioEngine>;
  86180. /**
  86181. * Event raised when audio has been locked on the browser.
  86182. */
  86183. onAudioLockedObservable: Observable<AudioEngine>;
  86184. /**
  86185. * Gets the current AudioContext if available.
  86186. */
  86187. readonly audioContext: Nullable<AudioContext>;
  86188. private _connectedAnalyser;
  86189. /**
  86190. * Instantiates a new audio engine.
  86191. *
  86192. * There should be only one per page as some browsers restrict the number
  86193. * of audio contexts you can create.
  86194. * @param hostElement defines the host element where to display the mute icon if necessary
  86195. */
  86196. constructor(hostElement?: Nullable<HTMLElement>);
  86197. /**
  86198. * Flags the audio engine in Locked state.
  86199. * This happens due to new browser policies preventing audio to autoplay.
  86200. */
  86201. lock(): void;
  86202. /**
  86203. * Unlocks the audio engine once a user action has been done on the dom.
  86204. * This is helpful to resume play once browser policies have been satisfied.
  86205. */
  86206. unlock(): void;
  86207. private _resumeAudioContext;
  86208. private _initializeAudioContext;
  86209. private _tryToRun;
  86210. private _triggerRunningState;
  86211. private _triggerSuspendedState;
  86212. private _displayMuteButton;
  86213. private _moveButtonToTopLeft;
  86214. private _onResize;
  86215. private _hideMuteButton;
  86216. /**
  86217. * Destroy and release the resources associated with the audio ccontext.
  86218. */
  86219. dispose(): void;
  86220. /**
  86221. * Gets the global volume sets on the master gain.
  86222. * @returns the global volume if set or -1 otherwise
  86223. */
  86224. getGlobalVolume(): number;
  86225. /**
  86226. * Sets the global volume of your experience (sets on the master gain).
  86227. * @param newVolume Defines the new global volume of the application
  86228. */
  86229. setGlobalVolume(newVolume: number): void;
  86230. /**
  86231. * Connect the audio engine to an audio analyser allowing some amazing
  86232. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  86233. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  86234. * @param analyser The analyser to connect to the engine
  86235. */
  86236. connectToAnalyser(analyser: Analyser): void;
  86237. }
  86238. }
  86239. declare module BABYLON {
  86240. /**
  86241. * Interface used to present a loading screen while loading a scene
  86242. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86243. */
  86244. export interface ILoadingScreen {
  86245. /**
  86246. * Function called to display the loading screen
  86247. */
  86248. displayLoadingUI: () => void;
  86249. /**
  86250. * Function called to hide the loading screen
  86251. */
  86252. hideLoadingUI: () => void;
  86253. /**
  86254. * Gets or sets the color to use for the background
  86255. */
  86256. loadingUIBackgroundColor: string;
  86257. /**
  86258. * Gets or sets the text to display while loading
  86259. */
  86260. loadingUIText: string;
  86261. }
  86262. /**
  86263. * Class used for the default loading screen
  86264. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  86265. */
  86266. export class DefaultLoadingScreen implements ILoadingScreen {
  86267. private _renderingCanvas;
  86268. private _loadingText;
  86269. private _loadingDivBackgroundColor;
  86270. private _loadingDiv;
  86271. private _loadingTextDiv;
  86272. /**
  86273. * Creates a new default loading screen
  86274. * @param _renderingCanvas defines the canvas used to render the scene
  86275. * @param _loadingText defines the default text to display
  86276. * @param _loadingDivBackgroundColor defines the default background color
  86277. */
  86278. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  86279. /**
  86280. * Function called to display the loading screen
  86281. */
  86282. displayLoadingUI(): void;
  86283. /**
  86284. * Function called to hide the loading screen
  86285. */
  86286. hideLoadingUI(): void;
  86287. /**
  86288. * Gets or sets the text to display while loading
  86289. */
  86290. loadingUIText: string;
  86291. /**
  86292. * Gets or sets the color to use for the background
  86293. */
  86294. loadingUIBackgroundColor: string;
  86295. private _resizeLoadingUI;
  86296. }
  86297. }
  86298. declare module BABYLON {
  86299. /**
  86300. * Settings for finer control over video usage
  86301. */
  86302. export interface VideoTextureSettings {
  86303. /**
  86304. * Applies `autoplay` to video, if specified
  86305. */
  86306. autoPlay?: boolean;
  86307. /**
  86308. * Applies `loop` to video, if specified
  86309. */
  86310. loop?: boolean;
  86311. /**
  86312. * Automatically updates internal texture from video at every frame in the render loop
  86313. */
  86314. autoUpdateTexture: boolean;
  86315. /**
  86316. * Image src displayed during the video loading or until the user interacts with the video.
  86317. */
  86318. poster?: string;
  86319. }
  86320. /**
  86321. * If you want to display a video in your scene, this is the special texture for that.
  86322. * This special texture works similar to other textures, with the exception of a few parameters.
  86323. * @see https://doc.babylonjs.com/how_to/video_texture
  86324. */
  86325. export class VideoTexture extends Texture {
  86326. /**
  86327. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  86328. */
  86329. readonly autoUpdateTexture: boolean;
  86330. /**
  86331. * The video instance used by the texture internally
  86332. */
  86333. readonly video: HTMLVideoElement;
  86334. private _onUserActionRequestedObservable;
  86335. /**
  86336. * Event triggerd when a dom action is required by the user to play the video.
  86337. * This happens due to recent changes in browser policies preventing video to auto start.
  86338. */
  86339. readonly onUserActionRequestedObservable: Observable<Texture>;
  86340. private _generateMipMaps;
  86341. private _engine;
  86342. private _stillImageCaptured;
  86343. private _displayingPosterTexture;
  86344. private _settings;
  86345. private _createInternalTextureOnEvent;
  86346. /**
  86347. * Creates a video texture.
  86348. * If you want to display a video in your scene, this is the special texture for that.
  86349. * This special texture works similar to other textures, with the exception of a few parameters.
  86350. * @see https://doc.babylonjs.com/how_to/video_texture
  86351. * @param name optional name, will detect from video source, if not defined
  86352. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  86353. * @param scene is obviously the current scene.
  86354. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  86355. * @param invertY is false by default but can be used to invert video on Y axis
  86356. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  86357. * @param settings allows finer control over video usage
  86358. */
  86359. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  86360. private _getName;
  86361. private _getVideo;
  86362. private _createInternalTexture;
  86363. private reset;
  86364. /**
  86365. * @hidden Internal method to initiate `update`.
  86366. */
  86367. _rebuild(): void;
  86368. /**
  86369. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  86370. */
  86371. update(): void;
  86372. /**
  86373. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  86374. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  86375. */
  86376. updateTexture(isVisible: boolean): void;
  86377. protected _updateInternalTexture: () => void;
  86378. /**
  86379. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  86380. * @param url New url.
  86381. */
  86382. updateURL(url: string): void;
  86383. /**
  86384. * Dispose the texture and release its associated resources.
  86385. */
  86386. dispose(): void;
  86387. /**
  86388. * Creates a video texture straight from a stream.
  86389. * @param scene Define the scene the texture should be created in
  86390. * @param stream Define the stream the texture should be created from
  86391. * @returns The created video texture as a promise
  86392. */
  86393. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  86394. /**
  86395. * Creates a video texture straight from your WebCam video feed.
  86396. * @param scene Define the scene the texture should be created in
  86397. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86398. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86399. * @returns The created video texture as a promise
  86400. */
  86401. static CreateFromWebCamAsync(scene: Scene, constraints: {
  86402. minWidth: number;
  86403. maxWidth: number;
  86404. minHeight: number;
  86405. maxHeight: number;
  86406. deviceId: string;
  86407. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  86408. /**
  86409. * Creates a video texture straight from your WebCam video feed.
  86410. * @param scene Define the scene the texture should be created in
  86411. * @param onReady Define a callback to triggered once the texture will be ready
  86412. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  86413. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  86414. */
  86415. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  86416. minWidth: number;
  86417. maxWidth: number;
  86418. minHeight: number;
  86419. maxHeight: number;
  86420. deviceId: string;
  86421. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  86422. }
  86423. }
  86424. declare module BABYLON {
  86425. /**
  86426. * Interface for attribute information associated with buffer instanciation
  86427. */
  86428. export class InstancingAttributeInfo {
  86429. /**
  86430. * Index/offset of the attribute in the vertex shader
  86431. */
  86432. index: number;
  86433. /**
  86434. * size of the attribute, 1, 2, 3 or 4
  86435. */
  86436. attributeSize: number;
  86437. /**
  86438. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  86439. * default is FLOAT
  86440. */
  86441. attribyteType: number;
  86442. /**
  86443. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  86444. */
  86445. normalized: boolean;
  86446. /**
  86447. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  86448. */
  86449. offset: number;
  86450. /**
  86451. * Name of the GLSL attribute, for debugging purpose only
  86452. */
  86453. attributeName: string;
  86454. }
  86455. /**
  86456. * Define options used to create a depth texture
  86457. */
  86458. export class DepthTextureCreationOptions {
  86459. /** Specifies whether or not a stencil should be allocated in the texture */
  86460. generateStencil?: boolean;
  86461. /** Specifies whether or not bilinear filtering is enable on the texture */
  86462. bilinearFiltering?: boolean;
  86463. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  86464. comparisonFunction?: number;
  86465. /** Specifies if the created texture is a cube texture */
  86466. isCube?: boolean;
  86467. }
  86468. /**
  86469. * Class used to describe the capabilities of the engine relatively to the current browser
  86470. */
  86471. export class EngineCapabilities {
  86472. /** Maximum textures units per fragment shader */
  86473. maxTexturesImageUnits: number;
  86474. /** Maximum texture units per vertex shader */
  86475. maxVertexTextureImageUnits: number;
  86476. /** Maximum textures units in the entire pipeline */
  86477. maxCombinedTexturesImageUnits: number;
  86478. /** Maximum texture size */
  86479. maxTextureSize: number;
  86480. /** Maximum cube texture size */
  86481. maxCubemapTextureSize: number;
  86482. /** Maximum render texture size */
  86483. maxRenderTextureSize: number;
  86484. /** Maximum number of vertex attributes */
  86485. maxVertexAttribs: number;
  86486. /** Maximum number of varyings */
  86487. maxVaryingVectors: number;
  86488. /** Maximum number of uniforms per vertex shader */
  86489. maxVertexUniformVectors: number;
  86490. /** Maximum number of uniforms per fragment shader */
  86491. maxFragmentUniformVectors: number;
  86492. /** Defines if standard derivates (dx/dy) are supported */
  86493. standardDerivatives: boolean;
  86494. /** Defines if s3tc texture compression is supported */
  86495. s3tc: Nullable<WEBGL_compressed_texture_s3tc>;
  86496. /** Defines if pvrtc texture compression is supported */
  86497. pvrtc: any;
  86498. /** Defines if etc1 texture compression is supported */
  86499. etc1: any;
  86500. /** Defines if etc2 texture compression is supported */
  86501. etc2: any;
  86502. /** Defines if astc texture compression is supported */
  86503. astc: any;
  86504. /** Defines if float textures are supported */
  86505. textureFloat: boolean;
  86506. /** Defines if vertex array objects are supported */
  86507. vertexArrayObject: boolean;
  86508. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  86509. textureAnisotropicFilterExtension: Nullable<EXT_texture_filter_anisotropic>;
  86510. /** Gets the maximum level of anisotropy supported */
  86511. maxAnisotropy: number;
  86512. /** Defines if instancing is supported */
  86513. instancedArrays: boolean;
  86514. /** Defines if 32 bits indices are supported */
  86515. uintIndices: boolean;
  86516. /** Defines if high precision shaders are supported */
  86517. highPrecisionShaderSupported: boolean;
  86518. /** Defines if depth reading in the fragment shader is supported */
  86519. fragmentDepthSupported: boolean;
  86520. /** Defines if float texture linear filtering is supported*/
  86521. textureFloatLinearFiltering: boolean;
  86522. /** Defines if rendering to float textures is supported */
  86523. textureFloatRender: boolean;
  86524. /** Defines if half float textures are supported*/
  86525. textureHalfFloat: boolean;
  86526. /** Defines if half float texture linear filtering is supported*/
  86527. textureHalfFloatLinearFiltering: boolean;
  86528. /** Defines if rendering to half float textures is supported */
  86529. textureHalfFloatRender: boolean;
  86530. /** Defines if textureLOD shader command is supported */
  86531. textureLOD: boolean;
  86532. /** Defines if draw buffers extension is supported */
  86533. drawBuffersExtension: boolean;
  86534. /** Defines if depth textures are supported */
  86535. depthTextureExtension: boolean;
  86536. /** Defines if float color buffer are supported */
  86537. colorBufferFloat: boolean;
  86538. /** Gets disjoint timer query extension (null if not supported) */
  86539. timerQuery: EXT_disjoint_timer_query;
  86540. /** Defines if timestamp can be used with timer query */
  86541. canUseTimestampForTimerQuery: boolean;
  86542. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  86543. multiview: any;
  86544. /** Function used to let the system compiles shaders in background */
  86545. parallelShaderCompile: {
  86546. COMPLETION_STATUS_KHR: number;
  86547. };
  86548. }
  86549. /** Interface defining initialization parameters for Engine class */
  86550. export interface EngineOptions extends WebGLContextAttributes {
  86551. /**
  86552. * Defines if the engine should no exceed a specified device ratio
  86553. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  86554. */
  86555. limitDeviceRatio?: number;
  86556. /**
  86557. * Defines if webvr should be enabled automatically
  86558. * @see http://doc.babylonjs.com/how_to/webvr_camera
  86559. */
  86560. autoEnableWebVR?: boolean;
  86561. /**
  86562. * Defines if webgl2 should be turned off even if supported
  86563. * @see http://doc.babylonjs.com/features/webgl2
  86564. */
  86565. disableWebGL2Support?: boolean;
  86566. /**
  86567. * Defines if webaudio should be initialized as well
  86568. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86569. */
  86570. audioEngine?: boolean;
  86571. /**
  86572. * Defines if animations should run using a deterministic lock step
  86573. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  86574. */
  86575. deterministicLockstep?: boolean;
  86576. /** Defines the maximum steps to use with deterministic lock step mode */
  86577. lockstepMaxSteps?: number;
  86578. /**
  86579. * Defines that engine should ignore context lost events
  86580. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  86581. */
  86582. doNotHandleContextLost?: boolean;
  86583. /**
  86584. * Defines that engine should ignore modifying touch action attribute and style
  86585. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  86586. */
  86587. doNotHandleTouchAction?: boolean;
  86588. /**
  86589. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  86590. */
  86591. useHighPrecisionFloats?: boolean;
  86592. }
  86593. /**
  86594. * Defines the interface used by display changed events
  86595. */
  86596. export interface IDisplayChangedEventArgs {
  86597. /** Gets the vrDisplay object (if any) */
  86598. vrDisplay: Nullable<any>;
  86599. /** Gets a boolean indicating if webVR is supported */
  86600. vrSupported: boolean;
  86601. }
  86602. /**
  86603. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  86604. */
  86605. export class Engine {
  86606. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  86607. static ExceptionList: ({
  86608. key: string;
  86609. capture: string;
  86610. captureConstraint: number;
  86611. targets: string[];
  86612. } | {
  86613. key: string;
  86614. capture: null;
  86615. captureConstraint: null;
  86616. targets: string[];
  86617. })[];
  86618. /** Gets the list of created engines */
  86619. static readonly Instances: Engine[];
  86620. /**
  86621. * Gets the latest created engine
  86622. */
  86623. static readonly LastCreatedEngine: Nullable<Engine>;
  86624. /**
  86625. * Gets the latest created scene
  86626. */
  86627. static readonly LastCreatedScene: Nullable<Scene>;
  86628. /**
  86629. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  86630. * @param flag defines which part of the materials must be marked as dirty
  86631. * @param predicate defines a predicate used to filter which materials should be affected
  86632. */
  86633. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  86634. /**
  86635. * Hidden
  86636. */
  86637. static _TextureLoaders: IInternalTextureLoader[];
  86638. /** Defines that alpha blending is disabled */
  86639. static readonly ALPHA_DISABLE: number;
  86640. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  86641. static readonly ALPHA_ADD: number;
  86642. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  86643. static readonly ALPHA_COMBINE: number;
  86644. /** Defines that alpha blending to DEST - SRC * DEST */
  86645. static readonly ALPHA_SUBTRACT: number;
  86646. /** Defines that alpha blending to SRC * DEST */
  86647. static readonly ALPHA_MULTIPLY: number;
  86648. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  86649. static readonly ALPHA_MAXIMIZED: number;
  86650. /** Defines that alpha blending to SRC + DEST */
  86651. static readonly ALPHA_ONEONE: number;
  86652. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  86653. static readonly ALPHA_PREMULTIPLIED: number;
  86654. /**
  86655. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  86656. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  86657. */
  86658. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  86659. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  86660. static readonly ALPHA_INTERPOLATE: number;
  86661. /**
  86662. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  86663. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  86664. */
  86665. static readonly ALPHA_SCREENMODE: number;
  86666. /** Defines that the ressource is not delayed*/
  86667. static readonly DELAYLOADSTATE_NONE: number;
  86668. /** Defines that the ressource was successfully delay loaded */
  86669. static readonly DELAYLOADSTATE_LOADED: number;
  86670. /** Defines that the ressource is currently delay loading */
  86671. static readonly DELAYLOADSTATE_LOADING: number;
  86672. /** Defines that the ressource is delayed and has not started loading */
  86673. static readonly DELAYLOADSTATE_NOTLOADED: number;
  86674. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  86675. static readonly NEVER: number;
  86676. /** 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 */
  86677. static readonly ALWAYS: number;
  86678. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  86679. static readonly LESS: number;
  86680. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  86681. static readonly EQUAL: number;
  86682. /** 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 */
  86683. static readonly LEQUAL: number;
  86684. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  86685. static readonly GREATER: number;
  86686. /** 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 */
  86687. static readonly GEQUAL: number;
  86688. /** 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 */
  86689. static readonly NOTEQUAL: number;
  86690. /** Passed to stencilOperation to specify that stencil value must be kept */
  86691. static readonly KEEP: number;
  86692. /** Passed to stencilOperation to specify that stencil value must be replaced */
  86693. static readonly REPLACE: number;
  86694. /** Passed to stencilOperation to specify that stencil value must be incremented */
  86695. static readonly INCR: number;
  86696. /** Passed to stencilOperation to specify that stencil value must be decremented */
  86697. static readonly DECR: number;
  86698. /** Passed to stencilOperation to specify that stencil value must be inverted */
  86699. static readonly INVERT: number;
  86700. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  86701. static readonly INCR_WRAP: number;
  86702. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  86703. static readonly DECR_WRAP: number;
  86704. /** Texture is not repeating outside of 0..1 UVs */
  86705. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  86706. /** Texture is repeating outside of 0..1 UVs */
  86707. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  86708. /** Texture is repeating and mirrored */
  86709. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  86710. /** ALPHA */
  86711. static readonly TEXTUREFORMAT_ALPHA: number;
  86712. /** LUMINANCE */
  86713. static readonly TEXTUREFORMAT_LUMINANCE: number;
  86714. /** LUMINANCE_ALPHA */
  86715. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  86716. /** RGB */
  86717. static readonly TEXTUREFORMAT_RGB: number;
  86718. /** RGBA */
  86719. static readonly TEXTUREFORMAT_RGBA: number;
  86720. /** RED */
  86721. static readonly TEXTUREFORMAT_RED: number;
  86722. /** RED (2nd reference) */
  86723. static readonly TEXTUREFORMAT_R: number;
  86724. /** RG */
  86725. static readonly TEXTUREFORMAT_RG: number;
  86726. /** RED_INTEGER */
  86727. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  86728. /** RED_INTEGER (2nd reference) */
  86729. static readonly TEXTUREFORMAT_R_INTEGER: number;
  86730. /** RG_INTEGER */
  86731. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  86732. /** RGB_INTEGER */
  86733. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  86734. /** RGBA_INTEGER */
  86735. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  86736. /** UNSIGNED_BYTE */
  86737. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  86738. /** UNSIGNED_BYTE (2nd reference) */
  86739. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  86740. /** FLOAT */
  86741. static readonly TEXTURETYPE_FLOAT: number;
  86742. /** HALF_FLOAT */
  86743. static readonly TEXTURETYPE_HALF_FLOAT: number;
  86744. /** BYTE */
  86745. static readonly TEXTURETYPE_BYTE: number;
  86746. /** SHORT */
  86747. static readonly TEXTURETYPE_SHORT: number;
  86748. /** UNSIGNED_SHORT */
  86749. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  86750. /** INT */
  86751. static readonly TEXTURETYPE_INT: number;
  86752. /** UNSIGNED_INT */
  86753. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  86754. /** UNSIGNED_SHORT_4_4_4_4 */
  86755. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  86756. /** UNSIGNED_SHORT_5_5_5_1 */
  86757. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  86758. /** UNSIGNED_SHORT_5_6_5 */
  86759. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  86760. /** UNSIGNED_INT_2_10_10_10_REV */
  86761. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  86762. /** UNSIGNED_INT_24_8 */
  86763. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  86764. /** UNSIGNED_INT_10F_11F_11F_REV */
  86765. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  86766. /** UNSIGNED_INT_5_9_9_9_REV */
  86767. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  86768. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  86769. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  86770. /** nearest is mag = nearest and min = nearest and mip = linear */
  86771. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  86772. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86773. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  86774. /** Trilinear is mag = linear and min = linear and mip = linear */
  86775. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  86776. /** nearest is mag = nearest and min = nearest and mip = linear */
  86777. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  86778. /** Bilinear is mag = linear and min = linear and mip = nearest */
  86779. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  86780. /** Trilinear is mag = linear and min = linear and mip = linear */
  86781. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  86782. /** mag = nearest and min = nearest and mip = nearest */
  86783. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  86784. /** mag = nearest and min = linear and mip = nearest */
  86785. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  86786. /** mag = nearest and min = linear and mip = linear */
  86787. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  86788. /** mag = nearest and min = linear and mip = none */
  86789. static readonly TEXTURE_NEAREST_LINEAR: number;
  86790. /** mag = nearest and min = nearest and mip = none */
  86791. static readonly TEXTURE_NEAREST_NEAREST: number;
  86792. /** mag = linear and min = nearest and mip = nearest */
  86793. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  86794. /** mag = linear and min = nearest and mip = linear */
  86795. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  86796. /** mag = linear and min = linear and mip = none */
  86797. static readonly TEXTURE_LINEAR_LINEAR: number;
  86798. /** mag = linear and min = nearest and mip = none */
  86799. static readonly TEXTURE_LINEAR_NEAREST: number;
  86800. /** Explicit coordinates mode */
  86801. static readonly TEXTURE_EXPLICIT_MODE: number;
  86802. /** Spherical coordinates mode */
  86803. static readonly TEXTURE_SPHERICAL_MODE: number;
  86804. /** Planar coordinates mode */
  86805. static readonly TEXTURE_PLANAR_MODE: number;
  86806. /** Cubic coordinates mode */
  86807. static readonly TEXTURE_CUBIC_MODE: number;
  86808. /** Projection coordinates mode */
  86809. static readonly TEXTURE_PROJECTION_MODE: number;
  86810. /** Skybox coordinates mode */
  86811. static readonly TEXTURE_SKYBOX_MODE: number;
  86812. /** Inverse Cubic coordinates mode */
  86813. static readonly TEXTURE_INVCUBIC_MODE: number;
  86814. /** Equirectangular coordinates mode */
  86815. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  86816. /** Equirectangular Fixed coordinates mode */
  86817. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  86818. /** Equirectangular Fixed Mirrored coordinates mode */
  86819. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  86820. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  86821. static readonly SCALEMODE_FLOOR: number;
  86822. /** Defines that texture rescaling will look for the nearest power of 2 size */
  86823. static readonly SCALEMODE_NEAREST: number;
  86824. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  86825. static readonly SCALEMODE_CEILING: number;
  86826. /**
  86827. * Returns the current npm package of the sdk
  86828. */
  86829. static readonly NpmPackage: string;
  86830. /**
  86831. * Returns the current version of the framework
  86832. */
  86833. static readonly Version: string;
  86834. /**
  86835. * Returns a string describing the current engine
  86836. */
  86837. readonly description: string;
  86838. /**
  86839. * Gets or sets the epsilon value used by collision engine
  86840. */
  86841. static CollisionsEpsilon: number;
  86842. /**
  86843. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  86844. */
  86845. static ShadersRepository: string;
  86846. /**
  86847. * Method called to create the default loading screen.
  86848. * This can be overriden in your own app.
  86849. * @param canvas The rendering canvas element
  86850. * @returns The loading screen
  86851. */
  86852. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  86853. /**
  86854. * Method called to create the default rescale post process on each engine.
  86855. */
  86856. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  86857. /**
  86858. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  86859. */
  86860. forcePOTTextures: boolean;
  86861. /**
  86862. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  86863. */
  86864. isFullscreen: boolean;
  86865. /**
  86866. * Gets a boolean indicating if the pointer is currently locked
  86867. */
  86868. isPointerLock: boolean;
  86869. /**
  86870. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  86871. */
  86872. cullBackFaces: boolean;
  86873. /**
  86874. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  86875. */
  86876. renderEvenInBackground: boolean;
  86877. /**
  86878. * Gets or sets a boolean indicating that cache can be kept between frames
  86879. */
  86880. preventCacheWipeBetweenFrames: boolean;
  86881. /**
  86882. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  86883. **/
  86884. enableOfflineSupport: boolean;
  86885. /**
  86886. * 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)
  86887. **/
  86888. disableManifestCheck: boolean;
  86889. /**
  86890. * Gets the list of created scenes
  86891. */
  86892. scenes: Scene[];
  86893. /**
  86894. * Event raised when a new scene is created
  86895. */
  86896. onNewSceneAddedObservable: Observable<Scene>;
  86897. /**
  86898. * Gets the list of created postprocesses
  86899. */
  86900. postProcesses: PostProcess[];
  86901. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  86902. validateShaderPrograms: boolean;
  86903. /**
  86904. * Observable event triggered each time the rendering canvas is resized
  86905. */
  86906. onResizeObservable: Observable<Engine>;
  86907. /**
  86908. * Observable event triggered each time the canvas loses focus
  86909. */
  86910. onCanvasBlurObservable: Observable<Engine>;
  86911. /**
  86912. * Observable event triggered each time the canvas gains focus
  86913. */
  86914. onCanvasFocusObservable: Observable<Engine>;
  86915. /**
  86916. * Observable event triggered each time the canvas receives pointerout event
  86917. */
  86918. onCanvasPointerOutObservable: Observable<PointerEvent>;
  86919. /**
  86920. * Observable event triggered before each texture is initialized
  86921. */
  86922. onBeforeTextureInitObservable: Observable<Texture>;
  86923. private _vrDisplay;
  86924. private _vrSupported;
  86925. private _oldSize;
  86926. private _oldHardwareScaleFactor;
  86927. private _vrExclusivePointerMode;
  86928. private _webVRInitPromise;
  86929. /**
  86930. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  86931. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  86932. */
  86933. readonly isInVRExclusivePointerMode: boolean;
  86934. /**
  86935. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  86936. */
  86937. disableUniformBuffers: boolean;
  86938. /** @hidden */
  86939. _uniformBuffers: UniformBuffer[];
  86940. /**
  86941. * Gets a boolean indicating that the engine supports uniform buffers
  86942. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  86943. */
  86944. readonly supportsUniformBuffers: boolean;
  86945. /**
  86946. * Observable raised when the engine begins a new frame
  86947. */
  86948. onBeginFrameObservable: Observable<Engine>;
  86949. /**
  86950. * If set, will be used to request the next animation frame for the render loop
  86951. */
  86952. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  86953. /**
  86954. * Observable raised when the engine ends the current frame
  86955. */
  86956. onEndFrameObservable: Observable<Engine>;
  86957. /**
  86958. * Observable raised when the engine is about to compile a shader
  86959. */
  86960. onBeforeShaderCompilationObservable: Observable<Engine>;
  86961. /**
  86962. * Observable raised when the engine has jsut compiled a shader
  86963. */
  86964. onAfterShaderCompilationObservable: Observable<Engine>;
  86965. /** @hidden */
  86966. _gl: WebGLRenderingContext;
  86967. private _renderingCanvas;
  86968. private _windowIsBackground;
  86969. private _webGLVersion;
  86970. protected _highPrecisionShadersAllowed: boolean;
  86971. /** @hidden */
  86972. readonly _shouldUseHighPrecisionShader: boolean;
  86973. /**
  86974. * Gets a boolean indicating that only power of 2 textures are supported
  86975. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  86976. */
  86977. readonly needPOTTextures: boolean;
  86978. /** @hidden */
  86979. _badOS: boolean;
  86980. /** @hidden */
  86981. _badDesktopOS: boolean;
  86982. /**
  86983. * Gets the audio engine
  86984. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  86985. * @ignorenaming
  86986. */
  86987. static audioEngine: IAudioEngine;
  86988. /**
  86989. * Default AudioEngine factory responsible of creating the Audio Engine.
  86990. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  86991. */
  86992. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  86993. /**
  86994. * Default offline support factory responsible of creating a tool used to store data locally.
  86995. * By default, this will create a Database object if the workload has been embedded.
  86996. */
  86997. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  86998. private _onFocus;
  86999. private _onBlur;
  87000. private _onCanvasPointerOut;
  87001. private _onCanvasBlur;
  87002. private _onCanvasFocus;
  87003. private _onFullscreenChange;
  87004. private _onPointerLockChange;
  87005. private _onVRDisplayPointerRestricted;
  87006. private _onVRDisplayPointerUnrestricted;
  87007. private _onVrDisplayConnect;
  87008. private _onVrDisplayDisconnect;
  87009. private _onVrDisplayPresentChange;
  87010. /**
  87011. * Observable signaled when VR display mode changes
  87012. */
  87013. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  87014. /**
  87015. * Observable signaled when VR request present is complete
  87016. */
  87017. onVRRequestPresentComplete: Observable<boolean>;
  87018. /**
  87019. * Observable signaled when VR request present starts
  87020. */
  87021. onVRRequestPresentStart: Observable<Engine>;
  87022. private _hardwareScalingLevel;
  87023. /** @hidden */
  87024. _caps: EngineCapabilities;
  87025. private _pointerLockRequested;
  87026. private _isStencilEnable;
  87027. private _colorWrite;
  87028. private _loadingScreen;
  87029. /** @hidden */
  87030. _drawCalls: PerfCounter;
  87031. private _glVersion;
  87032. private _glRenderer;
  87033. private _glVendor;
  87034. private _videoTextureSupported;
  87035. private _renderingQueueLaunched;
  87036. private _activeRenderLoops;
  87037. private _deterministicLockstep;
  87038. private _lockstepMaxSteps;
  87039. /**
  87040. * Observable signaled when a context lost event is raised
  87041. */
  87042. onContextLostObservable: Observable<Engine>;
  87043. /**
  87044. * Observable signaled when a context restored event is raised
  87045. */
  87046. onContextRestoredObservable: Observable<Engine>;
  87047. private _onContextLost;
  87048. private _onContextRestored;
  87049. private _contextWasLost;
  87050. /** @hidden */
  87051. _doNotHandleContextLost: boolean;
  87052. /**
  87053. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  87054. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  87055. */
  87056. doNotHandleContextLost: boolean;
  87057. private _performanceMonitor;
  87058. private _fps;
  87059. private _deltaTime;
  87060. /**
  87061. * Turn this value on if you want to pause FPS computation when in background
  87062. */
  87063. disablePerformanceMonitorInBackground: boolean;
  87064. /**
  87065. * Gets the performance monitor attached to this engine
  87066. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  87067. */
  87068. readonly performanceMonitor: PerformanceMonitor;
  87069. /**
  87070. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  87071. */
  87072. disableVertexArrayObjects: boolean;
  87073. /** @hidden */
  87074. protected _depthCullingState: _DepthCullingState;
  87075. /** @hidden */
  87076. protected _stencilState: _StencilState;
  87077. /** @hidden */
  87078. protected _alphaState: _AlphaState;
  87079. /** @hidden */
  87080. protected _alphaMode: number;
  87081. /** @hidden */
  87082. _internalTexturesCache: InternalTexture[];
  87083. /** @hidden */
  87084. protected _activeChannel: number;
  87085. private _currentTextureChannel;
  87086. /** @hidden */
  87087. protected _boundTexturesCache: {
  87088. [key: string]: Nullable<InternalTexture>;
  87089. };
  87090. /** @hidden */
  87091. protected _currentEffect: Nullable<Effect>;
  87092. /** @hidden */
  87093. protected _currentProgram: Nullable<WebGLProgram>;
  87094. private _compiledEffects;
  87095. private _vertexAttribArraysEnabled;
  87096. /** @hidden */
  87097. protected _cachedViewport: Nullable<Viewport>;
  87098. private _cachedVertexArrayObject;
  87099. /** @hidden */
  87100. protected _cachedVertexBuffers: any;
  87101. /** @hidden */
  87102. protected _cachedIndexBuffer: Nullable<WebGLBuffer>;
  87103. /** @hidden */
  87104. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  87105. /** @hidden */
  87106. protected _currentRenderTarget: Nullable<InternalTexture>;
  87107. private _uintIndicesCurrentlySet;
  87108. private _currentBoundBuffer;
  87109. /** @hidden */
  87110. protected _currentFramebuffer: Nullable<WebGLFramebuffer>;
  87111. private _currentBufferPointers;
  87112. private _currentInstanceLocations;
  87113. private _currentInstanceBuffers;
  87114. private _textureUnits;
  87115. private _workingCanvas;
  87116. private _workingContext;
  87117. private _rescalePostProcess;
  87118. private _dummyFramebuffer;
  87119. private _externalData;
  87120. private _bindedRenderFunction;
  87121. private _vaoRecordInProgress;
  87122. private _mustWipeVertexAttributes;
  87123. private _emptyTexture;
  87124. private _emptyCubeTexture;
  87125. private _emptyTexture3D;
  87126. /** @hidden */
  87127. _frameHandler: number;
  87128. private _nextFreeTextureSlots;
  87129. private _maxSimultaneousTextures;
  87130. private _activeRequests;
  87131. private _texturesSupported;
  87132. private _textureFormatInUse;
  87133. /**
  87134. * Gets the list of texture formats supported
  87135. */
  87136. readonly texturesSupported: Array<string>;
  87137. /**
  87138. * Gets the list of texture formats in use
  87139. */
  87140. readonly textureFormatInUse: Nullable<string>;
  87141. /**
  87142. * Gets the current viewport
  87143. */
  87144. readonly currentViewport: Nullable<Viewport>;
  87145. /**
  87146. * Gets the default empty texture
  87147. */
  87148. readonly emptyTexture: InternalTexture;
  87149. /**
  87150. * Gets the default empty 3D texture
  87151. */
  87152. readonly emptyTexture3D: InternalTexture;
  87153. /**
  87154. * Gets the default empty cube texture
  87155. */
  87156. readonly emptyCubeTexture: InternalTexture;
  87157. /**
  87158. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  87159. */
  87160. readonly premultipliedAlpha: boolean;
  87161. /**
  87162. * Creates a new engine
  87163. * @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
  87164. * @param antialias defines enable antialiasing (default: false)
  87165. * @param options defines further options to be sent to the getContext() function
  87166. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  87167. */
  87168. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  87169. private _disableTouchAction;
  87170. private _rebuildInternalTextures;
  87171. private _rebuildEffects;
  87172. /**
  87173. * Gets a boolean indicating if all created effects are ready
  87174. * @returns true if all effects are ready
  87175. */
  87176. areAllEffectsReady(): boolean;
  87177. private _rebuildBuffers;
  87178. private _initGLContext;
  87179. /**
  87180. * Gets version of the current webGL context
  87181. */
  87182. readonly webGLVersion: number;
  87183. /**
  87184. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  87185. */
  87186. readonly isStencilEnable: boolean;
  87187. private _prepareWorkingCanvas;
  87188. /**
  87189. * Reset the texture cache to empty state
  87190. */
  87191. resetTextureCache(): void;
  87192. /**
  87193. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  87194. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87195. * @returns true if engine is in deterministic lock step mode
  87196. */
  87197. isDeterministicLockStep(): boolean;
  87198. /**
  87199. * Gets the max steps when engine is running in deterministic lock step
  87200. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  87201. * @returns the max steps
  87202. */
  87203. getLockstepMaxSteps(): number;
  87204. /**
  87205. * Gets an object containing information about the current webGL context
  87206. * @returns an object containing the vender, the renderer and the version of the current webGL context
  87207. */
  87208. getGlInfo(): {
  87209. vendor: string;
  87210. renderer: string;
  87211. version: string;
  87212. };
  87213. /**
  87214. * Gets current aspect ratio
  87215. * @param camera defines the camera to use to get the aspect ratio
  87216. * @param useScreen defines if screen size must be used (or the current render target if any)
  87217. * @returns a number defining the aspect ratio
  87218. */
  87219. getAspectRatio(camera: Camera, useScreen?: boolean): number;
  87220. /**
  87221. * Gets current screen aspect ratio
  87222. * @returns a number defining the aspect ratio
  87223. */
  87224. getScreenAspectRatio(): number;
  87225. /**
  87226. * Gets the current render width
  87227. * @param useScreen defines if screen size must be used (or the current render target if any)
  87228. * @returns a number defining the current render width
  87229. */
  87230. getRenderWidth(useScreen?: boolean): number;
  87231. /**
  87232. * Gets the current render height
  87233. * @param useScreen defines if screen size must be used (or the current render target if any)
  87234. * @returns a number defining the current render height
  87235. */
  87236. getRenderHeight(useScreen?: boolean): number;
  87237. /**
  87238. * Gets the HTML canvas attached with the current webGL context
  87239. * @returns a HTML canvas
  87240. */
  87241. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  87242. /**
  87243. * Gets the client rect of the HTML canvas attached with the current webGL context
  87244. * @returns a client rectanglee
  87245. */
  87246. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  87247. /**
  87248. * Defines the hardware scaling level.
  87249. * By default the hardware scaling level is computed from the window device ratio.
  87250. * 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.
  87251. * @param level defines the level to use
  87252. */
  87253. setHardwareScalingLevel(level: number): void;
  87254. /**
  87255. * Gets the current hardware scaling level.
  87256. * By default the hardware scaling level is computed from the window device ratio.
  87257. * 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.
  87258. * @returns a number indicating the current hardware scaling level
  87259. */
  87260. getHardwareScalingLevel(): number;
  87261. /**
  87262. * Gets the list of loaded textures
  87263. * @returns an array containing all loaded textures
  87264. */
  87265. getLoadedTexturesCache(): InternalTexture[];
  87266. /**
  87267. * Gets the object containing all engine capabilities
  87268. * @returns the EngineCapabilities object
  87269. */
  87270. getCaps(): EngineCapabilities;
  87271. /**
  87272. * Gets the current depth function
  87273. * @returns a number defining the depth function
  87274. */
  87275. getDepthFunction(): Nullable<number>;
  87276. /**
  87277. * Sets the current depth function
  87278. * @param depthFunc defines the function to use
  87279. */
  87280. setDepthFunction(depthFunc: number): void;
  87281. /**
  87282. * Sets the current depth function to GREATER
  87283. */
  87284. setDepthFunctionToGreater(): void;
  87285. /**
  87286. * Sets the current depth function to GEQUAL
  87287. */
  87288. setDepthFunctionToGreaterOrEqual(): void;
  87289. /**
  87290. * Sets the current depth function to LESS
  87291. */
  87292. setDepthFunctionToLess(): void;
  87293. private _cachedStencilBuffer;
  87294. private _cachedStencilFunction;
  87295. private _cachedStencilMask;
  87296. private _cachedStencilOperationPass;
  87297. private _cachedStencilOperationFail;
  87298. private _cachedStencilOperationDepthFail;
  87299. private _cachedStencilReference;
  87300. /**
  87301. * Caches the the state of the stencil buffer
  87302. */
  87303. cacheStencilState(): void;
  87304. /**
  87305. * Restores the state of the stencil buffer
  87306. */
  87307. restoreStencilState(): void;
  87308. /**
  87309. * Sets the current depth function to LEQUAL
  87310. */
  87311. setDepthFunctionToLessOrEqual(): void;
  87312. /**
  87313. * Gets a boolean indicating if stencil buffer is enabled
  87314. * @returns the current stencil buffer state
  87315. */
  87316. getStencilBuffer(): boolean;
  87317. /**
  87318. * Enable or disable the stencil buffer
  87319. * @param enable defines if the stencil buffer must be enabled or disabled
  87320. */
  87321. setStencilBuffer(enable: boolean): void;
  87322. /**
  87323. * Gets the current stencil mask
  87324. * @returns a number defining the new stencil mask to use
  87325. */
  87326. getStencilMask(): number;
  87327. /**
  87328. * Sets the current stencil mask
  87329. * @param mask defines the new stencil mask to use
  87330. */
  87331. setStencilMask(mask: number): void;
  87332. /**
  87333. * Gets the current stencil function
  87334. * @returns a number defining the stencil function to use
  87335. */
  87336. getStencilFunction(): number;
  87337. /**
  87338. * Gets the current stencil reference value
  87339. * @returns a number defining the stencil reference value to use
  87340. */
  87341. getStencilFunctionReference(): number;
  87342. /**
  87343. * Gets the current stencil mask
  87344. * @returns a number defining the stencil mask to use
  87345. */
  87346. getStencilFunctionMask(): number;
  87347. /**
  87348. * Sets the current stencil function
  87349. * @param stencilFunc defines the new stencil function to use
  87350. */
  87351. setStencilFunction(stencilFunc: number): void;
  87352. /**
  87353. * Sets the current stencil reference
  87354. * @param reference defines the new stencil reference to use
  87355. */
  87356. setStencilFunctionReference(reference: number): void;
  87357. /**
  87358. * Sets the current stencil mask
  87359. * @param mask defines the new stencil mask to use
  87360. */
  87361. setStencilFunctionMask(mask: number): void;
  87362. /**
  87363. * Gets the current stencil operation when stencil fails
  87364. * @returns a number defining stencil operation to use when stencil fails
  87365. */
  87366. getStencilOperationFail(): number;
  87367. /**
  87368. * Gets the current stencil operation when depth fails
  87369. * @returns a number defining stencil operation to use when depth fails
  87370. */
  87371. getStencilOperationDepthFail(): number;
  87372. /**
  87373. * Gets the current stencil operation when stencil passes
  87374. * @returns a number defining stencil operation to use when stencil passes
  87375. */
  87376. getStencilOperationPass(): number;
  87377. /**
  87378. * Sets the stencil operation to use when stencil fails
  87379. * @param operation defines the stencil operation to use when stencil fails
  87380. */
  87381. setStencilOperationFail(operation: number): void;
  87382. /**
  87383. * Sets the stencil operation to use when depth fails
  87384. * @param operation defines the stencil operation to use when depth fails
  87385. */
  87386. setStencilOperationDepthFail(operation: number): void;
  87387. /**
  87388. * Sets the stencil operation to use when stencil passes
  87389. * @param operation defines the stencil operation to use when stencil passes
  87390. */
  87391. setStencilOperationPass(operation: number): void;
  87392. /**
  87393. * Sets a boolean indicating if the dithering state is enabled or disabled
  87394. * @param value defines the dithering state
  87395. */
  87396. setDitheringState(value: boolean): void;
  87397. /**
  87398. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  87399. * @param value defines the rasterizer state
  87400. */
  87401. setRasterizerState(value: boolean): void;
  87402. /**
  87403. * stop executing a render loop function and remove it from the execution array
  87404. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  87405. */
  87406. stopRenderLoop(renderFunction?: () => void): void;
  87407. /** @hidden */
  87408. _renderLoop(): void;
  87409. /**
  87410. * Register and execute a render loop. The engine can have more than one render function
  87411. * @param renderFunction defines the function to continuously execute
  87412. */
  87413. runRenderLoop(renderFunction: () => void): void;
  87414. /**
  87415. * Toggle full screen mode
  87416. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87417. */
  87418. switchFullscreen(requestPointerLock: boolean): void;
  87419. /**
  87420. * Enters full screen mode
  87421. * @param requestPointerLock defines if a pointer lock should be requested from the user
  87422. */
  87423. enterFullscreen(requestPointerLock: boolean): void;
  87424. /**
  87425. * Exits full screen mode
  87426. */
  87427. exitFullscreen(): void;
  87428. /**
  87429. * Clear the current render buffer or the current render target (if any is set up)
  87430. * @param color defines the color to use
  87431. * @param backBuffer defines if the back buffer must be cleared
  87432. * @param depth defines if the depth buffer must be cleared
  87433. * @param stencil defines if the stencil buffer must be cleared
  87434. */
  87435. clear(color: Nullable<Color4>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  87436. /**
  87437. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  87438. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87439. * @param y defines the y-coordinate of the corner of the clear rectangle
  87440. * @param width defines the width of the clear rectangle
  87441. * @param height defines the height of the clear rectangle
  87442. * @param clearColor defines the clear color
  87443. */
  87444. scissorClear(x: number, y: number, width: number, height: number, clearColor: Color4): void;
  87445. /**
  87446. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  87447. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  87448. * @param y defines the y-coordinate of the corner of the clear rectangle
  87449. * @param width defines the width of the clear rectangle
  87450. * @param height defines the height of the clear rectangle
  87451. */
  87452. enableScissor(x: number, y: number, width: number, height: number): void;
  87453. /**
  87454. * Disable previously set scissor test rectangle
  87455. */
  87456. disableScissor(): void;
  87457. private _viewportCached;
  87458. /** @hidden */
  87459. _viewport(x: number, y: number, width: number, height: number): void;
  87460. /**
  87461. * Set the WebGL's viewport
  87462. * @param viewport defines the viewport element to be used
  87463. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  87464. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  87465. */
  87466. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  87467. /**
  87468. * Directly set the WebGL Viewport
  87469. * @param x defines the x coordinate of the viewport (in screen space)
  87470. * @param y defines the y coordinate of the viewport (in screen space)
  87471. * @param width defines the width of the viewport (in screen space)
  87472. * @param height defines the height of the viewport (in screen space)
  87473. * @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
  87474. */
  87475. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<Viewport>;
  87476. /**
  87477. * Begin a new frame
  87478. */
  87479. beginFrame(): void;
  87480. /**
  87481. * Enf the current frame
  87482. */
  87483. endFrame(): void;
  87484. /**
  87485. * Resize the view according to the canvas' size
  87486. */
  87487. resize(): void;
  87488. /**
  87489. * Force a specific size of the canvas
  87490. * @param width defines the new canvas' width
  87491. * @param height defines the new canvas' height
  87492. */
  87493. setSize(width: number, height: number): void;
  87494. /**
  87495. * Gets a boolean indicating if a webVR device was detected
  87496. * @returns true if a webVR device was detected
  87497. */
  87498. isVRDevicePresent(): boolean;
  87499. /**
  87500. * Gets the current webVR device
  87501. * @returns the current webVR device (or null)
  87502. */
  87503. getVRDevice(): any;
  87504. /**
  87505. * Initializes a webVR display and starts listening to display change events
  87506. * The onVRDisplayChangedObservable will be notified upon these changes
  87507. * @returns The onVRDisplayChangedObservable
  87508. */
  87509. initWebVR(): Observable<IDisplayChangedEventArgs>;
  87510. /**
  87511. * Initializes a webVR display and starts listening to display change events
  87512. * The onVRDisplayChangedObservable will be notified upon these changes
  87513. * @returns A promise containing a VRDisplay and if vr is supported
  87514. */
  87515. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  87516. /**
  87517. * Call this function to switch to webVR mode
  87518. * Will do nothing if webVR is not supported or if there is no webVR device
  87519. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87520. */
  87521. enableVR(): void;
  87522. /**
  87523. * Call this function to leave webVR mode
  87524. * Will do nothing if webVR is not supported or if there is no webVR device
  87525. * @see http://doc.babylonjs.com/how_to/webvr_camera
  87526. */
  87527. disableVR(): void;
  87528. private _onVRFullScreenTriggered;
  87529. private _getVRDisplaysAsync;
  87530. /**
  87531. * Binds the frame buffer to the specified texture.
  87532. * @param texture The texture to render to or null for the default canvas
  87533. * @param faceIndex The face of the texture to render to in case of cube texture
  87534. * @param requiredWidth The width of the target to render to
  87535. * @param requiredHeight The height of the target to render to
  87536. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  87537. * @param depthStencilTexture The depth stencil texture to use to render
  87538. * @param lodLevel defines le lod level to bind to the frame buffer
  87539. */
  87540. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, depthStencilTexture?: InternalTexture, lodLevel?: number): void;
  87541. private bindUnboundFramebuffer;
  87542. /**
  87543. * Unbind the current render target texture from the webGL context
  87544. * @param texture defines the render target texture to unbind
  87545. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87546. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87547. */
  87548. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87549. /**
  87550. * Unbind a list of render target textures from the webGL context
  87551. * This is used only when drawBuffer extension or webGL2 are active
  87552. * @param textures defines the render target textures to unbind
  87553. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  87554. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  87555. */
  87556. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  87557. /**
  87558. * Force the mipmap generation for the given render target texture
  87559. * @param texture defines the render target texture to use
  87560. */
  87561. generateMipMapsForCubemap(texture: InternalTexture): void;
  87562. /**
  87563. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  87564. */
  87565. flushFramebuffer(): void;
  87566. /**
  87567. * Unbind the current render target and bind the default framebuffer
  87568. */
  87569. restoreDefaultFramebuffer(): void;
  87570. /**
  87571. * Create an uniform buffer
  87572. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87573. * @param elements defines the content of the uniform buffer
  87574. * @returns the webGL uniform buffer
  87575. */
  87576. createUniformBuffer(elements: FloatArray): WebGLBuffer;
  87577. /**
  87578. * Create a dynamic uniform buffer
  87579. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87580. * @param elements defines the content of the uniform buffer
  87581. * @returns the webGL uniform buffer
  87582. */
  87583. createDynamicUniformBuffer(elements: FloatArray): WebGLBuffer;
  87584. /**
  87585. * Update an existing uniform buffer
  87586. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87587. * @param uniformBuffer defines the target uniform buffer
  87588. * @param elements defines the content to update
  87589. * @param offset defines the offset in the uniform buffer where update should start
  87590. * @param count defines the size of the data to update
  87591. */
  87592. updateUniformBuffer(uniformBuffer: WebGLBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87593. private _resetVertexBufferBinding;
  87594. /**
  87595. * Creates a vertex buffer
  87596. * @param data the data for the vertex buffer
  87597. * @returns the new WebGL static buffer
  87598. */
  87599. createVertexBuffer(data: DataArray): WebGLBuffer;
  87600. /**
  87601. * Creates a dynamic vertex buffer
  87602. * @param data the data for the dynamic vertex buffer
  87603. * @returns the new WebGL dynamic buffer
  87604. */
  87605. createDynamicVertexBuffer(data: DataArray): WebGLBuffer;
  87606. /**
  87607. * Update a dynamic index buffer
  87608. * @param indexBuffer defines the target index buffer
  87609. * @param indices defines the data to update
  87610. * @param offset defines the offset in the target index buffer where update should start
  87611. */
  87612. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  87613. /**
  87614. * Updates a dynamic vertex buffer.
  87615. * @param vertexBuffer the vertex buffer to update
  87616. * @param data the data used to update the vertex buffer
  87617. * @param byteOffset the byte offset of the data
  87618. * @param byteLength the byte length of the data
  87619. */
  87620. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  87621. private _resetIndexBufferBinding;
  87622. /**
  87623. * Creates a new index buffer
  87624. * @param indices defines the content of the index buffer
  87625. * @param updatable defines if the index buffer must be updatable
  87626. * @returns a new webGL buffer
  87627. */
  87628. createIndexBuffer(indices: IndicesArray, updatable?: boolean): WebGLBuffer;
  87629. /**
  87630. * Bind a webGL buffer to the webGL context
  87631. * @param buffer defines the buffer to bind
  87632. */
  87633. bindArrayBuffer(buffer: Nullable<WebGLBuffer>): void;
  87634. /**
  87635. * Bind an uniform buffer to the current webGL context
  87636. * @param buffer defines the buffer to bind
  87637. */
  87638. bindUniformBuffer(buffer: Nullable<WebGLBuffer>): void;
  87639. /**
  87640. * Bind a buffer to the current webGL context at a given location
  87641. * @param buffer defines the buffer to bind
  87642. * @param location defines the index where to bind the buffer
  87643. */
  87644. bindUniformBufferBase(buffer: WebGLBuffer, location: number): void;
  87645. /**
  87646. * Bind a specific block at a given index in a specific shader program
  87647. * @param shaderProgram defines the shader program
  87648. * @param blockName defines the block name
  87649. * @param index defines the index where to bind the block
  87650. */
  87651. bindUniformBlock(shaderProgram: WebGLProgram, blockName: string, index: number): void;
  87652. private bindIndexBuffer;
  87653. private bindBuffer;
  87654. /**
  87655. * update the bound buffer with the given data
  87656. * @param data defines the data to update
  87657. */
  87658. updateArrayBuffer(data: Float32Array): void;
  87659. private _vertexAttribPointer;
  87660. private _bindIndexBufferWithCache;
  87661. private _bindVertexBuffersAttributes;
  87662. /**
  87663. * Records a vertex array object
  87664. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87665. * @param vertexBuffers defines the list of vertex buffers to store
  87666. * @param indexBuffer defines the index buffer to store
  87667. * @param effect defines the effect to store
  87668. * @returns the new vertex array object
  87669. */
  87670. recordVertexArrayObject(vertexBuffers: {
  87671. [key: string]: VertexBuffer;
  87672. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): WebGLVertexArrayObject;
  87673. /**
  87674. * Bind a specific vertex array object
  87675. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  87676. * @param vertexArrayObject defines the vertex array object to bind
  87677. * @param indexBuffer defines the index buffer to bind
  87678. */
  87679. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<WebGLBuffer>): void;
  87680. /**
  87681. * Bind webGl buffers directly to the webGL context
  87682. * @param vertexBuffer defines the vertex buffer to bind
  87683. * @param indexBuffer defines the index buffer to bind
  87684. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  87685. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  87686. * @param effect defines the effect associated with the vertex buffer
  87687. */
  87688. bindBuffersDirectly(vertexBuffer: WebGLBuffer, indexBuffer: WebGLBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  87689. private _unbindVertexArrayObject;
  87690. /**
  87691. * Bind a list of vertex buffers to the webGL context
  87692. * @param vertexBuffers defines the list of vertex buffers to bind
  87693. * @param indexBuffer defines the index buffer to bind
  87694. * @param effect defines the effect associated with the vertex buffers
  87695. */
  87696. bindBuffers(vertexBuffers: {
  87697. [key: string]: Nullable<VertexBuffer>;
  87698. }, indexBuffer: Nullable<WebGLBuffer>, effect: Effect): void;
  87699. /**
  87700. * Unbind all instance attributes
  87701. */
  87702. unbindInstanceAttributes(): void;
  87703. /**
  87704. * Release and free the memory of a vertex array object
  87705. * @param vao defines the vertex array object to delete
  87706. */
  87707. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  87708. /** @hidden */
  87709. _releaseBuffer(buffer: WebGLBuffer): boolean;
  87710. /**
  87711. * Creates a webGL buffer to use with instanciation
  87712. * @param capacity defines the size of the buffer
  87713. * @returns the webGL buffer
  87714. */
  87715. createInstancesBuffer(capacity: number): WebGLBuffer;
  87716. /**
  87717. * Delete a webGL buffer used with instanciation
  87718. * @param buffer defines the webGL buffer to delete
  87719. */
  87720. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  87721. /**
  87722. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  87723. * @param instancesBuffer defines the webGL buffer to update and bind
  87724. * @param data defines the data to store in the buffer
  87725. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  87726. */
  87727. updateAndBindInstancesBuffer(instancesBuffer: WebGLBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  87728. /**
  87729. * Apply all cached states (depth, culling, stencil and alpha)
  87730. */
  87731. applyStates(): void;
  87732. /**
  87733. * Send a draw order
  87734. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87735. * @param indexStart defines the starting index
  87736. * @param indexCount defines the number of index to draw
  87737. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87738. */
  87739. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  87740. /**
  87741. * Draw a list of points
  87742. * @param verticesStart defines the index of first vertex to draw
  87743. * @param verticesCount defines the count of vertices to draw
  87744. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87745. */
  87746. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87747. /**
  87748. * Draw a list of unindexed primitives
  87749. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  87750. * @param verticesStart defines the index of first vertex to draw
  87751. * @param verticesCount defines the count of vertices to draw
  87752. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87753. */
  87754. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87755. /**
  87756. * Draw a list of indexed primitives
  87757. * @param fillMode defines the primitive to use
  87758. * @param indexStart defines the starting index
  87759. * @param indexCount defines the number of index to draw
  87760. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87761. */
  87762. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  87763. /**
  87764. * Draw a list of unindexed primitives
  87765. * @param fillMode defines the primitive to use
  87766. * @param verticesStart defines the index of first vertex to draw
  87767. * @param verticesCount defines the count of vertices to draw
  87768. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  87769. */
  87770. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  87771. private _drawMode;
  87772. /** @hidden */
  87773. _releaseEffect(effect: Effect): void;
  87774. /** @hidden */
  87775. _deleteProgram(program: WebGLProgram): void;
  87776. /**
  87777. * Create a new effect (used to store vertex/fragment shaders)
  87778. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  87779. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  87780. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  87781. * @param samplers defines an array of string used to represent textures
  87782. * @param defines defines the string containing the defines to use to compile the shaders
  87783. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  87784. * @param onCompiled defines a function to call when the effect creation is successful
  87785. * @param onError defines a function to call when the effect creation has failed
  87786. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  87787. * @returns the new Effect
  87788. */
  87789. createEffect(baseName: any, attributesNamesOrOptions: string[] | EffectCreationOptions, uniformsNamesOrEngine: string[] | Engine, samplers?: string[], defines?: string, fallbacks?: EffectFallbacks, onCompiled?: Nullable<(effect: Effect) => void>, onError?: Nullable<(effect: Effect, errors: string) => void>, indexParameters?: any): Effect;
  87790. private _compileShader;
  87791. private _compileRawShader;
  87792. /**
  87793. * Directly creates a webGL program
  87794. * @param vertexCode defines the vertex shader code to use
  87795. * @param fragmentCode defines the fragment shader code to use
  87796. * @param context defines the webGL context to use (if not set, the current one will be used)
  87797. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87798. * @returns the new webGL program
  87799. */
  87800. createRawShaderProgram(vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87801. /**
  87802. * Creates a webGL program
  87803. * @param vertexCode defines the vertex shader code to use
  87804. * @param fragmentCode defines the fragment shader code to use
  87805. * @param defines defines the string containing the defines to use to compile the shaders
  87806. * @param context defines the webGL context to use (if not set, the current one will be used)
  87807. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  87808. * @returns the new webGL program
  87809. */
  87810. createShaderProgram(vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  87811. private _createShaderProgram;
  87812. private _finalizeProgram;
  87813. /** @hidden */
  87814. _isProgramCompiled(shaderProgram: WebGLProgram): boolean;
  87815. /** @hidden */
  87816. _executeWhenProgramIsCompiled(shaderProgram: WebGLProgram, action: () => void): void;
  87817. /**
  87818. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  87819. * @param shaderProgram defines the webGL program to use
  87820. * @param uniformsNames defines the list of uniform names
  87821. * @returns an array of webGL uniform locations
  87822. */
  87823. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  87824. /**
  87825. * Gets the lsit of active attributes for a given webGL program
  87826. * @param shaderProgram defines the webGL program to use
  87827. * @param attributesNames defines the list of attribute names to get
  87828. * @returns an array of indices indicating the offset of each attribute
  87829. */
  87830. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  87831. /**
  87832. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  87833. * @param effect defines the effect to activate
  87834. */
  87835. enableEffect(effect: Nullable<Effect>): void;
  87836. /**
  87837. * Set the value of an uniform to an array of int32
  87838. * @param uniform defines the webGL uniform location where to store the value
  87839. * @param array defines the array of int32 to store
  87840. */
  87841. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87842. /**
  87843. * Set the value of an uniform to an array of int32 (stored as vec2)
  87844. * @param uniform defines the webGL uniform location where to store the value
  87845. * @param array defines the array of int32 to store
  87846. */
  87847. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87848. /**
  87849. * Set the value of an uniform to an array of int32 (stored as vec3)
  87850. * @param uniform defines the webGL uniform location where to store the value
  87851. * @param array defines the array of int32 to store
  87852. */
  87853. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87854. /**
  87855. * Set the value of an uniform to an array of int32 (stored as vec4)
  87856. * @param uniform defines the webGL uniform location where to store the value
  87857. * @param array defines the array of int32 to store
  87858. */
  87859. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): void;
  87860. /**
  87861. * Set the value of an uniform to an array of float32
  87862. * @param uniform defines the webGL uniform location where to store the value
  87863. * @param array defines the array of float32 to store
  87864. */
  87865. setFloatArray(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87866. /**
  87867. * Set the value of an uniform to an array of float32 (stored as vec2)
  87868. * @param uniform defines the webGL uniform location where to store the value
  87869. * @param array defines the array of float32 to store
  87870. */
  87871. setFloatArray2(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87872. /**
  87873. * Set the value of an uniform to an array of float32 (stored as vec3)
  87874. * @param uniform defines the webGL uniform location where to store the value
  87875. * @param array defines the array of float32 to store
  87876. */
  87877. setFloatArray3(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87878. /**
  87879. * Set the value of an uniform to an array of float32 (stored as vec4)
  87880. * @param uniform defines the webGL uniform location where to store the value
  87881. * @param array defines the array of float32 to store
  87882. */
  87883. setFloatArray4(uniform: Nullable<WebGLUniformLocation>, array: Float32Array): void;
  87884. /**
  87885. * Set the value of an uniform to an array of number
  87886. * @param uniform defines the webGL uniform location where to store the value
  87887. * @param array defines the array of number to store
  87888. */
  87889. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87890. /**
  87891. * Set the value of an uniform to an array of number (stored as vec2)
  87892. * @param uniform defines the webGL uniform location where to store the value
  87893. * @param array defines the array of number to store
  87894. */
  87895. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87896. /**
  87897. * Set the value of an uniform to an array of number (stored as vec3)
  87898. * @param uniform defines the webGL uniform location where to store the value
  87899. * @param array defines the array of number to store
  87900. */
  87901. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87902. /**
  87903. * Set the value of an uniform to an array of number (stored as vec4)
  87904. * @param uniform defines the webGL uniform location where to store the value
  87905. * @param array defines the array of number to store
  87906. */
  87907. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[]): void;
  87908. /**
  87909. * Set the value of an uniform to an array of float32 (stored as matrices)
  87910. * @param uniform defines the webGL uniform location where to store the value
  87911. * @param matrices defines the array of float32 to store
  87912. */
  87913. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): void;
  87914. /**
  87915. * Set the value of an uniform to a matrix
  87916. * @param uniform defines the webGL uniform location where to store the value
  87917. * @param matrix defines the matrix to store
  87918. */
  87919. setMatrix(uniform: Nullable<WebGLUniformLocation>, matrix: Matrix): void;
  87920. /**
  87921. * Set the value of an uniform to a matrix (3x3)
  87922. * @param uniform defines the webGL uniform location where to store the value
  87923. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  87924. */
  87925. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87926. /**
  87927. * Set the value of an uniform to a matrix (2x2)
  87928. * @param uniform defines the webGL uniform location where to store the value
  87929. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  87930. */
  87931. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): void;
  87932. /**
  87933. * Set the value of an uniform to a number (int)
  87934. * @param uniform defines the webGL uniform location where to store the value
  87935. * @param value defines the int number to store
  87936. */
  87937. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87938. /**
  87939. * Set the value of an uniform to a number (float)
  87940. * @param uniform defines the webGL uniform location where to store the value
  87941. * @param value defines the float number to store
  87942. */
  87943. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): void;
  87944. /**
  87945. * Set the value of an uniform to a vec2
  87946. * @param uniform defines the webGL uniform location where to store the value
  87947. * @param x defines the 1st component of the value
  87948. * @param y defines the 2nd component of the value
  87949. */
  87950. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): void;
  87951. /**
  87952. * Set the value of an uniform to a vec3
  87953. * @param uniform defines the webGL uniform location where to store the value
  87954. * @param x defines the 1st component of the value
  87955. * @param y defines the 2nd component of the value
  87956. * @param z defines the 3rd component of the value
  87957. */
  87958. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): void;
  87959. /**
  87960. * Set the value of an uniform to a boolean
  87961. * @param uniform defines the webGL uniform location where to store the value
  87962. * @param bool defines the boolean to store
  87963. */
  87964. setBool(uniform: Nullable<WebGLUniformLocation>, bool: number): void;
  87965. /**
  87966. * Set the value of an uniform to a vec4
  87967. * @param uniform defines the webGL uniform location where to store the value
  87968. * @param x defines the 1st component of the value
  87969. * @param y defines the 2nd component of the value
  87970. * @param z defines the 3rd component of the value
  87971. * @param w defines the 4th component of the value
  87972. */
  87973. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): void;
  87974. /**
  87975. * Set the value of an uniform to a Color3
  87976. * @param uniform defines the webGL uniform location where to store the value
  87977. * @param color3 defines the color to store
  87978. */
  87979. setColor3(uniform: Nullable<WebGLUniformLocation>, color3: Color3): void;
  87980. /**
  87981. * Set the value of an uniform to a Color3 and an alpha value
  87982. * @param uniform defines the webGL uniform location where to store the value
  87983. * @param color3 defines the color to store
  87984. * @param alpha defines the alpha component to store
  87985. */
  87986. setColor4(uniform: Nullable<WebGLUniformLocation>, color3: Color3, alpha: number): void;
  87987. /**
  87988. * Sets a Color4 on a uniform variable
  87989. * @param uniform defines the uniform location
  87990. * @param color4 defines the value to be set
  87991. */
  87992. setDirectColor4(uniform: Nullable<WebGLUniformLocation>, color4: Color4): void;
  87993. /**
  87994. * Set various states to the webGL context
  87995. * @param culling defines backface culling state
  87996. * @param zOffset defines the value to apply to zOffset (0 by default)
  87997. * @param force defines if states must be applied even if cache is up to date
  87998. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  87999. */
  88000. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  88001. /**
  88002. * Set the z offset to apply to current rendering
  88003. * @param value defines the offset to apply
  88004. */
  88005. setZOffset(value: number): void;
  88006. /**
  88007. * Gets the current value of the zOffset
  88008. * @returns the current zOffset state
  88009. */
  88010. getZOffset(): number;
  88011. /**
  88012. * Enable or disable depth buffering
  88013. * @param enable defines the state to set
  88014. */
  88015. setDepthBuffer(enable: boolean): void;
  88016. /**
  88017. * Gets a boolean indicating if depth writing is enabled
  88018. * @returns the current depth writing state
  88019. */
  88020. getDepthWrite(): boolean;
  88021. /**
  88022. * Enable or disable depth writing
  88023. * @param enable defines the state to set
  88024. */
  88025. setDepthWrite(enable: boolean): void;
  88026. /**
  88027. * Enable or disable color writing
  88028. * @param enable defines the state to set
  88029. */
  88030. setColorWrite(enable: boolean): void;
  88031. /**
  88032. * Gets a boolean indicating if color writing is enabled
  88033. * @returns the current color writing state
  88034. */
  88035. getColorWrite(): boolean;
  88036. /**
  88037. * Sets alpha constants used by some alpha blending modes
  88038. * @param r defines the red component
  88039. * @param g defines the green component
  88040. * @param b defines the blue component
  88041. * @param a defines the alpha component
  88042. */
  88043. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  88044. /**
  88045. * Sets the current alpha mode
  88046. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  88047. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  88048. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88049. */
  88050. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  88051. /**
  88052. * Gets the current alpha mode
  88053. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  88054. * @returns the current alpha mode
  88055. */
  88056. getAlphaMode(): number;
  88057. /**
  88058. * Clears the list of texture accessible through engine.
  88059. * This can help preventing texture load conflict due to name collision.
  88060. */
  88061. clearInternalTexturesCache(): void;
  88062. /**
  88063. * Force the entire cache to be cleared
  88064. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  88065. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  88066. */
  88067. wipeCaches(bruteForce?: boolean): void;
  88068. /**
  88069. * Set the compressed texture format to use, based on the formats you have, and the formats
  88070. * supported by the hardware / browser.
  88071. *
  88072. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  88073. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  88074. * to API arguments needed to compressed textures. This puts the burden on the container
  88075. * generator to house the arcane code for determining these for current & future formats.
  88076. *
  88077. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  88078. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  88079. *
  88080. * Note: The result of this call is not taken into account when a texture is base64.
  88081. *
  88082. * @param formatsAvailable defines the list of those format families you have created
  88083. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  88084. *
  88085. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  88086. * @returns The extension selected.
  88087. */
  88088. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  88089. /** @hidden */
  88090. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  88091. min: number;
  88092. mag: number;
  88093. };
  88094. private _partialLoadImg;
  88095. private _cascadeLoadImgs;
  88096. /** @hidden */
  88097. _createTexture(): WebGLTexture;
  88098. /**
  88099. * Usually called from Texture.ts.
  88100. * Passed information to create a WebGLTexture
  88101. * @param urlArg defines a value which contains one of the following:
  88102. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  88103. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  88104. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  88105. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  88106. * @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)
  88107. * @param scene needed for loading to the correct scene
  88108. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  88109. * @param onLoad optional callback to be called upon successful completion
  88110. * @param onError optional callback to be called upon failure
  88111. * @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
  88112. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  88113. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  88114. * @param forcedExtension defines the extension to use to pick the right loader
  88115. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  88116. * @returns a InternalTexture for assignment back into BABYLON.Texture
  88117. */
  88118. 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;
  88119. private _rescaleTexture;
  88120. private _unpackFlipYCached;
  88121. /**
  88122. * In case you are sharing the context with other applications, it might
  88123. * be interested to not cache the unpack flip y state to ensure a consistent
  88124. * value would be set.
  88125. */
  88126. enableUnpackFlipYCached: boolean;
  88127. /** @hidden */
  88128. _unpackFlipY(value: boolean): void;
  88129. /** @hidden */
  88130. _getUnpackAlignement(): number;
  88131. /**
  88132. * Creates a dynamic texture
  88133. * @param width defines the width of the texture
  88134. * @param height defines the height of the texture
  88135. * @param generateMipMaps defines if the engine should generate the mip levels
  88136. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  88137. * @returns the dynamic texture inside an InternalTexture
  88138. */
  88139. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  88140. /**
  88141. * Update the sampling mode of a given texture
  88142. * @param samplingMode defines the required sampling mode
  88143. * @param texture defines the texture to update
  88144. */
  88145. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  88146. /**
  88147. * Update the content of a dynamic texture
  88148. * @param texture defines the texture to update
  88149. * @param canvas defines the canvas containing the source
  88150. * @param invertY defines if data must be stored with Y axis inverted
  88151. * @param premulAlpha defines if alpha is stored as premultiplied
  88152. * @param format defines the format of the data
  88153. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  88154. */
  88155. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  88156. /**
  88157. * Update a video texture
  88158. * @param texture defines the texture to update
  88159. * @param video defines the video element to use
  88160. * @param invertY defines if data must be stored with Y axis inverted
  88161. */
  88162. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  88163. /**
  88164. * Updates a depth texture Comparison Mode and Function.
  88165. * If the comparison Function is equal to 0, the mode will be set to none.
  88166. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  88167. * @param texture The texture to set the comparison function for
  88168. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  88169. */
  88170. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  88171. private _setupDepthStencilTexture;
  88172. /**
  88173. * Creates a depth stencil texture.
  88174. * This is only available in WebGL 2 or with the depth texture extension available.
  88175. * @param size The size of face edge in the texture.
  88176. * @param options The options defining the texture.
  88177. * @returns The texture
  88178. */
  88179. createDepthStencilTexture(size: number | {
  88180. width: number;
  88181. height: number;
  88182. }, options: DepthTextureCreationOptions): InternalTexture;
  88183. /**
  88184. * Creates a depth stencil texture.
  88185. * This is only available in WebGL 2 or with the depth texture extension available.
  88186. * @param size The size of face edge in the texture.
  88187. * @param options The options defining the texture.
  88188. * @returns The texture
  88189. */
  88190. private _createDepthStencilTexture;
  88191. /**
  88192. * Creates a depth stencil cube texture.
  88193. * This is only available in WebGL 2.
  88194. * @param size The size of face edge in the cube texture.
  88195. * @param options The options defining the cube texture.
  88196. * @returns The cube texture
  88197. */
  88198. private _createDepthStencilCubeTexture;
  88199. /**
  88200. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  88201. * @param renderTarget The render target to set the frame buffer for
  88202. */
  88203. setFrameBufferDepthStencilTexture(renderTarget: RenderTargetTexture): void;
  88204. /**
  88205. * Creates a new render target texture
  88206. * @param size defines the size of the texture
  88207. * @param options defines the options used to create the texture
  88208. * @returns a new render target texture stored in an InternalTexture
  88209. */
  88210. createRenderTargetTexture(size: number | {
  88211. width: number;
  88212. height: number;
  88213. }, options: boolean | RenderTargetCreationOptions): InternalTexture;
  88214. /**
  88215. * Create a multi render target texture
  88216. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  88217. * @param size defines the size of the texture
  88218. * @param options defines the creation options
  88219. * @returns the cube texture as an InternalTexture
  88220. */
  88221. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  88222. private _setupFramebufferDepthAttachments;
  88223. /**
  88224. * Updates the sample count of a render target texture
  88225. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88226. * @param texture defines the texture to update
  88227. * @param samples defines the sample count to set
  88228. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88229. */
  88230. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  88231. /**
  88232. * Update the sample count for a given multiple render target texture
  88233. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  88234. * @param textures defines the textures to update
  88235. * @param samples defines the sample count to set
  88236. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  88237. */
  88238. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  88239. /** @hidden */
  88240. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88241. /** @hidden */
  88242. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88243. /** @hidden */
  88244. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  88245. /** @hidden */
  88246. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  88247. /**
  88248. * Creates a new render target cube texture
  88249. * @param size defines the size of the texture
  88250. * @param options defines the options used to create the texture
  88251. * @returns a new render target cube texture stored in an InternalTexture
  88252. */
  88253. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  88254. /**
  88255. * Creates a cube texture
  88256. * @param rootUrl defines the url where the files to load is located
  88257. * @param scene defines the current scene
  88258. * @param files defines the list of files to load (1 per face)
  88259. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88260. * @param onLoad defines an optional callback raised when the texture is loaded
  88261. * @param onError defines an optional callback raised if there is an issue to load the texture
  88262. * @param format defines the format of the data
  88263. * @param forcedExtension defines the extension to use to pick the right loader
  88264. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88265. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88266. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88267. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88268. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  88269. * @returns the cube texture as an InternalTexture
  88270. */
  88271. 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;
  88272. /**
  88273. * @hidden
  88274. */
  88275. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88276. private _prepareWebGLTextureContinuation;
  88277. private _prepareWebGLTexture;
  88278. /** @hidden */
  88279. _convertRGBtoRGBATextureData(rgbData: any, width: number, height: number, textureType: number): ArrayBufferView;
  88280. /** @hidden */
  88281. _releaseFramebufferObjects(texture: InternalTexture): void;
  88282. /** @hidden */
  88283. _releaseTexture(texture: InternalTexture): void;
  88284. private setProgram;
  88285. private _boundUniforms;
  88286. /**
  88287. * Binds an effect to the webGL context
  88288. * @param effect defines the effect to bind
  88289. */
  88290. bindSamplers(effect: Effect): void;
  88291. private _activateCurrentTexture;
  88292. /** @hidden */
  88293. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  88294. /** @hidden */
  88295. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  88296. /**
  88297. * Sets a texture to the webGL context from a postprocess
  88298. * @param channel defines the channel to use
  88299. * @param postProcess defines the source postprocess
  88300. */
  88301. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  88302. /**
  88303. * Binds the output of the passed in post process to the texture channel specified
  88304. * @param channel The channel the texture should be bound to
  88305. * @param postProcess The post process which's output should be bound
  88306. */
  88307. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  88308. /**
  88309. * Unbind all textures from the webGL context
  88310. */
  88311. unbindAllTextures(): void;
  88312. /**
  88313. * Sets a texture to the according uniform.
  88314. * @param channel The texture channel
  88315. * @param uniform The uniform to set
  88316. * @param texture The texture to apply
  88317. */
  88318. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  88319. /**
  88320. * Sets a depth stencil texture from a render target to the according uniform.
  88321. * @param channel The texture channel
  88322. * @param uniform The uniform to set
  88323. * @param texture The render target texture containing the depth stencil texture to apply
  88324. */
  88325. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  88326. private _bindSamplerUniformToChannel;
  88327. private _getTextureWrapMode;
  88328. private _setTexture;
  88329. /**
  88330. * Sets an array of texture to the webGL context
  88331. * @param channel defines the channel where the texture array must be set
  88332. * @param uniform defines the associated uniform location
  88333. * @param textures defines the array of textures to bind
  88334. */
  88335. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  88336. /** @hidden */
  88337. _setAnisotropicLevel(target: number, texture: BaseTexture): void;
  88338. private _setTextureParameterFloat;
  88339. private _setTextureParameterInteger;
  88340. /**
  88341. * Reads pixels from the current frame buffer. Please note that this function can be slow
  88342. * @param x defines the x coordinate of the rectangle where pixels must be read
  88343. * @param y defines the y coordinate of the rectangle where pixels must be read
  88344. * @param width defines the width of the rectangle where pixels must be read
  88345. * @param height defines the height of the rectangle where pixels must be read
  88346. * @returns a Uint8Array containing RGBA colors
  88347. */
  88348. readPixels(x: number, y: number, width: number, height: number): Uint8Array;
  88349. /**
  88350. * Add an externaly attached data from its key.
  88351. * This method call will fail and return false, if such key already exists.
  88352. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  88353. * @param key the unique key that identifies the data
  88354. * @param data the data object to associate to the key for this Engine instance
  88355. * @return true if no such key were already present and the data was added successfully, false otherwise
  88356. */
  88357. addExternalData<T>(key: string, data: T): boolean;
  88358. /**
  88359. * Get an externaly attached data from its key
  88360. * @param key the unique key that identifies the data
  88361. * @return the associated data, if present (can be null), or undefined if not present
  88362. */
  88363. getExternalData<T>(key: string): T;
  88364. /**
  88365. * Get an externaly attached data from its key, create it using a factory if it's not already present
  88366. * @param key the unique key that identifies the data
  88367. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  88368. * @return the associated data, can be null if the factory returned null.
  88369. */
  88370. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  88371. /**
  88372. * Remove an externaly attached data from the Engine instance
  88373. * @param key the unique key that identifies the data
  88374. * @return true if the data was successfully removed, false if it doesn't exist
  88375. */
  88376. removeExternalData(key: string): boolean;
  88377. /**
  88378. * Unbind all vertex attributes from the webGL context
  88379. */
  88380. unbindAllAttributes(): void;
  88381. /**
  88382. * 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
  88383. */
  88384. releaseEffects(): void;
  88385. /**
  88386. * Dispose and release all associated resources
  88387. */
  88388. dispose(): void;
  88389. /**
  88390. * Display the loading screen
  88391. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88392. */
  88393. displayLoadingUI(): void;
  88394. /**
  88395. * Hide the loading screen
  88396. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88397. */
  88398. hideLoadingUI(): void;
  88399. /**
  88400. * Gets the current loading screen object
  88401. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88402. */
  88403. /**
  88404. * Sets the current loading screen object
  88405. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88406. */
  88407. loadingScreen: ILoadingScreen;
  88408. /**
  88409. * Sets the current loading screen text
  88410. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88411. */
  88412. loadingUIText: string;
  88413. /**
  88414. * Sets the current loading screen background color
  88415. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  88416. */
  88417. loadingUIBackgroundColor: string;
  88418. /**
  88419. * Attach a new callback raised when context lost event is fired
  88420. * @param callback defines the callback to call
  88421. */
  88422. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88423. /**
  88424. * Attach a new callback raised when context restored event is fired
  88425. * @param callback defines the callback to call
  88426. */
  88427. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  88428. /**
  88429. * Gets the source code of the vertex shader associated with a specific webGL program
  88430. * @param program defines the program to use
  88431. * @returns a string containing the source code of the vertex shader associated with the program
  88432. */
  88433. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  88434. /**
  88435. * Gets the source code of the fragment shader associated with a specific webGL program
  88436. * @param program defines the program to use
  88437. * @returns a string containing the source code of the fragment shader associated with the program
  88438. */
  88439. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  88440. /**
  88441. * Get the current error code of the webGL context
  88442. * @returns the error code
  88443. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  88444. */
  88445. getError(): number;
  88446. /**
  88447. * Gets the current framerate
  88448. * @returns a number representing the framerate
  88449. */
  88450. getFps(): number;
  88451. /**
  88452. * Gets the time spent between current and previous frame
  88453. * @returns a number representing the delta time in ms
  88454. */
  88455. getDeltaTime(): number;
  88456. private _measureFps;
  88457. /** @hidden */
  88458. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  88459. private _canRenderToFloatFramebuffer;
  88460. private _canRenderToHalfFloatFramebuffer;
  88461. private _canRenderToFramebuffer;
  88462. /** @hidden */
  88463. _getWebGLTextureType(type: number): number;
  88464. /** @hidden */
  88465. _getInternalFormat(format: number): number;
  88466. /** @hidden */
  88467. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  88468. /** @hidden */
  88469. _getRGBAMultiSampleBufferFormat(type: number): number;
  88470. /** @hidden */
  88471. _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;
  88472. /** @hidden */
  88473. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  88474. private _partialLoadFile;
  88475. private _cascadeLoadFiles;
  88476. /**
  88477. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  88478. * @returns true if the engine can be created
  88479. * @ignorenaming
  88480. */
  88481. static isSupported(): boolean;
  88482. }
  88483. }
  88484. declare module BABYLON {
  88485. /**
  88486. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  88487. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  88488. */
  88489. export class EffectFallbacks {
  88490. private _defines;
  88491. private _currentRank;
  88492. private _maxRank;
  88493. private _mesh;
  88494. /**
  88495. * Removes the fallback from the bound mesh.
  88496. */
  88497. unBindMesh(): void;
  88498. /**
  88499. * Adds a fallback on the specified property.
  88500. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88501. * @param define The name of the define in the shader
  88502. */
  88503. addFallback(rank: number, define: string): void;
  88504. /**
  88505. * Sets the mesh to use CPU skinning when needing to fallback.
  88506. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  88507. * @param mesh The mesh to use the fallbacks.
  88508. */
  88509. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  88510. /**
  88511. * Checks to see if more fallbacks are still availible.
  88512. */
  88513. readonly isMoreFallbacks: boolean;
  88514. /**
  88515. * Removes the defines that shoould be removed when falling back.
  88516. * @param currentDefines defines the current define statements for the shader.
  88517. * @param effect defines the current effect we try to compile
  88518. * @returns The resulting defines with defines of the current rank removed.
  88519. */
  88520. reduce(currentDefines: string, effect: Effect): string;
  88521. }
  88522. /**
  88523. * Options to be used when creating an effect.
  88524. */
  88525. export class EffectCreationOptions {
  88526. /**
  88527. * Atrributes that will be used in the shader.
  88528. */
  88529. attributes: string[];
  88530. /**
  88531. * Uniform varible names that will be set in the shader.
  88532. */
  88533. uniformsNames: string[];
  88534. /**
  88535. * Uniform buffer varible names that will be set in the shader.
  88536. */
  88537. uniformBuffersNames: string[];
  88538. /**
  88539. * Sampler texture variable names that will be set in the shader.
  88540. */
  88541. samplers: string[];
  88542. /**
  88543. * Define statements that will be set in the shader.
  88544. */
  88545. defines: any;
  88546. /**
  88547. * Possible fallbacks for this effect to improve performance when needed.
  88548. */
  88549. fallbacks: Nullable<EffectFallbacks>;
  88550. /**
  88551. * Callback that will be called when the shader is compiled.
  88552. */
  88553. onCompiled: Nullable<(effect: Effect) => void>;
  88554. /**
  88555. * Callback that will be called if an error occurs during shader compilation.
  88556. */
  88557. onError: Nullable<(effect: Effect, errors: string) => void>;
  88558. /**
  88559. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88560. */
  88561. indexParameters: any;
  88562. /**
  88563. * Max number of lights that can be used in the shader.
  88564. */
  88565. maxSimultaneousLights: number;
  88566. /**
  88567. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  88568. */
  88569. transformFeedbackVaryings: Nullable<string[]>;
  88570. }
  88571. /**
  88572. * Effect containing vertex and fragment shader that can be executed on an object.
  88573. */
  88574. export class Effect implements IDisposable {
  88575. /**
  88576. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  88577. */
  88578. static ShadersRepository: string;
  88579. /**
  88580. * Name of the effect.
  88581. */
  88582. name: any;
  88583. /**
  88584. * String container all the define statements that should be set on the shader.
  88585. */
  88586. defines: string;
  88587. /**
  88588. * Callback that will be called when the shader is compiled.
  88589. */
  88590. onCompiled: Nullable<(effect: Effect) => void>;
  88591. /**
  88592. * Callback that will be called if an error occurs during shader compilation.
  88593. */
  88594. onError: Nullable<(effect: Effect, errors: string) => void>;
  88595. /**
  88596. * Callback that will be called when effect is bound.
  88597. */
  88598. onBind: Nullable<(effect: Effect) => void>;
  88599. /**
  88600. * Unique ID of the effect.
  88601. */
  88602. uniqueId: number;
  88603. /**
  88604. * Observable that will be called when the shader is compiled.
  88605. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  88606. */
  88607. onCompileObservable: Observable<Effect>;
  88608. /**
  88609. * Observable that will be called if an error occurs during shader compilation.
  88610. */
  88611. onErrorObservable: Observable<Effect>;
  88612. /** @hidden */
  88613. _onBindObservable: Nullable<Observable<Effect>>;
  88614. /**
  88615. * Observable that will be called when effect is bound.
  88616. */
  88617. readonly onBindObservable: Observable<Effect>;
  88618. /** @hidden */
  88619. _bonesComputationForcedToCPU: boolean;
  88620. private static _uniqueIdSeed;
  88621. private _engine;
  88622. private _uniformBuffersNames;
  88623. private _uniformsNames;
  88624. private _samplerList;
  88625. private _samplers;
  88626. private _isReady;
  88627. private _compilationError;
  88628. private _attributesNames;
  88629. private _attributes;
  88630. private _uniforms;
  88631. /**
  88632. * Key for the effect.
  88633. * @hidden
  88634. */
  88635. _key: string;
  88636. private _indexParameters;
  88637. private _fallbacks;
  88638. private _vertexSourceCode;
  88639. private _fragmentSourceCode;
  88640. private _vertexSourceCodeOverride;
  88641. private _fragmentSourceCodeOverride;
  88642. private _transformFeedbackVaryings;
  88643. /**
  88644. * Compiled shader to webGL program.
  88645. * @hidden
  88646. */
  88647. _program: WebGLProgram;
  88648. private _valueCache;
  88649. private static _baseCache;
  88650. /**
  88651. * Instantiates an effect.
  88652. * An effect can be used to create/manage/execute vertex and fragment shaders.
  88653. * @param baseName Name of the effect.
  88654. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  88655. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  88656. * @param samplers List of sampler variables that will be passed to the shader.
  88657. * @param engine Engine to be used to render the effect
  88658. * @param defines Define statements to be added to the shader.
  88659. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  88660. * @param onCompiled Callback that will be called when the shader is compiled.
  88661. * @param onError Callback that will be called if an error occurs during shader compilation.
  88662. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  88663. */
  88664. 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);
  88665. /**
  88666. * Unique key for this effect
  88667. */
  88668. readonly key: string;
  88669. /**
  88670. * If the effect has been compiled and prepared.
  88671. * @returns if the effect is compiled and prepared.
  88672. */
  88673. isReady(): boolean;
  88674. /**
  88675. * The engine the effect was initialized with.
  88676. * @returns the engine.
  88677. */
  88678. getEngine(): Engine;
  88679. /**
  88680. * The compiled webGL program for the effect
  88681. * @returns the webGL program.
  88682. */
  88683. getProgram(): WebGLProgram;
  88684. /**
  88685. * The set of names of attribute variables for the shader.
  88686. * @returns An array of attribute names.
  88687. */
  88688. getAttributesNames(): string[];
  88689. /**
  88690. * Returns the attribute at the given index.
  88691. * @param index The index of the attribute.
  88692. * @returns The location of the attribute.
  88693. */
  88694. getAttributeLocation(index: number): number;
  88695. /**
  88696. * Returns the attribute based on the name of the variable.
  88697. * @param name of the attribute to look up.
  88698. * @returns the attribute location.
  88699. */
  88700. getAttributeLocationByName(name: string): number;
  88701. /**
  88702. * The number of attributes.
  88703. * @returns the numnber of attributes.
  88704. */
  88705. getAttributesCount(): number;
  88706. /**
  88707. * Gets the index of a uniform variable.
  88708. * @param uniformName of the uniform to look up.
  88709. * @returns the index.
  88710. */
  88711. getUniformIndex(uniformName: string): number;
  88712. /**
  88713. * Returns the attribute based on the name of the variable.
  88714. * @param uniformName of the uniform to look up.
  88715. * @returns the location of the uniform.
  88716. */
  88717. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  88718. /**
  88719. * Returns an array of sampler variable names
  88720. * @returns The array of sampler variable neames.
  88721. */
  88722. getSamplers(): string[];
  88723. /**
  88724. * The error from the last compilation.
  88725. * @returns the error string.
  88726. */
  88727. getCompilationError(): string;
  88728. /**
  88729. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  88730. * @param func The callback to be used.
  88731. */
  88732. executeWhenCompiled(func: (effect: Effect) => void): void;
  88733. private _checkIsReady;
  88734. /** @hidden */
  88735. _loadVertexShader(vertex: any, callback: (data: any) => void): void;
  88736. /** @hidden */
  88737. _loadFragmentShader(fragment: any, callback: (data: any) => void): void;
  88738. /** @hidden */
  88739. _dumpShadersSource(vertexCode: string, fragmentCode: string, defines: string): void;
  88740. private _processShaderConversion;
  88741. private _processIncludes;
  88742. private _processPrecision;
  88743. /**
  88744. * Recompiles the webGL program
  88745. * @param vertexSourceCode The source code for the vertex shader.
  88746. * @param fragmentSourceCode The source code for the fragment shader.
  88747. * @param onCompiled Callback called when completed.
  88748. * @param onError Callback called on error.
  88749. * @hidden
  88750. */
  88751. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void): void;
  88752. /**
  88753. * Gets the uniform locations of the the specified variable names
  88754. * @param names THe names of the variables to lookup.
  88755. * @returns Array of locations in the same order as variable names.
  88756. */
  88757. getSpecificUniformLocations(names: string[]): Nullable<WebGLUniformLocation>[];
  88758. /**
  88759. * Prepares the effect
  88760. * @hidden
  88761. */
  88762. _prepareEffect(): void;
  88763. /**
  88764. * Checks if the effect is supported. (Must be called after compilation)
  88765. */
  88766. readonly isSupported: boolean;
  88767. /**
  88768. * Binds a texture to the engine to be used as output of the shader.
  88769. * @param channel Name of the output variable.
  88770. * @param texture Texture to bind.
  88771. * @hidden
  88772. */
  88773. _bindTexture(channel: string, texture: InternalTexture): void;
  88774. /**
  88775. * Sets a texture on the engine to be used in the shader.
  88776. * @param channel Name of the sampler variable.
  88777. * @param texture Texture to set.
  88778. */
  88779. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  88780. /**
  88781. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  88782. * @param channel Name of the sampler variable.
  88783. * @param texture Texture to set.
  88784. */
  88785. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  88786. /**
  88787. * Sets an array of textures on the engine to be used in the shader.
  88788. * @param channel Name of the variable.
  88789. * @param textures Textures to set.
  88790. */
  88791. setTextureArray(channel: string, textures: BaseTexture[]): void;
  88792. /**
  88793. * 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)
  88794. * @param channel Name of the sampler variable.
  88795. * @param postProcess Post process to get the input texture from.
  88796. */
  88797. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  88798. /**
  88799. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  88800. * 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)
  88801. * @param channel Name of the sampler variable.
  88802. * @param postProcess Post process to get the output texture from.
  88803. */
  88804. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  88805. /** @hidden */
  88806. _cacheMatrix(uniformName: string, matrix: Matrix): boolean;
  88807. /** @hidden */
  88808. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  88809. /** @hidden */
  88810. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  88811. /** @hidden */
  88812. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  88813. /**
  88814. * Binds a buffer to a uniform.
  88815. * @param buffer Buffer to bind.
  88816. * @param name Name of the uniform variable to bind to.
  88817. */
  88818. bindUniformBuffer(buffer: WebGLBuffer, name: string): void;
  88819. /**
  88820. * Binds block to a uniform.
  88821. * @param blockName Name of the block to bind.
  88822. * @param index Index to bind.
  88823. */
  88824. bindUniformBlock(blockName: string, index: number): void;
  88825. /**
  88826. * Sets an interger value on a uniform variable.
  88827. * @param uniformName Name of the variable.
  88828. * @param value Value to be set.
  88829. * @returns this effect.
  88830. */
  88831. setInt(uniformName: string, value: number): Effect;
  88832. /**
  88833. * Sets an int array on a uniform variable.
  88834. * @param uniformName Name of the variable.
  88835. * @param array array to be set.
  88836. * @returns this effect.
  88837. */
  88838. setIntArray(uniformName: string, array: Int32Array): Effect;
  88839. /**
  88840. * 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)
  88841. * @param uniformName Name of the variable.
  88842. * @param array array to be set.
  88843. * @returns this effect.
  88844. */
  88845. setIntArray2(uniformName: string, array: Int32Array): Effect;
  88846. /**
  88847. * 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)
  88848. * @param uniformName Name of the variable.
  88849. * @param array array to be set.
  88850. * @returns this effect.
  88851. */
  88852. setIntArray3(uniformName: string, array: Int32Array): Effect;
  88853. /**
  88854. * 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)
  88855. * @param uniformName Name of the variable.
  88856. * @param array array to be set.
  88857. * @returns this effect.
  88858. */
  88859. setIntArray4(uniformName: string, array: Int32Array): Effect;
  88860. /**
  88861. * Sets an float array on a uniform variable.
  88862. * @param uniformName Name of the variable.
  88863. * @param array array to be set.
  88864. * @returns this effect.
  88865. */
  88866. setFloatArray(uniformName: string, array: Float32Array): Effect;
  88867. /**
  88868. * 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)
  88869. * @param uniformName Name of the variable.
  88870. * @param array array to be set.
  88871. * @returns this effect.
  88872. */
  88873. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  88874. /**
  88875. * 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)
  88876. * @param uniformName Name of the variable.
  88877. * @param array array to be set.
  88878. * @returns this effect.
  88879. */
  88880. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  88881. /**
  88882. * 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)
  88883. * @param uniformName Name of the variable.
  88884. * @param array array to be set.
  88885. * @returns this effect.
  88886. */
  88887. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  88888. /**
  88889. * Sets an array on a uniform variable.
  88890. * @param uniformName Name of the variable.
  88891. * @param array array to be set.
  88892. * @returns this effect.
  88893. */
  88894. setArray(uniformName: string, array: number[]): Effect;
  88895. /**
  88896. * 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)
  88897. * @param uniformName Name of the variable.
  88898. * @param array array to be set.
  88899. * @returns this effect.
  88900. */
  88901. setArray2(uniformName: string, array: number[]): Effect;
  88902. /**
  88903. * 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)
  88904. * @param uniformName Name of the variable.
  88905. * @param array array to be set.
  88906. * @returns this effect.
  88907. */
  88908. setArray3(uniformName: string, array: number[]): Effect;
  88909. /**
  88910. * 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)
  88911. * @param uniformName Name of the variable.
  88912. * @param array array to be set.
  88913. * @returns this effect.
  88914. */
  88915. setArray4(uniformName: string, array: number[]): Effect;
  88916. /**
  88917. * Sets matrices on a uniform variable.
  88918. * @param uniformName Name of the variable.
  88919. * @param matrices matrices to be set.
  88920. * @returns this effect.
  88921. */
  88922. setMatrices(uniformName: string, matrices: Float32Array): Effect;
  88923. /**
  88924. * Sets matrix on a uniform variable.
  88925. * @param uniformName Name of the variable.
  88926. * @param matrix matrix to be set.
  88927. * @returns this effect.
  88928. */
  88929. setMatrix(uniformName: string, matrix: Matrix): Effect;
  88930. /**
  88931. * 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)
  88932. * @param uniformName Name of the variable.
  88933. * @param matrix matrix to be set.
  88934. * @returns this effect.
  88935. */
  88936. setMatrix3x3(uniformName: string, matrix: Float32Array): Effect;
  88937. /**
  88938. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  88939. * @param uniformName Name of the variable.
  88940. * @param matrix matrix to be set.
  88941. * @returns this effect.
  88942. */
  88943. setMatrix2x2(uniformName: string, matrix: Float32Array): Effect;
  88944. /**
  88945. * Sets a float on a uniform variable.
  88946. * @param uniformName Name of the variable.
  88947. * @param value value to be set.
  88948. * @returns this effect.
  88949. */
  88950. setFloat(uniformName: string, value: number): Effect;
  88951. /**
  88952. * Sets a boolean on a uniform variable.
  88953. * @param uniformName Name of the variable.
  88954. * @param bool value to be set.
  88955. * @returns this effect.
  88956. */
  88957. setBool(uniformName: string, bool: boolean): Effect;
  88958. /**
  88959. * Sets a Vector2 on a uniform variable.
  88960. * @param uniformName Name of the variable.
  88961. * @param vector2 vector2 to be set.
  88962. * @returns this effect.
  88963. */
  88964. setVector2(uniformName: string, vector2: Vector2): Effect;
  88965. /**
  88966. * Sets a float2 on a uniform variable.
  88967. * @param uniformName Name of the variable.
  88968. * @param x First float in float2.
  88969. * @param y Second float in float2.
  88970. * @returns this effect.
  88971. */
  88972. setFloat2(uniformName: string, x: number, y: number): Effect;
  88973. /**
  88974. * Sets a Vector3 on a uniform variable.
  88975. * @param uniformName Name of the variable.
  88976. * @param vector3 Value to be set.
  88977. * @returns this effect.
  88978. */
  88979. setVector3(uniformName: string, vector3: Vector3): Effect;
  88980. /**
  88981. * Sets a float3 on a uniform variable.
  88982. * @param uniformName Name of the variable.
  88983. * @param x First float in float3.
  88984. * @param y Second float in float3.
  88985. * @param z Third float in float3.
  88986. * @returns this effect.
  88987. */
  88988. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  88989. /**
  88990. * Sets a Vector4 on a uniform variable.
  88991. * @param uniformName Name of the variable.
  88992. * @param vector4 Value to be set.
  88993. * @returns this effect.
  88994. */
  88995. setVector4(uniformName: string, vector4: Vector4): Effect;
  88996. /**
  88997. * Sets a float4 on a uniform variable.
  88998. * @param uniformName Name of the variable.
  88999. * @param x First float in float4.
  89000. * @param y Second float in float4.
  89001. * @param z Third float in float4.
  89002. * @param w Fourth float in float4.
  89003. * @returns this effect.
  89004. */
  89005. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  89006. /**
  89007. * Sets a Color3 on a uniform variable.
  89008. * @param uniformName Name of the variable.
  89009. * @param color3 Value to be set.
  89010. * @returns this effect.
  89011. */
  89012. setColor3(uniformName: string, color3: Color3): Effect;
  89013. /**
  89014. * Sets a Color4 on a uniform variable.
  89015. * @param uniformName Name of the variable.
  89016. * @param color3 Value to be set.
  89017. * @param alpha Alpha value to be set.
  89018. * @returns this effect.
  89019. */
  89020. setColor4(uniformName: string, color3: Color3, alpha: number): Effect;
  89021. /**
  89022. * Sets a Color4 on a uniform variable
  89023. * @param uniformName defines the name of the variable
  89024. * @param color4 defines the value to be set
  89025. * @returns this effect.
  89026. */
  89027. setDirectColor4(uniformName: string, color4: Color4): Effect;
  89028. /** Release all associated resources */
  89029. dispose(): void;
  89030. /**
  89031. * This function will add a new shader to the shader store
  89032. * @param name the name of the shader
  89033. * @param pixelShader optional pixel shader content
  89034. * @param vertexShader optional vertex shader content
  89035. */
  89036. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  89037. /**
  89038. * Store of each shader (The can be looked up using effect.key)
  89039. */
  89040. static ShadersStore: {
  89041. [key: string]: string;
  89042. };
  89043. /**
  89044. * Store of each included file for a shader (The can be looked up using effect.key)
  89045. */
  89046. static IncludesShadersStore: {
  89047. [key: string]: string;
  89048. };
  89049. /**
  89050. * Resets the cache of effects.
  89051. */
  89052. static ResetCache(): void;
  89053. }
  89054. }
  89055. declare module BABYLON {
  89056. /**
  89057. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  89058. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  89059. * 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;
  89060. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  89061. */
  89062. export class ColorCurves {
  89063. private _dirty;
  89064. private _tempColor;
  89065. private _globalCurve;
  89066. private _highlightsCurve;
  89067. private _midtonesCurve;
  89068. private _shadowsCurve;
  89069. private _positiveCurve;
  89070. private _negativeCurve;
  89071. private _globalHue;
  89072. private _globalDensity;
  89073. private _globalSaturation;
  89074. private _globalExposure;
  89075. /**
  89076. * Gets the global Hue value.
  89077. * 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).
  89078. */
  89079. /**
  89080. * Sets the global Hue value.
  89081. * 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).
  89082. */
  89083. globalHue: number;
  89084. /**
  89085. * Gets the global Density value.
  89086. * 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.
  89087. * Values less than zero provide a filter of opposite hue.
  89088. */
  89089. /**
  89090. * Sets the global Density value.
  89091. * 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.
  89092. * Values less than zero provide a filter of opposite hue.
  89093. */
  89094. globalDensity: number;
  89095. /**
  89096. * Gets the global Saturation value.
  89097. * 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.
  89098. */
  89099. /**
  89100. * Sets the global Saturation value.
  89101. * 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.
  89102. */
  89103. globalSaturation: number;
  89104. /**
  89105. * Gets the global Exposure value.
  89106. * 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.
  89107. */
  89108. /**
  89109. * Sets the global Exposure value.
  89110. * 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.
  89111. */
  89112. globalExposure: number;
  89113. private _highlightsHue;
  89114. private _highlightsDensity;
  89115. private _highlightsSaturation;
  89116. private _highlightsExposure;
  89117. /**
  89118. * Gets the highlights Hue value.
  89119. * 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).
  89120. */
  89121. /**
  89122. * Sets the highlights Hue value.
  89123. * 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).
  89124. */
  89125. highlightsHue: number;
  89126. /**
  89127. * Gets the highlights Density value.
  89128. * 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.
  89129. * Values less than zero provide a filter of opposite hue.
  89130. */
  89131. /**
  89132. * Sets the highlights Density value.
  89133. * 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.
  89134. * Values less than zero provide a filter of opposite hue.
  89135. */
  89136. highlightsDensity: number;
  89137. /**
  89138. * Gets the highlights Saturation value.
  89139. * 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.
  89140. */
  89141. /**
  89142. * Sets the highlights Saturation value.
  89143. * 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.
  89144. */
  89145. highlightsSaturation: number;
  89146. /**
  89147. * Gets the highlights Exposure value.
  89148. * 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.
  89149. */
  89150. /**
  89151. * Sets the highlights Exposure value.
  89152. * 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.
  89153. */
  89154. highlightsExposure: number;
  89155. private _midtonesHue;
  89156. private _midtonesDensity;
  89157. private _midtonesSaturation;
  89158. private _midtonesExposure;
  89159. /**
  89160. * Gets the midtones Hue value.
  89161. * 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).
  89162. */
  89163. /**
  89164. * Sets the midtones Hue value.
  89165. * 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).
  89166. */
  89167. midtonesHue: number;
  89168. /**
  89169. * Gets the midtones Density value.
  89170. * 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.
  89171. * Values less than zero provide a filter of opposite hue.
  89172. */
  89173. /**
  89174. * Sets the midtones Density value.
  89175. * 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.
  89176. * Values less than zero provide a filter of opposite hue.
  89177. */
  89178. midtonesDensity: number;
  89179. /**
  89180. * Gets the midtones Saturation value.
  89181. * 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.
  89182. */
  89183. /**
  89184. * Sets the midtones Saturation value.
  89185. * 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.
  89186. */
  89187. midtonesSaturation: number;
  89188. /**
  89189. * Gets the midtones Exposure value.
  89190. * 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.
  89191. */
  89192. /**
  89193. * Sets the midtones Exposure value.
  89194. * 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.
  89195. */
  89196. midtonesExposure: number;
  89197. private _shadowsHue;
  89198. private _shadowsDensity;
  89199. private _shadowsSaturation;
  89200. private _shadowsExposure;
  89201. /**
  89202. * Gets the shadows Hue value.
  89203. * 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).
  89204. */
  89205. /**
  89206. * Sets the shadows Hue value.
  89207. * 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).
  89208. */
  89209. shadowsHue: number;
  89210. /**
  89211. * Gets the shadows Density value.
  89212. * 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.
  89213. * Values less than zero provide a filter of opposite hue.
  89214. */
  89215. /**
  89216. * Sets the shadows Density value.
  89217. * 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.
  89218. * Values less than zero provide a filter of opposite hue.
  89219. */
  89220. shadowsDensity: number;
  89221. /**
  89222. * Gets the shadows Saturation value.
  89223. * 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.
  89224. */
  89225. /**
  89226. * Sets the shadows Saturation value.
  89227. * 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.
  89228. */
  89229. shadowsSaturation: number;
  89230. /**
  89231. * Gets the shadows Exposure value.
  89232. * 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.
  89233. */
  89234. /**
  89235. * Sets the shadows Exposure value.
  89236. * 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.
  89237. */
  89238. shadowsExposure: number;
  89239. /**
  89240. * Returns the class name
  89241. * @returns The class name
  89242. */
  89243. getClassName(): string;
  89244. /**
  89245. * Binds the color curves to the shader.
  89246. * @param colorCurves The color curve to bind
  89247. * @param effect The effect to bind to
  89248. * @param positiveUniform The positive uniform shader parameter
  89249. * @param neutralUniform The neutral uniform shader parameter
  89250. * @param negativeUniform The negative uniform shader parameter
  89251. */
  89252. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  89253. /**
  89254. * Prepare the list of uniforms associated with the ColorCurves effects.
  89255. * @param uniformsList The list of uniforms used in the effect
  89256. */
  89257. static PrepareUniforms(uniformsList: string[]): void;
  89258. /**
  89259. * Returns color grading data based on a hue, density, saturation and exposure value.
  89260. * @param filterHue The hue of the color filter.
  89261. * @param filterDensity The density of the color filter.
  89262. * @param saturation The saturation.
  89263. * @param exposure The exposure.
  89264. * @param result The result data container.
  89265. */
  89266. private getColorGradingDataToRef;
  89267. /**
  89268. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  89269. * @param value The input slider value in range [-100,100].
  89270. * @returns Adjusted value.
  89271. */
  89272. private static applyColorGradingSliderNonlinear;
  89273. /**
  89274. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  89275. * @param hue The hue (H) input.
  89276. * @param saturation The saturation (S) input.
  89277. * @param brightness The brightness (B) input.
  89278. * @result An RGBA color represented as Vector4.
  89279. */
  89280. private static fromHSBToRef;
  89281. /**
  89282. * Returns a value clamped between min and max
  89283. * @param value The value to clamp
  89284. * @param min The minimum of value
  89285. * @param max The maximum of value
  89286. * @returns The clamped value.
  89287. */
  89288. private static clamp;
  89289. /**
  89290. * Clones the current color curve instance.
  89291. * @return The cloned curves
  89292. */
  89293. clone(): ColorCurves;
  89294. /**
  89295. * Serializes the current color curve instance to a json representation.
  89296. * @return a JSON representation
  89297. */
  89298. serialize(): any;
  89299. /**
  89300. * Parses the color curve from a json representation.
  89301. * @param source the JSON source to parse
  89302. * @return The parsed curves
  89303. */
  89304. static Parse(source: any): ColorCurves;
  89305. }
  89306. }
  89307. declare module BABYLON {
  89308. /**
  89309. * Interface to follow in your material defines to integrate easily the
  89310. * Image proccessing functions.
  89311. * @hidden
  89312. */
  89313. export interface IImageProcessingConfigurationDefines {
  89314. IMAGEPROCESSING: boolean;
  89315. VIGNETTE: boolean;
  89316. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89317. VIGNETTEBLENDMODEOPAQUE: boolean;
  89318. TONEMAPPING: boolean;
  89319. TONEMAPPING_ACES: boolean;
  89320. CONTRAST: boolean;
  89321. EXPOSURE: boolean;
  89322. COLORCURVES: boolean;
  89323. COLORGRADING: boolean;
  89324. COLORGRADING3D: boolean;
  89325. SAMPLER3DGREENDEPTH: boolean;
  89326. SAMPLER3DBGRMAP: boolean;
  89327. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89328. }
  89329. /**
  89330. * @hidden
  89331. */
  89332. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  89333. IMAGEPROCESSING: boolean;
  89334. VIGNETTE: boolean;
  89335. VIGNETTEBLENDMODEMULTIPLY: boolean;
  89336. VIGNETTEBLENDMODEOPAQUE: boolean;
  89337. TONEMAPPING: boolean;
  89338. TONEMAPPING_ACES: boolean;
  89339. CONTRAST: boolean;
  89340. COLORCURVES: boolean;
  89341. COLORGRADING: boolean;
  89342. COLORGRADING3D: boolean;
  89343. SAMPLER3DGREENDEPTH: boolean;
  89344. SAMPLER3DBGRMAP: boolean;
  89345. IMAGEPROCESSINGPOSTPROCESS: boolean;
  89346. EXPOSURE: boolean;
  89347. constructor();
  89348. }
  89349. /**
  89350. * This groups together the common properties used for image processing either in direct forward pass
  89351. * or through post processing effect depending on the use of the image processing pipeline in your scene
  89352. * or not.
  89353. */
  89354. export class ImageProcessingConfiguration {
  89355. /**
  89356. * Default tone mapping applied in BabylonJS.
  89357. */
  89358. static readonly TONEMAPPING_STANDARD: number;
  89359. /**
  89360. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  89361. * to other engines rendering to increase portability.
  89362. */
  89363. static readonly TONEMAPPING_ACES: number;
  89364. /**
  89365. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  89366. */
  89367. colorCurves: Nullable<ColorCurves>;
  89368. private _colorCurvesEnabled;
  89369. /**
  89370. * Gets wether the color curves effect is enabled.
  89371. */
  89372. /**
  89373. * Sets wether the color curves effect is enabled.
  89374. */
  89375. colorCurvesEnabled: boolean;
  89376. private _colorGradingTexture;
  89377. /**
  89378. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89379. */
  89380. /**
  89381. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  89382. */
  89383. colorGradingTexture: Nullable<BaseTexture>;
  89384. private _colorGradingEnabled;
  89385. /**
  89386. * Gets wether the color grading effect is enabled.
  89387. */
  89388. /**
  89389. * Sets wether the color grading effect is enabled.
  89390. */
  89391. colorGradingEnabled: boolean;
  89392. private _colorGradingWithGreenDepth;
  89393. /**
  89394. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  89395. */
  89396. /**
  89397. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  89398. */
  89399. colorGradingWithGreenDepth: boolean;
  89400. private _colorGradingBGR;
  89401. /**
  89402. * Gets wether the color grading texture contains BGR values.
  89403. */
  89404. /**
  89405. * Sets wether the color grading texture contains BGR values.
  89406. */
  89407. colorGradingBGR: boolean;
  89408. /** @hidden */
  89409. _exposure: number;
  89410. /**
  89411. * Gets the Exposure used in the effect.
  89412. */
  89413. /**
  89414. * Sets the Exposure used in the effect.
  89415. */
  89416. exposure: number;
  89417. private _toneMappingEnabled;
  89418. /**
  89419. * Gets wether the tone mapping effect is enabled.
  89420. */
  89421. /**
  89422. * Sets wether the tone mapping effect is enabled.
  89423. */
  89424. toneMappingEnabled: boolean;
  89425. private _toneMappingType;
  89426. /**
  89427. * Gets the type of tone mapping effect.
  89428. */
  89429. /**
  89430. * Sets the type of tone mapping effect used in BabylonJS.
  89431. */
  89432. toneMappingType: number;
  89433. protected _contrast: number;
  89434. /**
  89435. * Gets the contrast used in the effect.
  89436. */
  89437. /**
  89438. * Sets the contrast used in the effect.
  89439. */
  89440. contrast: number;
  89441. /**
  89442. * Vignette stretch size.
  89443. */
  89444. vignetteStretch: number;
  89445. /**
  89446. * Vignette centre X Offset.
  89447. */
  89448. vignetteCentreX: number;
  89449. /**
  89450. * Vignette centre Y Offset.
  89451. */
  89452. vignetteCentreY: number;
  89453. /**
  89454. * Vignette weight or intensity of the vignette effect.
  89455. */
  89456. vignetteWeight: number;
  89457. /**
  89458. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  89459. * if vignetteEnabled is set to true.
  89460. */
  89461. vignetteColor: Color4;
  89462. /**
  89463. * Camera field of view used by the Vignette effect.
  89464. */
  89465. vignetteCameraFov: number;
  89466. private _vignetteBlendMode;
  89467. /**
  89468. * Gets the vignette blend mode allowing different kind of effect.
  89469. */
  89470. /**
  89471. * Sets the vignette blend mode allowing different kind of effect.
  89472. */
  89473. vignetteBlendMode: number;
  89474. private _vignetteEnabled;
  89475. /**
  89476. * Gets wether the vignette effect is enabled.
  89477. */
  89478. /**
  89479. * Sets wether the vignette effect is enabled.
  89480. */
  89481. vignetteEnabled: boolean;
  89482. private _applyByPostProcess;
  89483. /**
  89484. * Gets wether the image processing is applied through a post process or not.
  89485. */
  89486. /**
  89487. * Sets wether the image processing is applied through a post process or not.
  89488. */
  89489. applyByPostProcess: boolean;
  89490. private _isEnabled;
  89491. /**
  89492. * Gets wether the image processing is enabled or not.
  89493. */
  89494. /**
  89495. * Sets wether the image processing is enabled or not.
  89496. */
  89497. isEnabled: boolean;
  89498. /**
  89499. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89500. */
  89501. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89502. /**
  89503. * Method called each time the image processing information changes requires to recompile the effect.
  89504. */
  89505. protected _updateParameters(): void;
  89506. /**
  89507. * Gets the current class name.
  89508. * @return "ImageProcessingConfiguration"
  89509. */
  89510. getClassName(): string;
  89511. /**
  89512. * Prepare the list of uniforms associated with the Image Processing effects.
  89513. * @param uniforms The list of uniforms used in the effect
  89514. * @param defines the list of defines currently in use
  89515. */
  89516. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89517. /**
  89518. * Prepare the list of samplers associated with the Image Processing effects.
  89519. * @param samplersList The list of uniforms used in the effect
  89520. * @param defines the list of defines currently in use
  89521. */
  89522. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89523. /**
  89524. * Prepare the list of defines associated to the shader.
  89525. * @param defines the list of defines to complete
  89526. * @param forPostProcess Define if we are currently in post process mode or not
  89527. */
  89528. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89529. /**
  89530. * Returns true if all the image processing information are ready.
  89531. * @returns True if ready, otherwise, false
  89532. */
  89533. isReady(): boolean;
  89534. /**
  89535. * Binds the image processing to the shader.
  89536. * @param effect The effect to bind to
  89537. * @param aspectRatio Define the current aspect ratio of the effect
  89538. */
  89539. bind(effect: Effect, aspectRatio?: number): void;
  89540. /**
  89541. * Clones the current image processing instance.
  89542. * @return The cloned image processing
  89543. */
  89544. clone(): ImageProcessingConfiguration;
  89545. /**
  89546. * Serializes the current image processing instance to a json representation.
  89547. * @return a JSON representation
  89548. */
  89549. serialize(): any;
  89550. /**
  89551. * Parses the image processing from a json representation.
  89552. * @param source the JSON source to parse
  89553. * @return The parsed image processing
  89554. */
  89555. static Parse(source: any): ImageProcessingConfiguration;
  89556. private static _VIGNETTEMODE_MULTIPLY;
  89557. private static _VIGNETTEMODE_OPAQUE;
  89558. /**
  89559. * Used to apply the vignette as a mix with the pixel color.
  89560. */
  89561. static readonly VIGNETTEMODE_MULTIPLY: number;
  89562. /**
  89563. * Used to apply the vignette as a replacement of the pixel color.
  89564. */
  89565. static readonly VIGNETTEMODE_OPAQUE: number;
  89566. }
  89567. }
  89568. declare module BABYLON {
  89569. /**
  89570. * This represents all the required information to add a fresnel effect on a material:
  89571. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  89572. */
  89573. export class FresnelParameters {
  89574. private _isEnabled;
  89575. /**
  89576. * Define if the fresnel effect is enable or not.
  89577. */
  89578. isEnabled: boolean;
  89579. /**
  89580. * Define the color used on edges (grazing angle)
  89581. */
  89582. leftColor: Color3;
  89583. /**
  89584. * Define the color used on center
  89585. */
  89586. rightColor: Color3;
  89587. /**
  89588. * Define bias applied to computed fresnel term
  89589. */
  89590. bias: number;
  89591. /**
  89592. * Defined the power exponent applied to fresnel term
  89593. */
  89594. power: number;
  89595. /**
  89596. * Clones the current fresnel and its valuues
  89597. * @returns a clone fresnel configuration
  89598. */
  89599. clone(): FresnelParameters;
  89600. /**
  89601. * Serializes the current fresnel parameters to a JSON representation.
  89602. * @return the JSON serialization
  89603. */
  89604. serialize(): any;
  89605. /**
  89606. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  89607. * @param parsedFresnelParameters Define the JSON representation
  89608. * @returns the parsed parameters
  89609. */
  89610. static Parse(parsedFresnelParameters: any): FresnelParameters;
  89611. }
  89612. }
  89613. declare module BABYLON {
  89614. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  89615. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89616. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89617. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89618. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89619. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89620. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89621. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89622. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89623. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89624. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89625. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89626. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89627. /**
  89628. * Decorator used to define property that can be serialized as reference to a camera
  89629. * @param sourceName defines the name of the property to decorate
  89630. */
  89631. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  89632. /**
  89633. * Class used to help serialization objects
  89634. */
  89635. export class SerializationHelper {
  89636. /** hidden */
  89637. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  89638. /** hidden */
  89639. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  89640. /** hidden */
  89641. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  89642. /** hidden */
  89643. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  89644. /**
  89645. * Appends the serialized animations from the source animations
  89646. * @param source Source containing the animations
  89647. * @param destination Target to store the animations
  89648. */
  89649. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  89650. /**
  89651. * Static function used to serialized a specific entity
  89652. * @param entity defines the entity to serialize
  89653. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  89654. * @returns a JSON compatible object representing the serialization of the entity
  89655. */
  89656. static Serialize<T>(entity: T, serializationObject?: any): any;
  89657. /**
  89658. * Creates a new entity from a serialization data object
  89659. * @param creationFunction defines a function used to instanciated the new entity
  89660. * @param source defines the source serialization data
  89661. * @param scene defines the hosting scene
  89662. * @param rootUrl defines the root url for resources
  89663. * @returns a new entity
  89664. */
  89665. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  89666. /**
  89667. * Clones an object
  89668. * @param creationFunction defines the function used to instanciate the new object
  89669. * @param source defines the source object
  89670. * @returns the cloned object
  89671. */
  89672. static Clone<T>(creationFunction: () => T, source: T): T;
  89673. /**
  89674. * Instanciates a new object based on a source one (some data will be shared between both object)
  89675. * @param creationFunction defines the function used to instanciate the new object
  89676. * @param source defines the source object
  89677. * @returns the new object
  89678. */
  89679. static Instanciate<T>(creationFunction: () => T, source: T): T;
  89680. }
  89681. }
  89682. declare module BABYLON {
  89683. /**
  89684. * This is the base class of all the camera used in the application.
  89685. * @see http://doc.babylonjs.com/features/cameras
  89686. */
  89687. export class Camera extends Node {
  89688. /** @hidden */
  89689. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  89690. /**
  89691. * This is the default projection mode used by the cameras.
  89692. * It helps recreating a feeling of perspective and better appreciate depth.
  89693. * This is the best way to simulate real life cameras.
  89694. */
  89695. static readonly PERSPECTIVE_CAMERA: number;
  89696. /**
  89697. * This helps creating camera with an orthographic mode.
  89698. * 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.
  89699. */
  89700. static readonly ORTHOGRAPHIC_CAMERA: number;
  89701. /**
  89702. * This is the default FOV mode for perspective cameras.
  89703. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  89704. */
  89705. static readonly FOVMODE_VERTICAL_FIXED: number;
  89706. /**
  89707. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  89708. */
  89709. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  89710. /**
  89711. * This specifies ther is no need for a camera rig.
  89712. * Basically only one eye is rendered corresponding to the camera.
  89713. */
  89714. static readonly RIG_MODE_NONE: number;
  89715. /**
  89716. * Simulates a camera Rig with one blue eye and one red eye.
  89717. * This can be use with 3d blue and red glasses.
  89718. */
  89719. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  89720. /**
  89721. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  89722. */
  89723. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  89724. /**
  89725. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  89726. */
  89727. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  89728. /**
  89729. * Defines that both eyes of the camera will be rendered over under each other.
  89730. */
  89731. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  89732. /**
  89733. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  89734. */
  89735. static readonly RIG_MODE_VR: number;
  89736. /**
  89737. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  89738. */
  89739. static readonly RIG_MODE_WEBVR: number;
  89740. /**
  89741. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  89742. */
  89743. static readonly RIG_MODE_CUSTOM: number;
  89744. /**
  89745. * Defines if by default attaching controls should prevent the default javascript event to continue.
  89746. */
  89747. static ForceAttachControlToAlwaysPreventDefault: boolean;
  89748. /**
  89749. * Define the input manager associated with the camera.
  89750. */
  89751. inputs: CameraInputsManager<Camera>;
  89752. /** @hidden */
  89753. _position: Vector3;
  89754. /**
  89755. * Define the current local position of the camera in the scene
  89756. */
  89757. position: Vector3;
  89758. /**
  89759. * The vector the camera should consider as up.
  89760. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  89761. */
  89762. upVector: Vector3;
  89763. /**
  89764. * Define the current limit on the left side for an orthographic camera
  89765. * In scene unit
  89766. */
  89767. orthoLeft: Nullable<number>;
  89768. /**
  89769. * Define the current limit on the right side for an orthographic camera
  89770. * In scene unit
  89771. */
  89772. orthoRight: Nullable<number>;
  89773. /**
  89774. * Define the current limit on the bottom side for an orthographic camera
  89775. * In scene unit
  89776. */
  89777. orthoBottom: Nullable<number>;
  89778. /**
  89779. * Define the current limit on the top side for an orthographic camera
  89780. * In scene unit
  89781. */
  89782. orthoTop: Nullable<number>;
  89783. /**
  89784. * Field Of View is set in Radians. (default is 0.8)
  89785. */
  89786. fov: number;
  89787. /**
  89788. * Define the minimum distance the camera can see from.
  89789. * This is important to note that the depth buffer are not infinite and the closer it starts
  89790. * the more your scene might encounter depth fighting issue.
  89791. */
  89792. minZ: number;
  89793. /**
  89794. * Define the maximum distance the camera can see to.
  89795. * This is important to note that the depth buffer are not infinite and the further it end
  89796. * the more your scene might encounter depth fighting issue.
  89797. */
  89798. maxZ: number;
  89799. /**
  89800. * Define the default inertia of the camera.
  89801. * This helps giving a smooth feeling to the camera movement.
  89802. */
  89803. inertia: number;
  89804. /**
  89805. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  89806. */
  89807. mode: number;
  89808. /**
  89809. * Define wether the camera is intermediate.
  89810. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  89811. */
  89812. isIntermediate: boolean;
  89813. /**
  89814. * Define the viewport of the camera.
  89815. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  89816. */
  89817. viewport: Viewport;
  89818. /**
  89819. * Restricts the camera to viewing objects with the same layerMask.
  89820. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  89821. */
  89822. layerMask: number;
  89823. /**
  89824. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  89825. */
  89826. fovMode: number;
  89827. /**
  89828. * Rig mode of the camera.
  89829. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  89830. * This is normally controlled byt the camera themselves as internal use.
  89831. */
  89832. cameraRigMode: number;
  89833. /**
  89834. * Defines the distance between both "eyes" in case of a RIG
  89835. */
  89836. interaxialDistance: number;
  89837. /**
  89838. * Defines if stereoscopic rendering is done side by side or over under.
  89839. */
  89840. isStereoscopicSideBySide: boolean;
  89841. /**
  89842. * 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
  89843. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  89844. * else in the scene.
  89845. */
  89846. customRenderTargets: RenderTargetTexture[];
  89847. /**
  89848. * When set, the camera will render to this render target instead of the default canvas
  89849. */
  89850. outputRenderTarget: Nullable<RenderTargetTexture>;
  89851. /**
  89852. * Observable triggered when the camera view matrix has changed.
  89853. */
  89854. onViewMatrixChangedObservable: Observable<Camera>;
  89855. /**
  89856. * Observable triggered when the camera Projection matrix has changed.
  89857. */
  89858. onProjectionMatrixChangedObservable: Observable<Camera>;
  89859. /**
  89860. * Observable triggered when the inputs have been processed.
  89861. */
  89862. onAfterCheckInputsObservable: Observable<Camera>;
  89863. /**
  89864. * Observable triggered when reset has been called and applied to the camera.
  89865. */
  89866. onRestoreStateObservable: Observable<Camera>;
  89867. /** @hidden */
  89868. _cameraRigParams: any;
  89869. /** @hidden */
  89870. _rigCameras: Camera[];
  89871. /** @hidden */
  89872. _rigPostProcess: Nullable<PostProcess>;
  89873. protected _webvrViewMatrix: Matrix;
  89874. /** @hidden */
  89875. _skipRendering: boolean;
  89876. /** @hidden */
  89877. _projectionMatrix: Matrix;
  89878. /** @hidden */
  89879. _postProcesses: Nullable<PostProcess>[];
  89880. /** @hidden */
  89881. _activeMeshes: SmartArray<AbstractMesh>;
  89882. protected _globalPosition: Vector3;
  89883. /** hidden */
  89884. _computedViewMatrix: Matrix;
  89885. private _doNotComputeProjectionMatrix;
  89886. private _transformMatrix;
  89887. private _frustumPlanes;
  89888. private _refreshFrustumPlanes;
  89889. private _storedFov;
  89890. private _stateStored;
  89891. /**
  89892. * Instantiates a new camera object.
  89893. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  89894. * @see http://doc.babylonjs.com/features/cameras
  89895. * @param name Defines the name of the camera in the scene
  89896. * @param position Defines the position of the camera
  89897. * @param scene Defines the scene the camera belongs too
  89898. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  89899. */
  89900. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  89901. /**
  89902. * Store current camera state (fov, position, etc..)
  89903. * @returns the camera
  89904. */
  89905. storeState(): Camera;
  89906. /**
  89907. * Restores the camera state values if it has been stored. You must call storeState() first
  89908. */
  89909. protected _restoreStateValues(): boolean;
  89910. /**
  89911. * Restored camera state. You must call storeState() first.
  89912. * @returns true if restored and false otherwise
  89913. */
  89914. restoreState(): boolean;
  89915. /**
  89916. * Gets the class name of the camera.
  89917. * @returns the class name
  89918. */
  89919. getClassName(): string;
  89920. /** @hidden */
  89921. readonly _isCamera: boolean;
  89922. /**
  89923. * Gets a string representation of the camera useful for debug purpose.
  89924. * @param fullDetails Defines that a more verboe level of logging is required
  89925. * @returns the string representation
  89926. */
  89927. toString(fullDetails?: boolean): string;
  89928. /**
  89929. * Gets the current world space position of the camera.
  89930. */
  89931. readonly globalPosition: Vector3;
  89932. /**
  89933. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  89934. * @returns the active meshe list
  89935. */
  89936. getActiveMeshes(): SmartArray<AbstractMesh>;
  89937. /**
  89938. * Check wether a mesh is part of the current active mesh list of the camera
  89939. * @param mesh Defines the mesh to check
  89940. * @returns true if active, false otherwise
  89941. */
  89942. isActiveMesh(mesh: Mesh): boolean;
  89943. /**
  89944. * Is this camera ready to be used/rendered
  89945. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  89946. * @return true if the camera is ready
  89947. */
  89948. isReady(completeCheck?: boolean): boolean;
  89949. /** @hidden */
  89950. _initCache(): void;
  89951. /** @hidden */
  89952. _updateCache(ignoreParentClass?: boolean): void;
  89953. /** @hidden */
  89954. _isSynchronized(): boolean;
  89955. /** @hidden */
  89956. _isSynchronizedViewMatrix(): boolean;
  89957. /** @hidden */
  89958. _isSynchronizedProjectionMatrix(): boolean;
  89959. /**
  89960. * Attach the input controls to a specific dom element to get the input from.
  89961. * @param element Defines the element the controls should be listened from
  89962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  89963. */
  89964. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  89965. /**
  89966. * Detach the current controls from the specified dom element.
  89967. * @param element Defines the element to stop listening the inputs from
  89968. */
  89969. detachControl(element: HTMLElement): void;
  89970. /**
  89971. * Update the camera state according to the different inputs gathered during the frame.
  89972. */
  89973. update(): void;
  89974. /** @hidden */
  89975. _checkInputs(): void;
  89976. /** @hidden */
  89977. readonly rigCameras: Camera[];
  89978. /**
  89979. * Gets the post process used by the rig cameras
  89980. */
  89981. readonly rigPostProcess: Nullable<PostProcess>;
  89982. /**
  89983. * Internal, gets the first post proces.
  89984. * @returns the first post process to be run on this camera.
  89985. */
  89986. _getFirstPostProcess(): Nullable<PostProcess>;
  89987. private _cascadePostProcessesToRigCams;
  89988. /**
  89989. * Attach a post process to the camera.
  89990. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89991. * @param postProcess The post process to attach to the camera
  89992. * @param insertAt The position of the post process in case several of them are in use in the scene
  89993. * @returns the position the post process has been inserted at
  89994. */
  89995. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  89996. /**
  89997. * Detach a post process to the camera.
  89998. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  89999. * @param postProcess The post process to detach from the camera
  90000. */
  90001. detachPostProcess(postProcess: PostProcess): void;
  90002. /**
  90003. * Gets the current world matrix of the camera
  90004. */
  90005. getWorldMatrix(): Matrix;
  90006. /** @hidden */
  90007. _getViewMatrix(): Matrix;
  90008. /**
  90009. * Gets the current view matrix of the camera.
  90010. * @param force forces the camera to recompute the matrix without looking at the cached state
  90011. * @returns the view matrix
  90012. */
  90013. getViewMatrix(force?: boolean): Matrix;
  90014. /**
  90015. * Freeze the projection matrix.
  90016. * It will prevent the cache check of the camera projection compute and can speed up perf
  90017. * if no parameter of the camera are meant to change
  90018. * @param projection Defines manually a projection if necessary
  90019. */
  90020. freezeProjectionMatrix(projection?: Matrix): void;
  90021. /**
  90022. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  90023. */
  90024. unfreezeProjectionMatrix(): void;
  90025. /**
  90026. * Gets the current projection matrix of the camera.
  90027. * @param force forces the camera to recompute the matrix without looking at the cached state
  90028. * @returns the projection matrix
  90029. */
  90030. getProjectionMatrix(force?: boolean): Matrix;
  90031. /**
  90032. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  90033. * @returns a Matrix
  90034. */
  90035. getTransformationMatrix(): Matrix;
  90036. private _updateFrustumPlanes;
  90037. /**
  90038. * Checks if a cullable object (mesh...) is in the camera frustum
  90039. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  90040. * @param target The object to check
  90041. * @returns true if the object is in frustum otherwise false
  90042. */
  90043. isInFrustum(target: ICullable): boolean;
  90044. /**
  90045. * Checks if a cullable object (mesh...) is in the camera frustum
  90046. * Unlike isInFrustum this cheks the full bounding box
  90047. * @param target The object to check
  90048. * @returns true if the object is in frustum otherwise false
  90049. */
  90050. isCompletelyInFrustum(target: ICullable): boolean;
  90051. /**
  90052. * Gets a ray in the forward direction from the camera.
  90053. * @param length Defines the length of the ray to create
  90054. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  90055. * @param origin Defines the start point of the ray which defaults to the camera position
  90056. * @returns the forward ray
  90057. */
  90058. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  90059. /**
  90060. * Releases resources associated with this node.
  90061. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  90062. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  90063. */
  90064. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  90065. /** @hidden */
  90066. _isLeftCamera: boolean;
  90067. /**
  90068. * Gets the left camera of a rig setup in case of Rigged Camera
  90069. */
  90070. readonly isLeftCamera: boolean;
  90071. /** @hidden */
  90072. _isRightCamera: boolean;
  90073. /**
  90074. * Gets the right camera of a rig setup in case of Rigged Camera
  90075. */
  90076. readonly isRightCamera: boolean;
  90077. /**
  90078. * Gets the left camera of a rig setup in case of Rigged Camera
  90079. */
  90080. readonly leftCamera: Nullable<FreeCamera>;
  90081. /**
  90082. * Gets the right camera of a rig setup in case of Rigged Camera
  90083. */
  90084. readonly rightCamera: Nullable<FreeCamera>;
  90085. /**
  90086. * Gets the left camera target of a rig setup in case of Rigged Camera
  90087. * @returns the target position
  90088. */
  90089. getLeftTarget(): Nullable<Vector3>;
  90090. /**
  90091. * Gets the right camera target of a rig setup in case of Rigged Camera
  90092. * @returns the target position
  90093. */
  90094. getRightTarget(): Nullable<Vector3>;
  90095. /**
  90096. * @hidden
  90097. */
  90098. setCameraRigMode(mode: number, rigParams: any): void;
  90099. /** @hidden */
  90100. static _setStereoscopicRigMode(camera: Camera): void;
  90101. /** @hidden */
  90102. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  90103. /** @hidden */
  90104. static _setVRRigMode(camera: Camera, rigParams: any): void;
  90105. /** @hidden */
  90106. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  90107. /** @hidden */
  90108. _getVRProjectionMatrix(): Matrix;
  90109. protected _updateCameraRotationMatrix(): void;
  90110. protected _updateWebVRCameraRotationMatrix(): void;
  90111. /**
  90112. * This function MUST be overwritten by the different WebVR cameras available.
  90113. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90114. * @hidden
  90115. */
  90116. _getWebVRProjectionMatrix(): Matrix;
  90117. /**
  90118. * This function MUST be overwritten by the different WebVR cameras available.
  90119. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  90120. * @hidden
  90121. */
  90122. _getWebVRViewMatrix(): Matrix;
  90123. /** @hidden */
  90124. setCameraRigParameter(name: string, value: any): void;
  90125. /**
  90126. * needs to be overridden by children so sub has required properties to be copied
  90127. * @hidden
  90128. */
  90129. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  90130. /**
  90131. * May need to be overridden by children
  90132. * @hidden
  90133. */
  90134. _updateRigCameras(): void;
  90135. /** @hidden */
  90136. _setupInputs(): void;
  90137. /**
  90138. * Serialiaze the camera setup to a json represention
  90139. * @returns the JSON representation
  90140. */
  90141. serialize(): any;
  90142. /**
  90143. * Clones the current camera.
  90144. * @param name The cloned camera name
  90145. * @returns the cloned camera
  90146. */
  90147. clone(name: string): Camera;
  90148. /**
  90149. * Gets the direction of the camera relative to a given local axis.
  90150. * @param localAxis Defines the reference axis to provide a relative direction.
  90151. * @return the direction
  90152. */
  90153. getDirection(localAxis: Vector3): Vector3;
  90154. /**
  90155. * Gets the direction of the camera relative to a given local axis into a passed vector.
  90156. * @param localAxis Defines the reference axis to provide a relative direction.
  90157. * @param result Defines the vector to store the result in
  90158. */
  90159. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  90160. /**
  90161. * Gets a camera constructor for a given camera type
  90162. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  90163. * @param name The name of the camera the result will be able to instantiate
  90164. * @param scene The scene the result will construct the camera in
  90165. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  90166. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  90167. * @returns a factory method to construc the camera
  90168. */
  90169. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  90170. /**
  90171. * Compute the world matrix of the camera.
  90172. * @returns the camera workd matrix
  90173. */
  90174. computeWorldMatrix(): Matrix;
  90175. /**
  90176. * Parse a JSON and creates the camera from the parsed information
  90177. * @param parsedCamera The JSON to parse
  90178. * @param scene The scene to instantiate the camera in
  90179. * @returns the newly constructed camera
  90180. */
  90181. static Parse(parsedCamera: any, scene: Scene): Camera;
  90182. }
  90183. }
  90184. declare module BABYLON {
  90185. /**
  90186. * Interface for any object that can request an animation frame
  90187. */
  90188. export interface ICustomAnimationFrameRequester {
  90189. /**
  90190. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  90191. */
  90192. renderFunction?: Function;
  90193. /**
  90194. * Called to request the next frame to render to
  90195. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  90196. */
  90197. requestAnimationFrame: Function;
  90198. /**
  90199. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  90200. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  90201. */
  90202. requestID?: number;
  90203. }
  90204. /**
  90205. * Interface containing an array of animations
  90206. */
  90207. export interface IAnimatable {
  90208. /**
  90209. * Array of animations
  90210. */
  90211. animations: Nullable<Array<Animation>>;
  90212. }
  90213. /** Interface used by value gradients (color, factor, ...) */
  90214. export interface IValueGradient {
  90215. /**
  90216. * Gets or sets the gradient value (between 0 and 1)
  90217. */
  90218. gradient: number;
  90219. }
  90220. /** Class used to store color4 gradient */
  90221. export class ColorGradient implements IValueGradient {
  90222. /**
  90223. * Gets or sets the gradient value (between 0 and 1)
  90224. */
  90225. gradient: number;
  90226. /**
  90227. * Gets or sets first associated color
  90228. */
  90229. color1: Color4;
  90230. /**
  90231. * Gets or sets second associated color
  90232. */
  90233. color2?: Color4;
  90234. /**
  90235. * Will get a color picked randomly between color1 and color2.
  90236. * If color2 is undefined then color1 will be used
  90237. * @param result defines the target Color4 to store the result in
  90238. */
  90239. getColorToRef(result: Color4): void;
  90240. }
  90241. /** Class used to store color 3 gradient */
  90242. export class Color3Gradient implements IValueGradient {
  90243. /**
  90244. * Gets or sets the gradient value (between 0 and 1)
  90245. */
  90246. gradient: number;
  90247. /**
  90248. * Gets or sets the associated color
  90249. */
  90250. color: Color3;
  90251. }
  90252. /** Class used to store factor gradient */
  90253. export class FactorGradient implements IValueGradient {
  90254. /**
  90255. * Gets or sets the gradient value (between 0 and 1)
  90256. */
  90257. gradient: number;
  90258. /**
  90259. * Gets or sets first associated factor
  90260. */
  90261. factor1: number;
  90262. /**
  90263. * Gets or sets second associated factor
  90264. */
  90265. factor2?: number;
  90266. /**
  90267. * Will get a number picked randomly between factor1 and factor2.
  90268. * If factor2 is undefined then factor1 will be used
  90269. * @returns the picked number
  90270. */
  90271. getFactor(): number;
  90272. }
  90273. /**
  90274. * @ignore
  90275. * Application error to support additional information when loading a file
  90276. */
  90277. export class LoadFileError extends Error {
  90278. /** defines the optional web request */
  90279. request?: WebRequest | undefined;
  90280. private static _setPrototypeOf;
  90281. /**
  90282. * Creates a new LoadFileError
  90283. * @param message defines the message of the error
  90284. * @param request defines the optional web request
  90285. */
  90286. constructor(message: string,
  90287. /** defines the optional web request */
  90288. request?: WebRequest | undefined);
  90289. }
  90290. /**
  90291. * Class used to define a retry strategy when error happens while loading assets
  90292. */
  90293. export class RetryStrategy {
  90294. /**
  90295. * Function used to defines an exponential back off strategy
  90296. * @param maxRetries defines the maximum number of retries (3 by default)
  90297. * @param baseInterval defines the interval between retries
  90298. * @returns the strategy function to use
  90299. */
  90300. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  90301. }
  90302. /**
  90303. * File request interface
  90304. */
  90305. export interface IFileRequest {
  90306. /**
  90307. * Raised when the request is complete (success or error).
  90308. */
  90309. onCompleteObservable: Observable<IFileRequest>;
  90310. /**
  90311. * Aborts the request for a file.
  90312. */
  90313. abort: () => void;
  90314. }
  90315. /**
  90316. * Class containing a set of static utilities functions
  90317. */
  90318. export class Tools {
  90319. /**
  90320. * Gets or sets the base URL to use to load assets
  90321. */
  90322. static BaseUrl: string;
  90323. /**
  90324. * Enable/Disable Custom HTTP Request Headers globally.
  90325. * default = false
  90326. * @see CustomRequestHeaders
  90327. */
  90328. static UseCustomRequestHeaders: boolean;
  90329. /**
  90330. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  90331. * i.e. when loading files, where the server/service expects an Authorization header
  90332. */
  90333. static CustomRequestHeaders: {
  90334. [key: string]: string;
  90335. };
  90336. /**
  90337. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  90338. */
  90339. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  90340. /**
  90341. * Default behaviour for cors in the application.
  90342. * It can be a string if the expected behavior is identical in the entire app.
  90343. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  90344. */
  90345. static CorsBehavior: string | ((url: string | string[]) => string);
  90346. /**
  90347. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  90348. * @ignorenaming
  90349. */
  90350. static UseFallbackTexture: boolean;
  90351. /**
  90352. * Use this object to register external classes like custom textures or material
  90353. * to allow the laoders to instantiate them
  90354. */
  90355. static RegisteredExternalClasses: {
  90356. [key: string]: Object;
  90357. };
  90358. /**
  90359. * Texture content used if a texture cannot loaded
  90360. * @ignorenaming
  90361. */
  90362. static fallbackTexture: string;
  90363. /**
  90364. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  90365. * @param u defines the coordinate on X axis
  90366. * @param v defines the coordinate on Y axis
  90367. * @param width defines the width of the source data
  90368. * @param height defines the height of the source data
  90369. * @param pixels defines the source byte array
  90370. * @param color defines the output color
  90371. */
  90372. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: Color4): void;
  90373. /**
  90374. * Interpolates between a and b via alpha
  90375. * @param a The lower value (returned when alpha = 0)
  90376. * @param b The upper value (returned when alpha = 1)
  90377. * @param alpha The interpolation-factor
  90378. * @return The mixed value
  90379. */
  90380. static Mix(a: number, b: number, alpha: number): number;
  90381. /**
  90382. * Tries to instantiate a new object from a given class name
  90383. * @param className defines the class name to instantiate
  90384. * @returns the new object or null if the system was not able to do the instantiation
  90385. */
  90386. static Instantiate(className: string): any;
  90387. /**
  90388. * Provides a slice function that will work even on IE
  90389. * @param data defines the array to slice
  90390. * @param start defines the start of the data (optional)
  90391. * @param end defines the end of the data (optional)
  90392. * @returns the new sliced array
  90393. */
  90394. static Slice<T>(data: T, start?: number, end?: number): T;
  90395. /**
  90396. * Polyfill for setImmediate
  90397. * @param action defines the action to execute after the current execution block
  90398. */
  90399. static SetImmediate(action: () => void): void;
  90400. /**
  90401. * Function indicating if a number is an exponent of 2
  90402. * @param value defines the value to test
  90403. * @returns true if the value is an exponent of 2
  90404. */
  90405. static IsExponentOfTwo(value: number): boolean;
  90406. private static _tmpFloatArray;
  90407. /**
  90408. * Returns the nearest 32-bit single precision float representation of a Number
  90409. * @param value A Number. If the parameter is of a different type, it will get converted
  90410. * to a number or to NaN if it cannot be converted
  90411. * @returns number
  90412. */
  90413. static FloatRound(value: number): number;
  90414. /**
  90415. * Find the next highest power of two.
  90416. * @param x Number to start search from.
  90417. * @return Next highest power of two.
  90418. */
  90419. static CeilingPOT(x: number): number;
  90420. /**
  90421. * Find the next lowest power of two.
  90422. * @param x Number to start search from.
  90423. * @return Next lowest power of two.
  90424. */
  90425. static FloorPOT(x: number): number;
  90426. /**
  90427. * Find the nearest power of two.
  90428. * @param x Number to start search from.
  90429. * @return Next nearest power of two.
  90430. */
  90431. static NearestPOT(x: number): number;
  90432. /**
  90433. * Get the closest exponent of two
  90434. * @param value defines the value to approximate
  90435. * @param max defines the maximum value to return
  90436. * @param mode defines how to define the closest value
  90437. * @returns closest exponent of two of the given value
  90438. */
  90439. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  90440. /**
  90441. * Extracts the filename from a path
  90442. * @param path defines the path to use
  90443. * @returns the filename
  90444. */
  90445. static GetFilename(path: string): string;
  90446. /**
  90447. * Extracts the "folder" part of a path (everything before the filename).
  90448. * @param uri The URI to extract the info from
  90449. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  90450. * @returns The "folder" part of the path
  90451. */
  90452. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  90453. /**
  90454. * Extracts text content from a DOM element hierarchy
  90455. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  90456. */
  90457. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  90458. /**
  90459. * Convert an angle in radians to degrees
  90460. * @param angle defines the angle to convert
  90461. * @returns the angle in degrees
  90462. */
  90463. static ToDegrees(angle: number): number;
  90464. /**
  90465. * Convert an angle in degrees to radians
  90466. * @param angle defines the angle to convert
  90467. * @returns the angle in radians
  90468. */
  90469. static ToRadians(angle: number): number;
  90470. /**
  90471. * Encode a buffer to a base64 string
  90472. * @param buffer defines the buffer to encode
  90473. * @returns the encoded string
  90474. */
  90475. static EncodeArrayBufferTobase64(buffer: ArrayBuffer): string;
  90476. /**
  90477. * Extracts minimum and maximum values from a list of indexed positions
  90478. * @param positions defines the positions to use
  90479. * @param indices defines the indices to the positions
  90480. * @param indexStart defines the start index
  90481. * @param indexCount defines the end index
  90482. * @param bias defines bias value to add to the result
  90483. * @return minimum and maximum values
  90484. */
  90485. static ExtractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  90486. minimum: Vector3;
  90487. maximum: Vector3;
  90488. };
  90489. /**
  90490. * Extracts minimum and maximum values from a list of positions
  90491. * @param positions defines the positions to use
  90492. * @param start defines the start index in the positions array
  90493. * @param count defines the number of positions to handle
  90494. * @param bias defines bias value to add to the result
  90495. * @param stride defines the stride size to use (distance between two positions in the positions array)
  90496. * @return minimum and maximum values
  90497. */
  90498. static ExtractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  90499. minimum: Vector3;
  90500. maximum: Vector3;
  90501. };
  90502. /**
  90503. * Returns an array if obj is not an array
  90504. * @param obj defines the object to evaluate as an array
  90505. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  90506. * @returns either obj directly if obj is an array or a new array containing obj
  90507. */
  90508. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  90509. /**
  90510. * Gets the pointer prefix to use
  90511. * @returns "pointer" if touch is enabled. Else returns "mouse"
  90512. */
  90513. static GetPointerPrefix(): string;
  90514. /**
  90515. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  90516. * @param func - the function to be called
  90517. * @param requester - the object that will request the next frame. Falls back to window.
  90518. * @returns frame number
  90519. */
  90520. static QueueNewFrame(func: () => void, requester?: any): number;
  90521. /**
  90522. * Ask the browser to promote the current element to fullscreen rendering mode
  90523. * @param element defines the DOM element to promote
  90524. */
  90525. static RequestFullscreen(element: HTMLElement): void;
  90526. /**
  90527. * Asks the browser to exit fullscreen mode
  90528. */
  90529. static ExitFullscreen(): void;
  90530. /**
  90531. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  90532. * @param url define the url we are trying
  90533. * @param element define the dom element where to configure the cors policy
  90534. */
  90535. static SetCorsBehavior(url: string | string[], element: {
  90536. crossOrigin: string | null;
  90537. }): void;
  90538. /**
  90539. * Removes unwanted characters from an url
  90540. * @param url defines the url to clean
  90541. * @returns the cleaned url
  90542. */
  90543. static CleanUrl(url: string): string;
  90544. /**
  90545. * Gets or sets a function used to pre-process url before using them to load assets
  90546. */
  90547. static PreprocessUrl: (url: string) => string;
  90548. /**
  90549. * Loads an image as an HTMLImageElement.
  90550. * @param input url string, ArrayBuffer, or Blob to load
  90551. * @param onLoad callback called when the image successfully loads
  90552. * @param onError callback called when the image fails to load
  90553. * @param offlineProvider offline provider for caching
  90554. * @returns the HTMLImageElement of the loaded image
  90555. */
  90556. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>): HTMLImageElement;
  90557. /**
  90558. * Loads a file
  90559. * @param url url string, ArrayBuffer, or Blob to load
  90560. * @param onSuccess callback called when the file successfully loads
  90561. * @param onProgress callback called while file is loading (if the server supports this mode)
  90562. * @param offlineProvider defines the offline provider for caching
  90563. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  90564. * @param onError callback called when the file fails to load
  90565. * @returns a file request object
  90566. */
  90567. 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;
  90568. /**
  90569. * Load a script (identified by an url). When the url returns, the
  90570. * content of this file is added into a new script element, attached to the DOM (body element)
  90571. * @param scriptUrl defines the url of the script to laod
  90572. * @param onSuccess defines the callback called when the script is loaded
  90573. * @param onError defines the callback to call if an error occurs
  90574. * @param scriptId defines the id of the script element
  90575. */
  90576. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  90577. /**
  90578. * Load an asynchronous script (identified by an url). When the url returns, the
  90579. * content of this file is added into a new script element, attached to the DOM (body element)
  90580. * @param scriptUrl defines the url of the script to laod
  90581. * @param scriptId defines the id of the script element
  90582. * @returns a promise request object
  90583. */
  90584. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Nullable<Promise<boolean>>;
  90585. /**
  90586. * Loads a file from a blob
  90587. * @param fileToLoad defines the blob to use
  90588. * @param callback defines the callback to call when data is loaded
  90589. * @param progressCallback defines the callback to call during loading process
  90590. * @returns a file request object
  90591. */
  90592. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  90593. /**
  90594. * Loads a file
  90595. * @param fileToLoad defines the file to load
  90596. * @param callback defines the callback to call when data is loaded
  90597. * @param progressCallBack defines the callback to call during loading process
  90598. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  90599. * @returns a file request object
  90600. */
  90601. static ReadFile(fileToLoad: File, callback: (data: any) => void, progressCallBack?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): IFileRequest;
  90602. /**
  90603. * Creates a data url from a given string content
  90604. * @param content defines the content to convert
  90605. * @returns the new data url link
  90606. */
  90607. static FileAsURL(content: string): string;
  90608. /**
  90609. * Format the given number to a specific decimal format
  90610. * @param value defines the number to format
  90611. * @param decimals defines the number of decimals to use
  90612. * @returns the formatted string
  90613. */
  90614. static Format(value: number, decimals?: number): string;
  90615. /**
  90616. * Checks if a given vector is inside a specific range
  90617. * @param v defines the vector to test
  90618. * @param min defines the minimum range
  90619. * @param max defines the maximum range
  90620. */
  90621. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  90622. /**
  90623. * Tries to copy an object by duplicating every property
  90624. * @param source defines the source object
  90625. * @param destination defines the target object
  90626. * @param doNotCopyList defines a list of properties to avoid
  90627. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  90628. */
  90629. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  90630. /**
  90631. * Gets a boolean indicating if the given object has no own property
  90632. * @param obj defines the object to test
  90633. * @returns true if object has no own property
  90634. */
  90635. static IsEmpty(obj: any): boolean;
  90636. /**
  90637. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  90638. * @param str Source string
  90639. * @param suffix Suffix to search for in the source string
  90640. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  90641. */
  90642. static EndsWith(str: string, suffix: string): boolean;
  90643. /**
  90644. * Function used to register events at window level
  90645. * @param events defines the events to register
  90646. */
  90647. static RegisterTopRootEvents(events: {
  90648. name: string;
  90649. handler: Nullable<(e: FocusEvent) => any>;
  90650. }[]): void;
  90651. /**
  90652. * Function used to unregister events from window level
  90653. * @param events defines the events to unregister
  90654. */
  90655. static UnregisterTopRootEvents(events: {
  90656. name: string;
  90657. handler: Nullable<(e: FocusEvent) => any>;
  90658. }[]): void;
  90659. /**
  90660. * @ignore
  90661. */
  90662. static _ScreenshotCanvas: HTMLCanvasElement;
  90663. /**
  90664. * Dumps the current bound framebuffer
  90665. * @param width defines the rendering width
  90666. * @param height defines the rendering height
  90667. * @param engine defines the hosting engine
  90668. * @param successCallback defines the callback triggered once the data are available
  90669. * @param mimeType defines the mime type of the result
  90670. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  90671. */
  90672. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90673. /**
  90674. * Converts the canvas data to blob.
  90675. * This acts as a polyfill for browsers not supporting the to blob function.
  90676. * @param canvas Defines the canvas to extract the data from
  90677. * @param successCallback Defines the callback triggered once the data are available
  90678. * @param mimeType Defines the mime type of the result
  90679. */
  90680. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  90681. /**
  90682. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  90683. * @param successCallback defines the callback triggered once the data are available
  90684. * @param mimeType defines the mime type of the result
  90685. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  90686. */
  90687. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  90688. /**
  90689. * Downloads a blob in the browser
  90690. * @param blob defines the blob to download
  90691. * @param fileName defines the name of the downloaded file
  90692. */
  90693. static Download(blob: Blob, fileName: string): void;
  90694. /**
  90695. * Captures a screenshot of the current rendering
  90696. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90697. * @param engine defines the rendering engine
  90698. * @param camera defines the source camera
  90699. * @param size This parameter can be set to a single number or to an object with the
  90700. * following (optional) properties: precision, width, height. If a single number is passed,
  90701. * it will be used for both width and height. If an object is passed, the screenshot size
  90702. * will be derived from the parameters. The precision property is a multiplier allowing
  90703. * rendering at a higher or lower resolution
  90704. * @param successCallback defines the callback receives a single parameter which contains the
  90705. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90706. * src parameter of an <img> to display it
  90707. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  90708. * Check your browser for supported MIME types
  90709. */
  90710. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  90711. /**
  90712. * Generates an image screenshot from the specified camera.
  90713. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  90714. * @param engine The engine to use for rendering
  90715. * @param camera The camera to use for rendering
  90716. * @param size This parameter can be set to a single number or to an object with the
  90717. * following (optional) properties: precision, width, height. If a single number is passed,
  90718. * it will be used for both width and height. If an object is passed, the screenshot size
  90719. * will be derived from the parameters. The precision property is a multiplier allowing
  90720. * rendering at a higher or lower resolution
  90721. * @param successCallback The callback receives a single parameter which contains the
  90722. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  90723. * src parameter of an <img> to display it
  90724. * @param mimeType The MIME type of the screenshot image (default: image/png).
  90725. * Check your browser for supported MIME types
  90726. * @param samples Texture samples (default: 1)
  90727. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  90728. * @param fileName A name for for the downloaded file.
  90729. */
  90730. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  90731. /**
  90732. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  90733. * Be aware Math.random() could cause collisions, but:
  90734. * "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"
  90735. * @returns a pseudo random id
  90736. */
  90737. static RandomId(): string;
  90738. /**
  90739. * Test if the given uri is a base64 string
  90740. * @param uri The uri to test
  90741. * @return True if the uri is a base64 string or false otherwise
  90742. */
  90743. static IsBase64(uri: string): boolean;
  90744. /**
  90745. * Decode the given base64 uri.
  90746. * @param uri The uri to decode
  90747. * @return The decoded base64 data.
  90748. */
  90749. static DecodeBase64(uri: string): ArrayBuffer;
  90750. /**
  90751. * Gets the absolute url.
  90752. * @param url the input url
  90753. * @return the absolute url
  90754. */
  90755. static GetAbsoluteUrl(url: string): string;
  90756. /**
  90757. * No log
  90758. */
  90759. static readonly NoneLogLevel: number;
  90760. /**
  90761. * Only message logs
  90762. */
  90763. static readonly MessageLogLevel: number;
  90764. /**
  90765. * Only warning logs
  90766. */
  90767. static readonly WarningLogLevel: number;
  90768. /**
  90769. * Only error logs
  90770. */
  90771. static readonly ErrorLogLevel: number;
  90772. /**
  90773. * All logs
  90774. */
  90775. static readonly AllLogLevel: number;
  90776. /**
  90777. * Gets a value indicating the number of loading errors
  90778. * @ignorenaming
  90779. */
  90780. static readonly errorsCount: number;
  90781. /**
  90782. * Callback called when a new log is added
  90783. */
  90784. static OnNewCacheEntry: (entry: string) => void;
  90785. /**
  90786. * Log a message to the console
  90787. * @param message defines the message to log
  90788. */
  90789. static Log(message: string): void;
  90790. /**
  90791. * Write a warning message to the console
  90792. * @param message defines the message to log
  90793. */
  90794. static Warn(message: string): void;
  90795. /**
  90796. * Write an error message to the console
  90797. * @param message defines the message to log
  90798. */
  90799. static Error(message: string): void;
  90800. /**
  90801. * Gets current log cache (list of logs)
  90802. */
  90803. static readonly LogCache: string;
  90804. /**
  90805. * Clears the log cache
  90806. */
  90807. static ClearLogCache(): void;
  90808. /**
  90809. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  90810. */
  90811. static LogLevels: number;
  90812. /**
  90813. * Checks if the loaded document was accessed via `file:`-Protocol.
  90814. * @returns boolean
  90815. */
  90816. static IsFileURL(): boolean;
  90817. /**
  90818. * Checks if the window object exists
  90819. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  90820. */
  90821. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  90822. /**
  90823. * No performance log
  90824. */
  90825. static readonly PerformanceNoneLogLevel: number;
  90826. /**
  90827. * Use user marks to log performance
  90828. */
  90829. static readonly PerformanceUserMarkLogLevel: number;
  90830. /**
  90831. * Log performance to the console
  90832. */
  90833. static readonly PerformanceConsoleLogLevel: number;
  90834. private static _performance;
  90835. /**
  90836. * Sets the current performance log level
  90837. */
  90838. static PerformanceLogLevel: number;
  90839. private static _StartPerformanceCounterDisabled;
  90840. private static _EndPerformanceCounterDisabled;
  90841. private static _StartUserMark;
  90842. private static _EndUserMark;
  90843. private static _StartPerformanceConsole;
  90844. private static _EndPerformanceConsole;
  90845. /**
  90846. * Starts a performance counter
  90847. */
  90848. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90849. /**
  90850. * Ends a specific performance coutner
  90851. */
  90852. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  90853. /**
  90854. * Gets either window.performance.now() if supported or Date.now() else
  90855. */
  90856. static readonly Now: number;
  90857. /**
  90858. * This method will return the name of the class used to create the instance of the given object.
  90859. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  90860. * @param object the object to get the class name from
  90861. * @param isType defines if the object is actually a type
  90862. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  90863. */
  90864. static GetClassName(object: any, isType?: boolean): string;
  90865. /**
  90866. * Gets the first element of an array satisfying a given predicate
  90867. * @param array defines the array to browse
  90868. * @param predicate defines the predicate to use
  90869. * @returns null if not found or the element
  90870. */
  90871. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  90872. /**
  90873. * This method will return the name of the full name of the class, including its owning module (if any).
  90874. * 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).
  90875. * @param object the object to get the class name from
  90876. * @param isType defines if the object is actually a type
  90877. * @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.
  90878. * @ignorenaming
  90879. */
  90880. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  90881. /**
  90882. * Returns a promise that resolves after the given amount of time.
  90883. * @param delay Number of milliseconds to delay
  90884. * @returns Promise that resolves after the given amount of time
  90885. */
  90886. static DelayAsync(delay: number): Promise<void>;
  90887. /**
  90888. * Gets the current gradient from an array of IValueGradient
  90889. * @param ratio defines the current ratio to get
  90890. * @param gradients defines the array of IValueGradient
  90891. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  90892. */
  90893. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  90894. }
  90895. /**
  90896. * This class is used to track a performance counter which is number based.
  90897. * The user has access to many properties which give statistics of different nature.
  90898. *
  90899. * The implementer can track two kinds of Performance Counter: time and count.
  90900. * 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.
  90901. * 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.
  90902. */
  90903. export class PerfCounter {
  90904. /**
  90905. * Gets or sets a global boolean to turn on and off all the counters
  90906. */
  90907. static Enabled: boolean;
  90908. /**
  90909. * Returns the smallest value ever
  90910. */
  90911. readonly min: number;
  90912. /**
  90913. * Returns the biggest value ever
  90914. */
  90915. readonly max: number;
  90916. /**
  90917. * Returns the average value since the performance counter is running
  90918. */
  90919. readonly average: number;
  90920. /**
  90921. * Returns the average value of the last second the counter was monitored
  90922. */
  90923. readonly lastSecAverage: number;
  90924. /**
  90925. * Returns the current value
  90926. */
  90927. readonly current: number;
  90928. /**
  90929. * Gets the accumulated total
  90930. */
  90931. readonly total: number;
  90932. /**
  90933. * Gets the total value count
  90934. */
  90935. readonly count: number;
  90936. /**
  90937. * Creates a new counter
  90938. */
  90939. constructor();
  90940. /**
  90941. * Call this method to start monitoring a new frame.
  90942. * 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.
  90943. */
  90944. fetchNewFrame(): void;
  90945. /**
  90946. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  90947. * @param newCount the count value to add to the monitored count
  90948. * @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.
  90949. */
  90950. addCount(newCount: number, fetchResult: boolean): void;
  90951. /**
  90952. * Start monitoring this performance counter
  90953. */
  90954. beginMonitoring(): void;
  90955. /**
  90956. * Compute the time lapsed since the previous beginMonitoring() call.
  90957. * @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
  90958. */
  90959. endMonitoring(newFrame?: boolean): void;
  90960. private _fetchResult;
  90961. private _startMonitoringTime;
  90962. private _min;
  90963. private _max;
  90964. private _average;
  90965. private _current;
  90966. private _totalValueCount;
  90967. private _totalAccumulated;
  90968. private _lastSecAverage;
  90969. private _lastSecAccumulated;
  90970. private _lastSecTime;
  90971. private _lastSecValueCount;
  90972. }
  90973. /**
  90974. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  90975. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  90976. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  90977. * @param name The name of the class, case should be preserved
  90978. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  90979. */
  90980. export function className(name: string, module?: string): (target: Object) => void;
  90981. /**
  90982. * An implementation of a loop for asynchronous functions.
  90983. */
  90984. export class AsyncLoop {
  90985. /**
  90986. * Defines the number of iterations for the loop
  90987. */
  90988. iterations: number;
  90989. /**
  90990. * Defines the current index of the loop.
  90991. */
  90992. index: number;
  90993. private _done;
  90994. private _fn;
  90995. private _successCallback;
  90996. /**
  90997. * Constructor.
  90998. * @param iterations the number of iterations.
  90999. * @param func the function to run each iteration
  91000. * @param successCallback the callback that will be called upon succesful execution
  91001. * @param offset starting offset.
  91002. */
  91003. constructor(
  91004. /**
  91005. * Defines the number of iterations for the loop
  91006. */
  91007. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  91008. /**
  91009. * Execute the next iteration. Must be called after the last iteration was finished.
  91010. */
  91011. executeNext(): void;
  91012. /**
  91013. * Break the loop and run the success callback.
  91014. */
  91015. breakLoop(): void;
  91016. /**
  91017. * Create and run an async loop.
  91018. * @param iterations the number of iterations.
  91019. * @param fn the function to run each iteration
  91020. * @param successCallback the callback that will be called upon succesful execution
  91021. * @param offset starting offset.
  91022. * @returns the created async loop object
  91023. */
  91024. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  91025. /**
  91026. * A for-loop that will run a given number of iterations synchronous and the rest async.
  91027. * @param iterations total number of iterations
  91028. * @param syncedIterations number of synchronous iterations in each async iteration.
  91029. * @param fn the function to call each iteration.
  91030. * @param callback a success call back that will be called when iterating stops.
  91031. * @param breakFunction a break condition (optional)
  91032. * @param timeout timeout settings for the setTimeout function. default - 0.
  91033. * @returns the created async loop object
  91034. */
  91035. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  91036. }
  91037. }
  91038. declare module BABYLON {
  91039. /** @hidden */
  91040. export interface ICollisionCoordinator {
  91041. createCollider(): Collider;
  91042. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91043. init(scene: Scene): void;
  91044. }
  91045. /** @hidden */
  91046. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  91047. private _scene;
  91048. private _scaledPosition;
  91049. private _scaledVelocity;
  91050. private _finalPosition;
  91051. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  91052. createCollider(): Collider;
  91053. init(scene: Scene): void;
  91054. private _collideWithWorld;
  91055. }
  91056. }
  91057. declare module BABYLON {
  91058. /**
  91059. * This class defines the direct association between an animation and a target
  91060. */
  91061. export class TargetedAnimation {
  91062. /**
  91063. * Animation to perform
  91064. */
  91065. animation: Animation;
  91066. /**
  91067. * Target to animate
  91068. */
  91069. target: any;
  91070. }
  91071. /**
  91072. * Use this class to create coordinated animations on multiple targets
  91073. */
  91074. export class AnimationGroup implements IDisposable {
  91075. /** The name of the animation group */
  91076. name: string;
  91077. private _scene;
  91078. private _targetedAnimations;
  91079. private _animatables;
  91080. private _from;
  91081. private _to;
  91082. private _isStarted;
  91083. private _isPaused;
  91084. private _speedRatio;
  91085. /**
  91086. * Gets or sets the unique id of the node
  91087. */
  91088. uniqueId: number;
  91089. /**
  91090. * This observable will notify when one animation have ended
  91091. */
  91092. onAnimationEndObservable: Observable<TargetedAnimation>;
  91093. /**
  91094. * Observer raised when one animation loops
  91095. */
  91096. onAnimationLoopObservable: Observable<TargetedAnimation>;
  91097. /**
  91098. * This observable will notify when all animations have ended.
  91099. */
  91100. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  91101. /**
  91102. * This observable will notify when all animations have paused.
  91103. */
  91104. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  91105. /**
  91106. * This observable will notify when all animations are playing.
  91107. */
  91108. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  91109. /**
  91110. * Gets the first frame
  91111. */
  91112. readonly from: number;
  91113. /**
  91114. * Gets the last frame
  91115. */
  91116. readonly to: number;
  91117. /**
  91118. * Define if the animations are started
  91119. */
  91120. readonly isStarted: boolean;
  91121. /**
  91122. * Gets a value indicating that the current group is playing
  91123. */
  91124. readonly isPlaying: boolean;
  91125. /**
  91126. * Gets or sets the speed ratio to use for all animations
  91127. */
  91128. /**
  91129. * Gets or sets the speed ratio to use for all animations
  91130. */
  91131. speedRatio: number;
  91132. /**
  91133. * Gets the targeted animations for this animation group
  91134. */
  91135. readonly targetedAnimations: Array<TargetedAnimation>;
  91136. /**
  91137. * returning the list of animatables controlled by this animation group.
  91138. */
  91139. readonly animatables: Array<Animatable>;
  91140. /**
  91141. * Instantiates a new Animation Group.
  91142. * This helps managing several animations at once.
  91143. * @see http://doc.babylonjs.com/how_to/group
  91144. * @param name Defines the name of the group
  91145. * @param scene Defines the scene the group belongs to
  91146. */
  91147. constructor(
  91148. /** The name of the animation group */
  91149. name: string, scene?: Nullable<Scene>);
  91150. /**
  91151. * Add an animation (with its target) in the group
  91152. * @param animation defines the animation we want to add
  91153. * @param target defines the target of the animation
  91154. * @returns the TargetedAnimation object
  91155. */
  91156. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  91157. /**
  91158. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  91159. * It can add constant keys at begin or end
  91160. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  91161. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  91162. * @returns the animation group
  91163. */
  91164. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  91165. /**
  91166. * Start all animations on given targets
  91167. * @param loop defines if animations must loop
  91168. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  91169. * @param from defines the from key (optional)
  91170. * @param to defines the to key (optional)
  91171. * @returns the current animation group
  91172. */
  91173. start(loop?: boolean, speedRatio?: number, from?: number, to?: number): AnimationGroup;
  91174. /**
  91175. * Pause all animations
  91176. * @returns the animation group
  91177. */
  91178. pause(): AnimationGroup;
  91179. /**
  91180. * Play all animations to initial state
  91181. * This function will start() the animations if they were not started or will restart() them if they were paused
  91182. * @param loop defines if animations must loop
  91183. * @returns the animation group
  91184. */
  91185. play(loop?: boolean): AnimationGroup;
  91186. /**
  91187. * Reset all animations to initial state
  91188. * @returns the animation group
  91189. */
  91190. reset(): AnimationGroup;
  91191. /**
  91192. * Restart animations from key 0
  91193. * @returns the animation group
  91194. */
  91195. restart(): AnimationGroup;
  91196. /**
  91197. * Stop all animations
  91198. * @returns the animation group
  91199. */
  91200. stop(): AnimationGroup;
  91201. /**
  91202. * Set animation weight for all animatables
  91203. * @param weight defines the weight to use
  91204. * @return the animationGroup
  91205. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91206. */
  91207. setWeightForAllAnimatables(weight: number): AnimationGroup;
  91208. /**
  91209. * Synchronize and normalize all animatables with a source animatable
  91210. * @param root defines the root animatable to synchronize with
  91211. * @return the animationGroup
  91212. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  91213. */
  91214. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  91215. /**
  91216. * Goes to a specific frame in this animation group
  91217. * @param frame the frame number to go to
  91218. * @return the animationGroup
  91219. */
  91220. goToFrame(frame: number): AnimationGroup;
  91221. /**
  91222. * Dispose all associated resources
  91223. */
  91224. dispose(): void;
  91225. private _checkAnimationGroupEnded;
  91226. /**
  91227. * Clone the current animation group and returns a copy
  91228. * @param newName defines the name of the new group
  91229. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  91230. * @returns the new aniamtion group
  91231. */
  91232. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  91233. /**
  91234. * Returns a new AnimationGroup object parsed from the source provided.
  91235. * @param parsedAnimationGroup defines the source
  91236. * @param scene defines the scene that will receive the animationGroup
  91237. * @returns a new AnimationGroup
  91238. */
  91239. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  91240. /**
  91241. * Returns the string "AnimationGroup"
  91242. * @returns "AnimationGroup"
  91243. */
  91244. getClassName(): string;
  91245. /**
  91246. * Creates a detailled string about the object
  91247. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  91248. * @returns a string representing the object
  91249. */
  91250. toString(fullDetails?: boolean): string;
  91251. }
  91252. }
  91253. declare module BABYLON {
  91254. /**
  91255. * Define an interface for all classes that will hold resources
  91256. */
  91257. export interface IDisposable {
  91258. /**
  91259. * Releases all held resources
  91260. */
  91261. dispose(): void;
  91262. }
  91263. /** Interface defining initialization parameters for Scene class */
  91264. export interface SceneOptions {
  91265. /**
  91266. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  91267. * It will improve performance when the number of geometries becomes important.
  91268. */
  91269. useGeometryUniqueIdsMap?: boolean;
  91270. /**
  91271. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  91272. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91273. */
  91274. useMaterialMeshMap?: boolean;
  91275. /**
  91276. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  91277. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  91278. */
  91279. useClonedMeshhMap?: boolean;
  91280. }
  91281. /**
  91282. * Represents a scene to be rendered by the engine.
  91283. * @see http://doc.babylonjs.com/features/scene
  91284. */
  91285. export class Scene extends AbstractScene implements IAnimatable {
  91286. private static _uniqueIdCounter;
  91287. /** The fog is deactivated */
  91288. static readonly FOGMODE_NONE: number;
  91289. /** The fog density is following an exponential function */
  91290. static readonly FOGMODE_EXP: number;
  91291. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  91292. static readonly FOGMODE_EXP2: number;
  91293. /** The fog density is following a linear function. */
  91294. static readonly FOGMODE_LINEAR: number;
  91295. /**
  91296. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  91297. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91298. */
  91299. static MinDeltaTime: number;
  91300. /**
  91301. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  91302. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91303. */
  91304. static MaxDeltaTime: number;
  91305. /**
  91306. * Factory used to create the default material.
  91307. * @param name The name of the material to create
  91308. * @param scene The scene to create the material for
  91309. * @returns The default material
  91310. */
  91311. static DefaultMaterialFactory(scene: Scene): Material;
  91312. /**
  91313. * Factory used to create the a collision coordinator.
  91314. * @returns The collision coordinator
  91315. */
  91316. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  91317. /** @hidden */
  91318. readonly _isScene: boolean;
  91319. /**
  91320. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  91321. */
  91322. autoClear: boolean;
  91323. /**
  91324. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  91325. */
  91326. autoClearDepthAndStencil: boolean;
  91327. /**
  91328. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  91329. */
  91330. clearColor: Color4;
  91331. /**
  91332. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  91333. */
  91334. ambientColor: Color3;
  91335. /**
  91336. * This is use to store the default BRDF lookup for PBR materials in your scene.
  91337. * It should only be one of the following (if not the default embedded one):
  91338. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  91339. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  91340. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  91341. * The material properties need to be setup according to the type of texture in use.
  91342. */
  91343. environmentBRDFTexture: BaseTexture;
  91344. /** @hidden */
  91345. protected _environmentTexture: Nullable<BaseTexture>;
  91346. /**
  91347. * Texture used in all pbr material as the reflection texture.
  91348. * As in the majority of the scene they are the same (exception for multi room and so on),
  91349. * this is easier to reference from here than from all the materials.
  91350. */
  91351. /**
  91352. * Texture used in all pbr material as the reflection texture.
  91353. * As in the majority of the scene they are the same (exception for multi room and so on),
  91354. * this is easier to set here than in all the materials.
  91355. */
  91356. environmentTexture: Nullable<BaseTexture>;
  91357. /** @hidden */
  91358. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  91359. /**
  91360. * Default image processing configuration used either in the rendering
  91361. * Forward main pass or through the imageProcessingPostProcess if present.
  91362. * As in the majority of the scene they are the same (exception for multi camera),
  91363. * this is easier to reference from here than from all the materials and post process.
  91364. *
  91365. * No setter as we it is a shared configuration, you can set the values instead.
  91366. */
  91367. readonly imageProcessingConfiguration: ImageProcessingConfiguration;
  91368. private _forceWireframe;
  91369. /**
  91370. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  91371. */
  91372. forceWireframe: boolean;
  91373. private _forcePointsCloud;
  91374. /**
  91375. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  91376. */
  91377. forcePointsCloud: boolean;
  91378. /**
  91379. * Gets or sets the active clipplane 1
  91380. */
  91381. clipPlane: Nullable<Plane>;
  91382. /**
  91383. * Gets or sets the active clipplane 2
  91384. */
  91385. clipPlane2: Nullable<Plane>;
  91386. /**
  91387. * Gets or sets the active clipplane 3
  91388. */
  91389. clipPlane3: Nullable<Plane>;
  91390. /**
  91391. * Gets or sets the active clipplane 4
  91392. */
  91393. clipPlane4: Nullable<Plane>;
  91394. /**
  91395. * Gets or sets a boolean indicating if animations are enabled
  91396. */
  91397. animationsEnabled: boolean;
  91398. private _animationPropertiesOverride;
  91399. /**
  91400. * Gets or sets the animation properties override
  91401. */
  91402. animationPropertiesOverride: Nullable<AnimationPropertiesOverride>;
  91403. /**
  91404. * Gets or sets a boolean indicating if a constant deltatime has to be used
  91405. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  91406. */
  91407. useConstantAnimationDeltaTime: boolean;
  91408. /**
  91409. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  91410. * Please note that it requires to run a ray cast through the scene on every frame
  91411. */
  91412. constantlyUpdateMeshUnderPointer: boolean;
  91413. /**
  91414. * Defines the HTML cursor to use when hovering over interactive elements
  91415. */
  91416. hoverCursor: string;
  91417. /**
  91418. * Defines the HTML default cursor to use (empty by default)
  91419. */
  91420. defaultCursor: string;
  91421. /**
  91422. * This is used to call preventDefault() on pointer down
  91423. * in order to block unwanted artifacts like system double clicks
  91424. */
  91425. preventDefaultOnPointerDown: boolean;
  91426. /**
  91427. * This is used to call preventDefault() on pointer up
  91428. * in order to block unwanted artifacts like system double clicks
  91429. */
  91430. preventDefaultOnPointerUp: boolean;
  91431. /**
  91432. * Gets or sets user defined metadata
  91433. */
  91434. metadata: any;
  91435. /**
  91436. * For internal use only. Please do not use.
  91437. */
  91438. reservedDataStore: any;
  91439. /**
  91440. * Gets the name of the plugin used to load this scene (null by default)
  91441. */
  91442. loadingPluginName: string;
  91443. /**
  91444. * Use this array to add regular expressions used to disable offline support for specific urls
  91445. */
  91446. disableOfflineSupportExceptionRules: RegExp[];
  91447. /**
  91448. * An event triggered when the scene is disposed.
  91449. */
  91450. onDisposeObservable: Observable<Scene>;
  91451. private _onDisposeObserver;
  91452. /** Sets a function to be executed when this scene is disposed. */
  91453. onDispose: () => void;
  91454. /**
  91455. * An event triggered before rendering the scene (right after animations and physics)
  91456. */
  91457. onBeforeRenderObservable: Observable<Scene>;
  91458. private _onBeforeRenderObserver;
  91459. /** Sets a function to be executed before rendering this scene */
  91460. beforeRender: Nullable<() => void>;
  91461. /**
  91462. * An event triggered after rendering the scene
  91463. */
  91464. onAfterRenderObservable: Observable<Scene>;
  91465. private _onAfterRenderObserver;
  91466. /** Sets a function to be executed after rendering this scene */
  91467. afterRender: Nullable<() => void>;
  91468. /**
  91469. * An event triggered before animating the scene
  91470. */
  91471. onBeforeAnimationsObservable: Observable<Scene>;
  91472. /**
  91473. * An event triggered after animations processing
  91474. */
  91475. onAfterAnimationsObservable: Observable<Scene>;
  91476. /**
  91477. * An event triggered before draw calls are ready to be sent
  91478. */
  91479. onBeforeDrawPhaseObservable: Observable<Scene>;
  91480. /**
  91481. * An event triggered after draw calls have been sent
  91482. */
  91483. onAfterDrawPhaseObservable: Observable<Scene>;
  91484. /**
  91485. * An event triggered when the scene is ready
  91486. */
  91487. onReadyObservable: Observable<Scene>;
  91488. /**
  91489. * An event triggered before rendering a camera
  91490. */
  91491. onBeforeCameraRenderObservable: Observable<Camera>;
  91492. private _onBeforeCameraRenderObserver;
  91493. /** Sets a function to be executed before rendering a camera*/
  91494. beforeCameraRender: () => void;
  91495. /**
  91496. * An event triggered after rendering a camera
  91497. */
  91498. onAfterCameraRenderObservable: Observable<Camera>;
  91499. private _onAfterCameraRenderObserver;
  91500. /** Sets a function to be executed after rendering a camera*/
  91501. afterCameraRender: () => void;
  91502. /**
  91503. * An event triggered when active meshes evaluation is about to start
  91504. */
  91505. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  91506. /**
  91507. * An event triggered when active meshes evaluation is done
  91508. */
  91509. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  91510. /**
  91511. * An event triggered when particles rendering is about to start
  91512. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91513. */
  91514. onBeforeParticlesRenderingObservable: Observable<Scene>;
  91515. /**
  91516. * An event triggered when particles rendering is done
  91517. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  91518. */
  91519. onAfterParticlesRenderingObservable: Observable<Scene>;
  91520. /**
  91521. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  91522. */
  91523. onDataLoadedObservable: Observable<Scene>;
  91524. /**
  91525. * An event triggered when a camera is created
  91526. */
  91527. onNewCameraAddedObservable: Observable<Camera>;
  91528. /**
  91529. * An event triggered when a camera is removed
  91530. */
  91531. onCameraRemovedObservable: Observable<Camera>;
  91532. /**
  91533. * An event triggered when a light is created
  91534. */
  91535. onNewLightAddedObservable: Observable<Light>;
  91536. /**
  91537. * An event triggered when a light is removed
  91538. */
  91539. onLightRemovedObservable: Observable<Light>;
  91540. /**
  91541. * An event triggered when a geometry is created
  91542. */
  91543. onNewGeometryAddedObservable: Observable<Geometry>;
  91544. /**
  91545. * An event triggered when a geometry is removed
  91546. */
  91547. onGeometryRemovedObservable: Observable<Geometry>;
  91548. /**
  91549. * An event triggered when a transform node is created
  91550. */
  91551. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  91552. /**
  91553. * An event triggered when a transform node is removed
  91554. */
  91555. onTransformNodeRemovedObservable: Observable<TransformNode>;
  91556. /**
  91557. * An event triggered when a mesh is created
  91558. */
  91559. onNewMeshAddedObservable: Observable<AbstractMesh>;
  91560. /**
  91561. * An event triggered when a mesh is removed
  91562. */
  91563. onMeshRemovedObservable: Observable<AbstractMesh>;
  91564. /**
  91565. * An event triggered when a skeleton is created
  91566. */
  91567. onNewSkeletonAddedObservable: Observable<Skeleton>;
  91568. /**
  91569. * An event triggered when a skeleton is removed
  91570. */
  91571. onSkeletonRemovedObservable: Observable<Skeleton>;
  91572. /**
  91573. * An event triggered when a material is created
  91574. */
  91575. onNewMaterialAddedObservable: Observable<Material>;
  91576. /**
  91577. * An event triggered when a material is removed
  91578. */
  91579. onMaterialRemovedObservable: Observable<Material>;
  91580. /**
  91581. * An event triggered when a texture is created
  91582. */
  91583. onNewTextureAddedObservable: Observable<BaseTexture>;
  91584. /**
  91585. * An event triggered when a texture is removed
  91586. */
  91587. onTextureRemovedObservable: Observable<BaseTexture>;
  91588. /**
  91589. * An event triggered when render targets are about to be rendered
  91590. * Can happen multiple times per frame.
  91591. */
  91592. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  91593. /**
  91594. * An event triggered when render targets were rendered.
  91595. * Can happen multiple times per frame.
  91596. */
  91597. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  91598. /**
  91599. * An event triggered before calculating deterministic simulation step
  91600. */
  91601. onBeforeStepObservable: Observable<Scene>;
  91602. /**
  91603. * An event triggered after calculating deterministic simulation step
  91604. */
  91605. onAfterStepObservable: Observable<Scene>;
  91606. /**
  91607. * An event triggered when the activeCamera property is updated
  91608. */
  91609. onActiveCameraChanged: Observable<Scene>;
  91610. /**
  91611. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  91612. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91613. * 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)
  91614. */
  91615. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91616. /**
  91617. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  91618. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  91619. * 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)
  91620. */
  91621. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  91622. /**
  91623. * This Observable will when a mesh has been imported into the scene.
  91624. */
  91625. onMeshImportedObservable: Observable<AbstractMesh>;
  91626. /**
  91627. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  91628. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  91629. */
  91630. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  91631. /** @hidden */
  91632. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  91633. /**
  91634. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  91635. */
  91636. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  91637. /**
  91638. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  91639. */
  91640. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  91641. /**
  91642. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  91643. */
  91644. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  91645. private _onPointerMove;
  91646. private _onPointerDown;
  91647. private _onPointerUp;
  91648. /** Callback called when a pointer move is detected */
  91649. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91650. /** Callback called when a pointer down is detected */
  91651. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  91652. /** Callback called when a pointer up is detected */
  91653. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  91654. /** Callback called when a pointer pick is detected */
  91655. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  91656. /**
  91657. * 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).
  91658. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  91659. */
  91660. onPrePointerObservable: Observable<PointerInfoPre>;
  91661. /**
  91662. * Observable event triggered each time an input event is received from the rendering canvas
  91663. */
  91664. onPointerObservable: Observable<PointerInfo>;
  91665. /**
  91666. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  91667. */
  91668. readonly unTranslatedPointer: Vector2;
  91669. /** The distance in pixel that you have to move to prevent some events */
  91670. static DragMovementThreshold: number;
  91671. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  91672. static LongPressDelay: number;
  91673. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  91674. static DoubleClickDelay: number;
  91675. /** If you need to check double click without raising a single click at first click, enable this flag */
  91676. static ExclusiveDoubleClickMode: boolean;
  91677. private _initClickEvent;
  91678. private _initActionManager;
  91679. private _delayedSimpleClick;
  91680. private _delayedSimpleClickTimeout;
  91681. private _previousDelayedSimpleClickTimeout;
  91682. private _meshPickProceed;
  91683. private _previousButtonPressed;
  91684. private _currentPickResult;
  91685. private _previousPickResult;
  91686. private _totalPointersPressed;
  91687. private _doubleClickOccured;
  91688. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  91689. cameraToUseForPointers: Nullable<Camera>;
  91690. private _pointerX;
  91691. private _pointerY;
  91692. private _unTranslatedPointerX;
  91693. private _unTranslatedPointerY;
  91694. private _startingPointerPosition;
  91695. private _previousStartingPointerPosition;
  91696. private _startingPointerTime;
  91697. private _previousStartingPointerTime;
  91698. private _pointerCaptures;
  91699. private _timeAccumulator;
  91700. private _currentStepId;
  91701. private _currentInternalStep;
  91702. /** @hidden */
  91703. _mirroredCameraPosition: Nullable<Vector3>;
  91704. /**
  91705. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  91706. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  91707. */
  91708. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  91709. /**
  91710. * Observable event triggered each time an keyboard event is received from the hosting window
  91711. */
  91712. onKeyboardObservable: Observable<KeyboardInfo>;
  91713. private _onKeyDown;
  91714. private _onKeyUp;
  91715. private _onCanvasFocusObserver;
  91716. private _onCanvasBlurObserver;
  91717. private _useRightHandedSystem;
  91718. /**
  91719. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  91720. */
  91721. useRightHandedSystem: boolean;
  91722. /**
  91723. * Sets the step Id used by deterministic lock step
  91724. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91725. * @param newStepId defines the step Id
  91726. */
  91727. setStepId(newStepId: number): void;
  91728. /**
  91729. * Gets the step Id used by deterministic lock step
  91730. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91731. * @returns the step Id
  91732. */
  91733. getStepId(): number;
  91734. /**
  91735. * Gets the internal step used by deterministic lock step
  91736. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  91737. * @returns the internal step
  91738. */
  91739. getInternalStep(): number;
  91740. private _fogEnabled;
  91741. /**
  91742. * Gets or sets a boolean indicating if fog is enabled on this scene
  91743. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91744. * (Default is true)
  91745. */
  91746. fogEnabled: boolean;
  91747. private _fogMode;
  91748. /**
  91749. * Gets or sets the fog mode to use
  91750. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91751. * | mode | value |
  91752. * | --- | --- |
  91753. * | FOGMODE_NONE | 0 |
  91754. * | FOGMODE_EXP | 1 |
  91755. * | FOGMODE_EXP2 | 2 |
  91756. * | FOGMODE_LINEAR | 3 |
  91757. */
  91758. fogMode: number;
  91759. /**
  91760. * Gets or sets the fog color to use
  91761. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91762. * (Default is Color3(0.2, 0.2, 0.3))
  91763. */
  91764. fogColor: Color3;
  91765. /**
  91766. * Gets or sets the fog density to use
  91767. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91768. * (Default is 0.1)
  91769. */
  91770. fogDensity: number;
  91771. /**
  91772. * Gets or sets the fog start distance to use
  91773. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91774. * (Default is 0)
  91775. */
  91776. fogStart: number;
  91777. /**
  91778. * Gets or sets the fog end distance to use
  91779. * @see http://doc.babylonjs.com/babylon101/environment#fog
  91780. * (Default is 1000)
  91781. */
  91782. fogEnd: number;
  91783. private _shadowsEnabled;
  91784. /**
  91785. * Gets or sets a boolean indicating if shadows are enabled on this scene
  91786. */
  91787. shadowsEnabled: boolean;
  91788. private _lightsEnabled;
  91789. /**
  91790. * Gets or sets a boolean indicating if lights are enabled on this scene
  91791. */
  91792. lightsEnabled: boolean;
  91793. /** All of the active cameras added to this scene. */
  91794. activeCameras: Camera[];
  91795. /** @hidden */
  91796. _activeCamera: Nullable<Camera>;
  91797. /** Gets or sets the current active camera */
  91798. activeCamera: Nullable<Camera>;
  91799. private _defaultMaterial;
  91800. /** The default material used on meshes when no material is affected */
  91801. /** The default material used on meshes when no material is affected */
  91802. defaultMaterial: Material;
  91803. private _texturesEnabled;
  91804. /**
  91805. * Gets or sets a boolean indicating if textures are enabled on this scene
  91806. */
  91807. texturesEnabled: boolean;
  91808. /**
  91809. * Gets or sets a boolean indicating if particles are enabled on this scene
  91810. */
  91811. particlesEnabled: boolean;
  91812. /**
  91813. * Gets or sets a boolean indicating if sprites are enabled on this scene
  91814. */
  91815. spritesEnabled: boolean;
  91816. private _skeletonsEnabled;
  91817. /**
  91818. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  91819. */
  91820. skeletonsEnabled: boolean;
  91821. /**
  91822. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  91823. */
  91824. lensFlaresEnabled: boolean;
  91825. /**
  91826. * Gets or sets a boolean indicating if collisions are enabled on this scene
  91827. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91828. */
  91829. collisionsEnabled: boolean;
  91830. private _collisionCoordinator;
  91831. /** @hidden */
  91832. readonly collisionCoordinator: ICollisionCoordinator;
  91833. /**
  91834. * Defines the gravity applied to this scene (used only for collisions)
  91835. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  91836. */
  91837. gravity: Vector3;
  91838. /**
  91839. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  91840. */
  91841. postProcessesEnabled: boolean;
  91842. /**
  91843. * The list of postprocesses added to the scene
  91844. */
  91845. postProcesses: PostProcess[];
  91846. /**
  91847. * Gets the current postprocess manager
  91848. */
  91849. postProcessManager: PostProcessManager;
  91850. /**
  91851. * Gets or sets a boolean indicating if render targets are enabled on this scene
  91852. */
  91853. renderTargetsEnabled: boolean;
  91854. /**
  91855. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  91856. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  91857. */
  91858. dumpNextRenderTargets: boolean;
  91859. /**
  91860. * The list of user defined render targets added to the scene
  91861. */
  91862. customRenderTargets: RenderTargetTexture[];
  91863. /**
  91864. * Defines if texture loading must be delayed
  91865. * If true, textures will only be loaded when they need to be rendered
  91866. */
  91867. useDelayedTextureLoading: boolean;
  91868. /**
  91869. * Gets the list of meshes imported to the scene through SceneLoader
  91870. */
  91871. importedMeshesFiles: String[];
  91872. /**
  91873. * Gets or sets a boolean indicating if probes are enabled on this scene
  91874. */
  91875. probesEnabled: boolean;
  91876. /**
  91877. * Gets or sets the current offline provider to use to store scene data
  91878. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  91879. */
  91880. offlineProvider: IOfflineProvider;
  91881. /**
  91882. * Gets or sets the action manager associated with the scene
  91883. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  91884. */
  91885. actionManager: AbstractActionManager;
  91886. private _meshesForIntersections;
  91887. /**
  91888. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  91889. */
  91890. proceduralTexturesEnabled: boolean;
  91891. private _engine;
  91892. private _totalVertices;
  91893. /** @hidden */
  91894. _activeIndices: PerfCounter;
  91895. /** @hidden */
  91896. _activeParticles: PerfCounter;
  91897. /** @hidden */
  91898. _activeBones: PerfCounter;
  91899. private _animationRatio;
  91900. /** @hidden */
  91901. _animationTimeLast: number;
  91902. /** @hidden */
  91903. _animationTime: number;
  91904. /**
  91905. * Gets or sets a general scale for animation speed
  91906. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  91907. */
  91908. animationTimeScale: number;
  91909. /** @hidden */
  91910. _cachedMaterial: Nullable<Material>;
  91911. /** @hidden */
  91912. _cachedEffect: Nullable<Effect>;
  91913. /** @hidden */
  91914. _cachedVisibility: Nullable<number>;
  91915. private _renderId;
  91916. private _frameId;
  91917. private _executeWhenReadyTimeoutId;
  91918. private _intermediateRendering;
  91919. private _viewUpdateFlag;
  91920. private _projectionUpdateFlag;
  91921. /** @hidden */
  91922. _toBeDisposed: Nullable<IDisposable>[];
  91923. private _activeRequests;
  91924. /** @hidden */
  91925. _pendingData: any[];
  91926. private _isDisposed;
  91927. /**
  91928. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  91929. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  91930. */
  91931. dispatchAllSubMeshesOfActiveMeshes: boolean;
  91932. private _activeMeshes;
  91933. private _processedMaterials;
  91934. private _renderTargets;
  91935. /** @hidden */
  91936. _activeParticleSystems: SmartArray<IParticleSystem>;
  91937. private _activeSkeletons;
  91938. private _softwareSkinnedMeshes;
  91939. private _renderingManager;
  91940. /** @hidden */
  91941. _activeAnimatables: Animatable[];
  91942. private _transformMatrix;
  91943. private _sceneUbo;
  91944. /** @hidden */
  91945. _viewMatrix: Matrix;
  91946. private _projectionMatrix;
  91947. private _wheelEventName;
  91948. /** @hidden */
  91949. _forcedViewPosition: Nullable<Vector3>;
  91950. /** @hidden */
  91951. _frustumPlanes: Plane[];
  91952. /**
  91953. * Gets the list of frustum planes (built from the active camera)
  91954. */
  91955. readonly frustumPlanes: Plane[];
  91956. /**
  91957. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  91958. * This is useful if there are more lights that the maximum simulteanous authorized
  91959. */
  91960. requireLightSorting: boolean;
  91961. /** @hidden */
  91962. readonly useMaterialMeshMap: boolean;
  91963. /** @hidden */
  91964. readonly useClonedMeshhMap: boolean;
  91965. private _pointerOverMesh;
  91966. private _pickedDownMesh;
  91967. private _pickedUpMesh;
  91968. private _externalData;
  91969. private _uid;
  91970. /**
  91971. * @hidden
  91972. * Backing store of defined scene components.
  91973. */
  91974. _components: ISceneComponent[];
  91975. /**
  91976. * @hidden
  91977. * Backing store of defined scene components.
  91978. */
  91979. _serializableComponents: ISceneSerializableComponent[];
  91980. /**
  91981. * List of components to register on the next registration step.
  91982. */
  91983. private _transientComponents;
  91984. /**
  91985. * Registers the transient components if needed.
  91986. */
  91987. private _registerTransientComponents;
  91988. /**
  91989. * @hidden
  91990. * Add a component to the scene.
  91991. * Note that the ccomponent could be registered on th next frame if this is called after
  91992. * the register component stage.
  91993. * @param component Defines the component to add to the scene
  91994. */
  91995. _addComponent(component: ISceneComponent): void;
  91996. /**
  91997. * @hidden
  91998. * Gets a component from the scene.
  91999. * @param name defines the name of the component to retrieve
  92000. * @returns the component or null if not present
  92001. */
  92002. _getComponent(name: string): Nullable<ISceneComponent>;
  92003. /**
  92004. * @hidden
  92005. * Defines the actions happening before camera updates.
  92006. */
  92007. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  92008. /**
  92009. * @hidden
  92010. * Defines the actions happening before clear the canvas.
  92011. */
  92012. _beforeClearStage: Stage<SimpleStageAction>;
  92013. /**
  92014. * @hidden
  92015. * Defines the actions when collecting render targets for the frame.
  92016. */
  92017. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92018. /**
  92019. * @hidden
  92020. * Defines the actions happening for one camera in the frame.
  92021. */
  92022. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  92023. /**
  92024. * @hidden
  92025. * Defines the actions happening during the per mesh ready checks.
  92026. */
  92027. _isReadyForMeshStage: Stage<MeshStageAction>;
  92028. /**
  92029. * @hidden
  92030. * Defines the actions happening before evaluate active mesh checks.
  92031. */
  92032. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  92033. /**
  92034. * @hidden
  92035. * Defines the actions happening during the evaluate sub mesh checks.
  92036. */
  92037. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  92038. /**
  92039. * @hidden
  92040. * Defines the actions happening during the active mesh stage.
  92041. */
  92042. _activeMeshStage: Stage<ActiveMeshStageAction>;
  92043. /**
  92044. * @hidden
  92045. * Defines the actions happening during the per camera render target step.
  92046. */
  92047. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  92048. /**
  92049. * @hidden
  92050. * Defines the actions happening just before the active camera is drawing.
  92051. */
  92052. _beforeCameraDrawStage: Stage<CameraStageAction>;
  92053. /**
  92054. * @hidden
  92055. * Defines the actions happening just before a render target is drawing.
  92056. */
  92057. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92058. /**
  92059. * @hidden
  92060. * Defines the actions happening just before a rendering group is drawing.
  92061. */
  92062. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92063. /**
  92064. * @hidden
  92065. * Defines the actions happening just before a mesh is drawing.
  92066. */
  92067. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92068. /**
  92069. * @hidden
  92070. * Defines the actions happening just after a mesh has been drawn.
  92071. */
  92072. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  92073. /**
  92074. * @hidden
  92075. * Defines the actions happening just after a rendering group has been drawn.
  92076. */
  92077. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  92078. /**
  92079. * @hidden
  92080. * Defines the actions happening just after the active camera has been drawn.
  92081. */
  92082. _afterCameraDrawStage: Stage<CameraStageAction>;
  92083. /**
  92084. * @hidden
  92085. * Defines the actions happening just after a render target has been drawn.
  92086. */
  92087. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  92088. /**
  92089. * @hidden
  92090. * Defines the actions happening just after rendering all cameras and computing intersections.
  92091. */
  92092. _afterRenderStage: Stage<SimpleStageAction>;
  92093. /**
  92094. * @hidden
  92095. * Defines the actions happening when a pointer move event happens.
  92096. */
  92097. _pointerMoveStage: Stage<PointerMoveStageAction>;
  92098. /**
  92099. * @hidden
  92100. * Defines the actions happening when a pointer down event happens.
  92101. */
  92102. _pointerDownStage: Stage<PointerUpDownStageAction>;
  92103. /**
  92104. * @hidden
  92105. * Defines the actions happening when a pointer up event happens.
  92106. */
  92107. _pointerUpStage: Stage<PointerUpDownStageAction>;
  92108. /**
  92109. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  92110. */
  92111. private geometriesByUniqueId;
  92112. /**
  92113. * Creates a new Scene
  92114. * @param engine defines the engine to use to render this scene
  92115. * @param options defines the scene options
  92116. */
  92117. constructor(engine: Engine, options?: SceneOptions);
  92118. /**
  92119. * Gets a string idenfifying the name of the class
  92120. * @returns "Scene" string
  92121. */
  92122. getClassName(): string;
  92123. private _defaultMeshCandidates;
  92124. /**
  92125. * @hidden
  92126. */
  92127. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  92128. private _defaultSubMeshCandidates;
  92129. /**
  92130. * @hidden
  92131. */
  92132. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  92133. /**
  92134. * Sets the default candidate providers for the scene.
  92135. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  92136. * and getCollidingSubMeshCandidates to their default function
  92137. */
  92138. setDefaultCandidateProviders(): void;
  92139. /**
  92140. * Gets the mesh that is currently under the pointer
  92141. */
  92142. readonly meshUnderPointer: Nullable<AbstractMesh>;
  92143. /**
  92144. * Gets or sets the current on-screen X position of the pointer
  92145. */
  92146. pointerX: number;
  92147. /**
  92148. * Gets or sets the current on-screen Y position of the pointer
  92149. */
  92150. pointerY: number;
  92151. /**
  92152. * Gets the cached material (ie. the latest rendered one)
  92153. * @returns the cached material
  92154. */
  92155. getCachedMaterial(): Nullable<Material>;
  92156. /**
  92157. * Gets the cached effect (ie. the latest rendered one)
  92158. * @returns the cached effect
  92159. */
  92160. getCachedEffect(): Nullable<Effect>;
  92161. /**
  92162. * Gets the cached visibility state (ie. the latest rendered one)
  92163. * @returns the cached visibility state
  92164. */
  92165. getCachedVisibility(): Nullable<number>;
  92166. /**
  92167. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  92168. * @param material defines the current material
  92169. * @param effect defines the current effect
  92170. * @param visibility defines the current visibility state
  92171. * @returns true if one parameter is not cached
  92172. */
  92173. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  92174. /**
  92175. * Gets the engine associated with the scene
  92176. * @returns an Engine
  92177. */
  92178. getEngine(): Engine;
  92179. /**
  92180. * Gets the total number of vertices rendered per frame
  92181. * @returns the total number of vertices rendered per frame
  92182. */
  92183. getTotalVertices(): number;
  92184. /**
  92185. * Gets the performance counter for total vertices
  92186. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92187. */
  92188. readonly totalVerticesPerfCounter: PerfCounter;
  92189. /**
  92190. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  92191. * @returns the total number of active indices rendered per frame
  92192. */
  92193. getActiveIndices(): number;
  92194. /**
  92195. * Gets the performance counter for active indices
  92196. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92197. */
  92198. readonly totalActiveIndicesPerfCounter: PerfCounter;
  92199. /**
  92200. * Gets the total number of active particles rendered per frame
  92201. * @returns the total number of active particles rendered per frame
  92202. */
  92203. getActiveParticles(): number;
  92204. /**
  92205. * Gets the performance counter for active particles
  92206. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92207. */
  92208. readonly activeParticlesPerfCounter: PerfCounter;
  92209. /**
  92210. * Gets the total number of active bones rendered per frame
  92211. * @returns the total number of active bones rendered per frame
  92212. */
  92213. getActiveBones(): number;
  92214. /**
  92215. * Gets the performance counter for active bones
  92216. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  92217. */
  92218. readonly activeBonesPerfCounter: PerfCounter;
  92219. /**
  92220. * Gets the array of active meshes
  92221. * @returns an array of AbstractMesh
  92222. */
  92223. getActiveMeshes(): SmartArray<AbstractMesh>;
  92224. /**
  92225. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  92226. * @returns a number
  92227. */
  92228. getAnimationRatio(): number;
  92229. /**
  92230. * Gets an unique Id for the current render phase
  92231. * @returns a number
  92232. */
  92233. getRenderId(): number;
  92234. /**
  92235. * Gets an unique Id for the current frame
  92236. * @returns a number
  92237. */
  92238. getFrameId(): number;
  92239. /** Call this function if you want to manually increment the render Id*/
  92240. incrementRenderId(): void;
  92241. private _updatePointerPosition;
  92242. private _createUbo;
  92243. private _setRayOnPointerInfo;
  92244. /**
  92245. * Use this method to simulate a pointer move on a mesh
  92246. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92247. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92248. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92249. * @returns the current scene
  92250. */
  92251. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92252. private _processPointerMove;
  92253. private _checkPrePointerObservable;
  92254. /**
  92255. * Use this method to simulate a pointer down on a mesh
  92256. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92257. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92258. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92259. * @returns the current scene
  92260. */
  92261. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  92262. private _processPointerDown;
  92263. /**
  92264. * Use this method to simulate a pointer up on a mesh
  92265. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  92266. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  92267. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  92268. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  92269. * @returns the current scene
  92270. */
  92271. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  92272. private _processPointerUp;
  92273. /**
  92274. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  92275. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  92276. * @returns true if the pointer was captured
  92277. */
  92278. isPointerCaptured(pointerId?: number): boolean;
  92279. /** @hidden */
  92280. _isPointerSwiping(): boolean;
  92281. /**
  92282. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  92283. * @param attachUp defines if you want to attach events to pointerup
  92284. * @param attachDown defines if you want to attach events to pointerdown
  92285. * @param attachMove defines if you want to attach events to pointermove
  92286. */
  92287. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  92288. /** Detaches all event handlers*/
  92289. detachControl(): void;
  92290. /**
  92291. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  92292. * Delay loaded resources are not taking in account
  92293. * @return true if all required resources are ready
  92294. */
  92295. isReady(): boolean;
  92296. /** Resets all cached information relative to material (including effect and visibility) */
  92297. resetCachedMaterial(): void;
  92298. /**
  92299. * Registers a function to be called before every frame render
  92300. * @param func defines the function to register
  92301. */
  92302. registerBeforeRender(func: () => void): void;
  92303. /**
  92304. * Unregisters a function called before every frame render
  92305. * @param func defines the function to unregister
  92306. */
  92307. unregisterBeforeRender(func: () => void): void;
  92308. /**
  92309. * Registers a function to be called after every frame render
  92310. * @param func defines the function to register
  92311. */
  92312. registerAfterRender(func: () => void): void;
  92313. /**
  92314. * Unregisters a function called after every frame render
  92315. * @param func defines the function to unregister
  92316. */
  92317. unregisterAfterRender(func: () => void): void;
  92318. private _executeOnceBeforeRender;
  92319. /**
  92320. * The provided function will run before render once and will be disposed afterwards.
  92321. * A timeout delay can be provided so that the function will be executed in N ms.
  92322. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  92323. * @param func The function to be executed.
  92324. * @param timeout optional delay in ms
  92325. */
  92326. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  92327. /** @hidden */
  92328. _addPendingData(data: any): void;
  92329. /** @hidden */
  92330. _removePendingData(data: any): void;
  92331. /**
  92332. * Returns the number of items waiting to be loaded
  92333. * @returns the number of items waiting to be loaded
  92334. */
  92335. getWaitingItemsCount(): number;
  92336. /**
  92337. * Returns a boolean indicating if the scene is still loading data
  92338. */
  92339. readonly isLoading: boolean;
  92340. /**
  92341. * Registers a function to be executed when the scene is ready
  92342. * @param {Function} func - the function to be executed
  92343. */
  92344. executeWhenReady(func: () => void): void;
  92345. /**
  92346. * Returns a promise that resolves when the scene is ready
  92347. * @returns A promise that resolves when the scene is ready
  92348. */
  92349. whenReadyAsync(): Promise<void>;
  92350. /** @hidden */
  92351. _checkIsReady(): void;
  92352. /**
  92353. * Gets all animatable attached to the scene
  92354. */
  92355. readonly animatables: Animatable[];
  92356. /**
  92357. * Resets the last animation time frame.
  92358. * Useful to override when animations start running when loading a scene for the first time.
  92359. */
  92360. resetLastAnimationTimeFrame(): void;
  92361. /**
  92362. * Gets the current view matrix
  92363. * @returns a Matrix
  92364. */
  92365. getViewMatrix(): Matrix;
  92366. /**
  92367. * Gets the current projection matrix
  92368. * @returns a Matrix
  92369. */
  92370. getProjectionMatrix(): Matrix;
  92371. /**
  92372. * Gets the current transform matrix
  92373. * @returns a Matrix made of View * Projection
  92374. */
  92375. getTransformMatrix(): Matrix;
  92376. /**
  92377. * Sets the current transform matrix
  92378. * @param viewL defines the View matrix to use
  92379. * @param projectionL defines the Projection matrix to use
  92380. * @param viewR defines the right View matrix to use (if provided)
  92381. * @param projectionR defines the right Projection matrix to use (if provided)
  92382. */
  92383. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  92384. /**
  92385. * Gets the uniform buffer used to store scene data
  92386. * @returns a UniformBuffer
  92387. */
  92388. getSceneUniformBuffer(): UniformBuffer;
  92389. /**
  92390. * Gets an unique (relatively to the current scene) Id
  92391. * @returns an unique number for the scene
  92392. */
  92393. getUniqueId(): number;
  92394. /**
  92395. * Add a mesh to the list of scene's meshes
  92396. * @param newMesh defines the mesh to add
  92397. * @param recursive if all child meshes should also be added to the scene
  92398. */
  92399. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  92400. /**
  92401. * Remove a mesh for the list of scene's meshes
  92402. * @param toRemove defines the mesh to remove
  92403. * @param recursive if all child meshes should also be removed from the scene
  92404. * @returns the index where the mesh was in the mesh list
  92405. */
  92406. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  92407. /**
  92408. * Add a transform node to the list of scene's transform nodes
  92409. * @param newTransformNode defines the transform node to add
  92410. */
  92411. addTransformNode(newTransformNode: TransformNode): void;
  92412. /**
  92413. * Remove a transform node for the list of scene's transform nodes
  92414. * @param toRemove defines the transform node to remove
  92415. * @returns the index where the transform node was in the transform node list
  92416. */
  92417. removeTransformNode(toRemove: TransformNode): number;
  92418. /**
  92419. * Remove a skeleton for the list of scene's skeletons
  92420. * @param toRemove defines the skeleton to remove
  92421. * @returns the index where the skeleton was in the skeleton list
  92422. */
  92423. removeSkeleton(toRemove: Skeleton): number;
  92424. /**
  92425. * Remove a morph target for the list of scene's morph targets
  92426. * @param toRemove defines the morph target to remove
  92427. * @returns the index where the morph target was in the morph target list
  92428. */
  92429. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  92430. /**
  92431. * Remove a light for the list of scene's lights
  92432. * @param toRemove defines the light to remove
  92433. * @returns the index where the light was in the light list
  92434. */
  92435. removeLight(toRemove: Light): number;
  92436. /**
  92437. * Remove a camera for the list of scene's cameras
  92438. * @param toRemove defines the camera to remove
  92439. * @returns the index where the camera was in the camera list
  92440. */
  92441. removeCamera(toRemove: Camera): number;
  92442. /**
  92443. * Remove a particle system for the list of scene's particle systems
  92444. * @param toRemove defines the particle system to remove
  92445. * @returns the index where the particle system was in the particle system list
  92446. */
  92447. removeParticleSystem(toRemove: IParticleSystem): number;
  92448. /**
  92449. * Remove a animation for the list of scene's animations
  92450. * @param toRemove defines the animation to remove
  92451. * @returns the index where the animation was in the animation list
  92452. */
  92453. removeAnimation(toRemove: Animation): number;
  92454. /**
  92455. * Removes the given animation group from this scene.
  92456. * @param toRemove The animation group to remove
  92457. * @returns The index of the removed animation group
  92458. */
  92459. removeAnimationGroup(toRemove: AnimationGroup): number;
  92460. /**
  92461. * Removes the given multi-material from this scene.
  92462. * @param toRemove The multi-material to remove
  92463. * @returns The index of the removed multi-material
  92464. */
  92465. removeMultiMaterial(toRemove: MultiMaterial): number;
  92466. /**
  92467. * Removes the given material from this scene.
  92468. * @param toRemove The material to remove
  92469. * @returns The index of the removed material
  92470. */
  92471. removeMaterial(toRemove: Material): number;
  92472. /**
  92473. * Removes the given action manager from this scene.
  92474. * @param toRemove The action manager to remove
  92475. * @returns The index of the removed action manager
  92476. */
  92477. removeActionManager(toRemove: AbstractActionManager): number;
  92478. /**
  92479. * Removes the given texture from this scene.
  92480. * @param toRemove The texture to remove
  92481. * @returns The index of the removed texture
  92482. */
  92483. removeTexture(toRemove: BaseTexture): number;
  92484. /**
  92485. * Adds the given light to this scene
  92486. * @param newLight The light to add
  92487. */
  92488. addLight(newLight: Light): void;
  92489. /**
  92490. * Sorts the list list based on light priorities
  92491. */
  92492. sortLightsByPriority(): void;
  92493. /**
  92494. * Adds the given camera to this scene
  92495. * @param newCamera The camera to add
  92496. */
  92497. addCamera(newCamera: Camera): void;
  92498. /**
  92499. * Adds the given skeleton to this scene
  92500. * @param newSkeleton The skeleton to add
  92501. */
  92502. addSkeleton(newSkeleton: Skeleton): void;
  92503. /**
  92504. * Adds the given particle system to this scene
  92505. * @param newParticleSystem The particle system to add
  92506. */
  92507. addParticleSystem(newParticleSystem: IParticleSystem): void;
  92508. /**
  92509. * Adds the given animation to this scene
  92510. * @param newAnimation The animation to add
  92511. */
  92512. addAnimation(newAnimation: Animation): void;
  92513. /**
  92514. * Adds the given animation group to this scene.
  92515. * @param newAnimationGroup The animation group to add
  92516. */
  92517. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  92518. /**
  92519. * Adds the given multi-material to this scene
  92520. * @param newMultiMaterial The multi-material to add
  92521. */
  92522. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  92523. /**
  92524. * Adds the given material to this scene
  92525. * @param newMaterial The material to add
  92526. */
  92527. addMaterial(newMaterial: Material): void;
  92528. /**
  92529. * Adds the given morph target to this scene
  92530. * @param newMorphTargetManager The morph target to add
  92531. */
  92532. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  92533. /**
  92534. * Adds the given geometry to this scene
  92535. * @param newGeometry The geometry to add
  92536. */
  92537. addGeometry(newGeometry: Geometry): void;
  92538. /**
  92539. * Adds the given action manager to this scene
  92540. * @param newActionManager The action manager to add
  92541. */
  92542. addActionManager(newActionManager: AbstractActionManager): void;
  92543. /**
  92544. * Adds the given texture to this scene.
  92545. * @param newTexture The texture to add
  92546. */
  92547. addTexture(newTexture: BaseTexture): void;
  92548. /**
  92549. * Switch active camera
  92550. * @param newCamera defines the new active camera
  92551. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  92552. */
  92553. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  92554. /**
  92555. * sets the active camera of the scene using its ID
  92556. * @param id defines the camera's ID
  92557. * @return the new active camera or null if none found.
  92558. */
  92559. setActiveCameraByID(id: string): Nullable<Camera>;
  92560. /**
  92561. * sets the active camera of the scene using its name
  92562. * @param name defines the camera's name
  92563. * @returns the new active camera or null if none found.
  92564. */
  92565. setActiveCameraByName(name: string): Nullable<Camera>;
  92566. /**
  92567. * get an animation group using its name
  92568. * @param name defines the material's name
  92569. * @return the animation group or null if none found.
  92570. */
  92571. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  92572. /**
  92573. * Get a material using its unique id
  92574. * @param uniqueId defines the material's unique id
  92575. * @return the material or null if none found.
  92576. */
  92577. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  92578. /**
  92579. * get a material using its id
  92580. * @param id defines the material's ID
  92581. * @return the material or null if none found.
  92582. */
  92583. getMaterialByID(id: string): Nullable<Material>;
  92584. /**
  92585. * Gets a material using its name
  92586. * @param name defines the material's name
  92587. * @return the material or null if none found.
  92588. */
  92589. getMaterialByName(name: string): Nullable<Material>;
  92590. /**
  92591. * Gets a camera using its id
  92592. * @param id defines the id to look for
  92593. * @returns the camera or null if not found
  92594. */
  92595. getCameraByID(id: string): Nullable<Camera>;
  92596. /**
  92597. * Gets a camera using its unique id
  92598. * @param uniqueId defines the unique id to look for
  92599. * @returns the camera or null if not found
  92600. */
  92601. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  92602. /**
  92603. * Gets a camera using its name
  92604. * @param name defines the camera's name
  92605. * @return the camera or null if none found.
  92606. */
  92607. getCameraByName(name: string): Nullable<Camera>;
  92608. /**
  92609. * Gets a bone using its id
  92610. * @param id defines the bone's id
  92611. * @return the bone or null if not found
  92612. */
  92613. getBoneByID(id: string): Nullable<Bone>;
  92614. /**
  92615. * Gets a bone using its id
  92616. * @param name defines the bone's name
  92617. * @return the bone or null if not found
  92618. */
  92619. getBoneByName(name: string): Nullable<Bone>;
  92620. /**
  92621. * Gets a light node using its name
  92622. * @param name defines the the light's name
  92623. * @return the light or null if none found.
  92624. */
  92625. getLightByName(name: string): Nullable<Light>;
  92626. /**
  92627. * Gets a light node using its id
  92628. * @param id defines the light's id
  92629. * @return the light or null if none found.
  92630. */
  92631. getLightByID(id: string): Nullable<Light>;
  92632. /**
  92633. * Gets a light node using its scene-generated unique ID
  92634. * @param uniqueId defines the light's unique id
  92635. * @return the light or null if none found.
  92636. */
  92637. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  92638. /**
  92639. * Gets a particle system by id
  92640. * @param id defines the particle system id
  92641. * @return the corresponding system or null if none found
  92642. */
  92643. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  92644. /**
  92645. * Gets a geometry using its ID
  92646. * @param id defines the geometry's id
  92647. * @return the geometry or null if none found.
  92648. */
  92649. getGeometryByID(id: string): Nullable<Geometry>;
  92650. private _getGeometryByUniqueID;
  92651. /**
  92652. * Add a new geometry to this scene
  92653. * @param geometry defines the geometry to be added to the scene.
  92654. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  92655. * @return a boolean defining if the geometry was added or not
  92656. */
  92657. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  92658. /**
  92659. * Removes an existing geometry
  92660. * @param geometry defines the geometry to be removed from the scene
  92661. * @return a boolean defining if the geometry was removed or not
  92662. */
  92663. removeGeometry(geometry: Geometry): boolean;
  92664. /**
  92665. * Gets the list of geometries attached to the scene
  92666. * @returns an array of Geometry
  92667. */
  92668. getGeometries(): Geometry[];
  92669. /**
  92670. * Gets the first added mesh found of a given ID
  92671. * @param id defines the id to search for
  92672. * @return the mesh found or null if not found at all
  92673. */
  92674. getMeshByID(id: string): Nullable<AbstractMesh>;
  92675. /**
  92676. * Gets a list of meshes using their id
  92677. * @param id defines the id to search for
  92678. * @returns a list of meshes
  92679. */
  92680. getMeshesByID(id: string): Array<AbstractMesh>;
  92681. /**
  92682. * Gets the first added transform node found of a given ID
  92683. * @param id defines the id to search for
  92684. * @return the found transform node or null if not found at all.
  92685. */
  92686. getTransformNodeByID(id: string): Nullable<TransformNode>;
  92687. /**
  92688. * Gets a transform node with its auto-generated unique id
  92689. * @param uniqueId efines the unique id to search for
  92690. * @return the found transform node or null if not found at all.
  92691. */
  92692. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  92693. /**
  92694. * Gets a list of transform nodes using their id
  92695. * @param id defines the id to search for
  92696. * @returns a list of transform nodes
  92697. */
  92698. getTransformNodesByID(id: string): Array<TransformNode>;
  92699. /**
  92700. * Gets a mesh with its auto-generated unique id
  92701. * @param uniqueId defines the unique id to search for
  92702. * @return the found mesh or null if not found at all.
  92703. */
  92704. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  92705. /**
  92706. * Gets a the last added mesh using a given id
  92707. * @param id defines the id to search for
  92708. * @return the found mesh or null if not found at all.
  92709. */
  92710. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  92711. /**
  92712. * Gets a the last added node (Mesh, Camera, Light) using a given id
  92713. * @param id defines the id to search for
  92714. * @return the found node or null if not found at all
  92715. */
  92716. getLastEntryByID(id: string): Nullable<Node>;
  92717. /**
  92718. * Gets a node (Mesh, Camera, Light) using a given id
  92719. * @param id defines the id to search for
  92720. * @return the found node or null if not found at all
  92721. */
  92722. getNodeByID(id: string): Nullable<Node>;
  92723. /**
  92724. * Gets a node (Mesh, Camera, Light) using a given name
  92725. * @param name defines the name to search for
  92726. * @return the found node or null if not found at all.
  92727. */
  92728. getNodeByName(name: string): Nullable<Node>;
  92729. /**
  92730. * Gets a mesh using a given name
  92731. * @param name defines the name to search for
  92732. * @return the found mesh or null if not found at all.
  92733. */
  92734. getMeshByName(name: string): Nullable<AbstractMesh>;
  92735. /**
  92736. * Gets a transform node using a given name
  92737. * @param name defines the name to search for
  92738. * @return the found transform node or null if not found at all.
  92739. */
  92740. getTransformNodeByName(name: string): Nullable<TransformNode>;
  92741. /**
  92742. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  92743. * @param id defines the id to search for
  92744. * @return the found skeleton or null if not found at all.
  92745. */
  92746. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  92747. /**
  92748. * Gets a skeleton using a given auto generated unique id
  92749. * @param uniqueId defines the unique id to search for
  92750. * @return the found skeleton or null if not found at all.
  92751. */
  92752. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  92753. /**
  92754. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  92755. * @param id defines the id to search for
  92756. * @return the found skeleton or null if not found at all.
  92757. */
  92758. getSkeletonById(id: string): Nullable<Skeleton>;
  92759. /**
  92760. * Gets a skeleton using a given name
  92761. * @param name defines the name to search for
  92762. * @return the found skeleton or null if not found at all.
  92763. */
  92764. getSkeletonByName(name: string): Nullable<Skeleton>;
  92765. /**
  92766. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  92767. * @param id defines the id to search for
  92768. * @return the found morph target manager or null if not found at all.
  92769. */
  92770. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  92771. /**
  92772. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  92773. * @param id defines the id to search for
  92774. * @return the found morph target or null if not found at all.
  92775. */
  92776. getMorphTargetById(id: string): Nullable<MorphTarget>;
  92777. /**
  92778. * Gets a boolean indicating if the given mesh is active
  92779. * @param mesh defines the mesh to look for
  92780. * @returns true if the mesh is in the active list
  92781. */
  92782. isActiveMesh(mesh: AbstractMesh): boolean;
  92783. /**
  92784. * Return a unique id as a string which can serve as an identifier for the scene
  92785. */
  92786. readonly uid: string;
  92787. /**
  92788. * Add an externaly attached data from its key.
  92789. * This method call will fail and return false, if such key already exists.
  92790. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  92791. * @param key the unique key that identifies the data
  92792. * @param data the data object to associate to the key for this Engine instance
  92793. * @return true if no such key were already present and the data was added successfully, false otherwise
  92794. */
  92795. addExternalData<T>(key: string, data: T): boolean;
  92796. /**
  92797. * Get an externaly attached data from its key
  92798. * @param key the unique key that identifies the data
  92799. * @return the associated data, if present (can be null), or undefined if not present
  92800. */
  92801. getExternalData<T>(key: string): Nullable<T>;
  92802. /**
  92803. * Get an externaly attached data from its key, create it using a factory if it's not already present
  92804. * @param key the unique key that identifies the data
  92805. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  92806. * @return the associated data, can be null if the factory returned null.
  92807. */
  92808. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  92809. /**
  92810. * Remove an externaly attached data from the Engine instance
  92811. * @param key the unique key that identifies the data
  92812. * @return true if the data was successfully removed, false if it doesn't exist
  92813. */
  92814. removeExternalData(key: string): boolean;
  92815. private _evaluateSubMesh;
  92816. /**
  92817. * Clear the processed materials smart array preventing retention point in material dispose.
  92818. */
  92819. freeProcessedMaterials(): void;
  92820. private _preventFreeActiveMeshesAndRenderingGroups;
  92821. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  92822. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  92823. * when disposing several meshes in a row or a hierarchy of meshes.
  92824. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  92825. */
  92826. blockfreeActiveMeshesAndRenderingGroups: boolean;
  92827. /**
  92828. * Clear the active meshes smart array preventing retention point in mesh dispose.
  92829. */
  92830. freeActiveMeshes(): void;
  92831. /**
  92832. * Clear the info related to rendering groups preventing retention points during dispose.
  92833. */
  92834. freeRenderingGroups(): void;
  92835. /** @hidden */
  92836. _isInIntermediateRendering(): boolean;
  92837. /**
  92838. * Lambda returning the list of potentially active meshes.
  92839. */
  92840. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  92841. /**
  92842. * Lambda returning the list of potentially active sub meshes.
  92843. */
  92844. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  92845. /**
  92846. * Lambda returning the list of potentially intersecting sub meshes.
  92847. */
  92848. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  92849. /**
  92850. * Lambda returning the list of potentially colliding sub meshes.
  92851. */
  92852. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  92853. private _activeMeshesFrozen;
  92854. /**
  92855. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  92856. * @returns the current scene
  92857. */
  92858. freezeActiveMeshes(): Scene;
  92859. /**
  92860. * Use this function to restart evaluating active meshes on every frame
  92861. * @returns the current scene
  92862. */
  92863. unfreezeActiveMeshes(): Scene;
  92864. private _evaluateActiveMeshes;
  92865. private _activeMesh;
  92866. /**
  92867. * Update the transform matrix to update from the current active camera
  92868. * @param force defines a boolean used to force the update even if cache is up to date
  92869. */
  92870. updateTransformMatrix(force?: boolean): void;
  92871. private _bindFrameBuffer;
  92872. /** @hidden */
  92873. _allowPostProcessClearColor: boolean;
  92874. /** @hidden */
  92875. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  92876. private _processSubCameras;
  92877. private _checkIntersections;
  92878. /** @hidden */
  92879. _advancePhysicsEngineStep(step: number): void;
  92880. /**
  92881. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  92882. */
  92883. getDeterministicFrameTime: () => number;
  92884. /** @hidden */
  92885. _animate(): void;
  92886. /** Execute all animations (for a frame) */
  92887. animate(): void;
  92888. /**
  92889. * Render the scene
  92890. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  92891. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  92892. */
  92893. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  92894. /**
  92895. * Freeze all materials
  92896. * A frozen material will not be updatable but should be faster to render
  92897. */
  92898. freezeMaterials(): void;
  92899. /**
  92900. * Unfreeze all materials
  92901. * A frozen material will not be updatable but should be faster to render
  92902. */
  92903. unfreezeMaterials(): void;
  92904. /**
  92905. * Releases all held ressources
  92906. */
  92907. dispose(): void;
  92908. /**
  92909. * Gets if the scene is already disposed
  92910. */
  92911. readonly isDisposed: boolean;
  92912. /**
  92913. * Call this function to reduce memory footprint of the scene.
  92914. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  92915. */
  92916. clearCachedVertexData(): void;
  92917. /**
  92918. * This function will remove the local cached buffer data from texture.
  92919. * It will save memory but will prevent the texture from being rebuilt
  92920. */
  92921. cleanCachedTextureBuffer(): void;
  92922. /**
  92923. * Get the world extend vectors with an optional filter
  92924. *
  92925. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  92926. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  92927. */
  92928. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  92929. min: Vector3;
  92930. max: Vector3;
  92931. };
  92932. /**
  92933. * Creates a ray that can be used to pick in the scene
  92934. * @param x defines the x coordinate of the origin (on-screen)
  92935. * @param y defines the y coordinate of the origin (on-screen)
  92936. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92937. * @param camera defines the camera to use for the picking
  92938. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92939. * @returns a Ray
  92940. */
  92941. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  92942. /**
  92943. * Creates a ray that can be used to pick in the scene
  92944. * @param x defines the x coordinate of the origin (on-screen)
  92945. * @param y defines the y coordinate of the origin (on-screen)
  92946. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  92947. * @param result defines the ray where to store the picking ray
  92948. * @param camera defines the camera to use for the picking
  92949. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  92950. * @returns the current scene
  92951. */
  92952. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  92953. /**
  92954. * Creates a ray that can be used to pick in the scene
  92955. * @param x defines the x coordinate of the origin (on-screen)
  92956. * @param y defines the y coordinate of the origin (on-screen)
  92957. * @param camera defines the camera to use for the picking
  92958. * @returns a Ray
  92959. */
  92960. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  92961. /**
  92962. * Creates a ray that can be used to pick in the scene
  92963. * @param x defines the x coordinate of the origin (on-screen)
  92964. * @param y defines the y coordinate of the origin (on-screen)
  92965. * @param result defines the ray where to store the picking ray
  92966. * @param camera defines the camera to use for the picking
  92967. * @returns the current scene
  92968. */
  92969. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  92970. /** Launch a ray to try to pick a mesh in the scene
  92971. * @param x position on screen
  92972. * @param y position on screen
  92973. * @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
  92974. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  92975. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92976. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92977. * @returns a PickingInfo
  92978. */
  92979. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: (p0: Vector3, p1: Vector3, p2: Vector3) => boolean): Nullable<PickingInfo>;
  92980. /** Use the given ray to pick a mesh in the scene
  92981. * @param ray The ray to use to pick meshes
  92982. * @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
  92983. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  92984. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92985. * @returns a PickingInfo
  92986. */
  92987. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  92988. /**
  92989. * Launch a ray to try to pick a mesh in the scene
  92990. * @param x X position on screen
  92991. * @param y Y position on screen
  92992. * @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
  92993. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  92994. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  92995. * @returns an array of PickingInfo
  92996. */
  92997. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  92998. /**
  92999. * Launch a ray to try to pick a mesh in the scene
  93000. * @param ray Ray to use
  93001. * @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
  93002. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  93003. * @returns an array of PickingInfo
  93004. */
  93005. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  93006. /**
  93007. * Force the value of meshUnderPointer
  93008. * @param mesh defines the mesh to use
  93009. */
  93010. setPointerOverMesh(mesh: Nullable<AbstractMesh>): void;
  93011. /**
  93012. * Gets the mesh under the pointer
  93013. * @returns a Mesh or null if no mesh is under the pointer
  93014. */
  93015. getPointerOverMesh(): Nullable<AbstractMesh>;
  93016. /** @hidden */
  93017. _rebuildGeometries(): void;
  93018. /** @hidden */
  93019. _rebuildTextures(): void;
  93020. private _getByTags;
  93021. /**
  93022. * Get a list of meshes by tags
  93023. * @param tagsQuery defines the tags query to use
  93024. * @param forEach defines a predicate used to filter results
  93025. * @returns an array of Mesh
  93026. */
  93027. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  93028. /**
  93029. * Get a list of cameras by tags
  93030. * @param tagsQuery defines the tags query to use
  93031. * @param forEach defines a predicate used to filter results
  93032. * @returns an array of Camera
  93033. */
  93034. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  93035. /**
  93036. * Get a list of lights by tags
  93037. * @param tagsQuery defines the tags query to use
  93038. * @param forEach defines a predicate used to filter results
  93039. * @returns an array of Light
  93040. */
  93041. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  93042. /**
  93043. * Get a list of materials by tags
  93044. * @param tagsQuery defines the tags query to use
  93045. * @param forEach defines a predicate used to filter results
  93046. * @returns an array of Material
  93047. */
  93048. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  93049. /**
  93050. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  93051. * This allowed control for front to back rendering or reversly depending of the special needs.
  93052. *
  93053. * @param renderingGroupId The rendering group id corresponding to its index
  93054. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  93055. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  93056. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  93057. */
  93058. 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;
  93059. /**
  93060. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  93061. *
  93062. * @param renderingGroupId The rendering group id corresponding to its index
  93063. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  93064. * @param depth Automatically clears depth between groups if true and autoClear is true.
  93065. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  93066. */
  93067. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  93068. /**
  93069. * Gets the current auto clear configuration for one rendering group of the rendering
  93070. * manager.
  93071. * @param index the rendering group index to get the information for
  93072. * @returns The auto clear setup for the requested rendering group
  93073. */
  93074. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  93075. private _blockMaterialDirtyMechanism;
  93076. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  93077. blockMaterialDirtyMechanism: boolean;
  93078. /**
  93079. * Will flag all materials as dirty to trigger new shader compilation
  93080. * @param flag defines the flag used to specify which material part must be marked as dirty
  93081. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  93082. */
  93083. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  93084. /** @hidden */
  93085. _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;
  93086. /** @hidden */
  93087. _loadFileAsync(url: string, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  93088. }
  93089. }
  93090. declare module BABYLON {
  93091. /**
  93092. * Set of assets to keep when moving a scene into an asset container.
  93093. */
  93094. export class KeepAssets extends AbstractScene {
  93095. }
  93096. /**
  93097. * Container with a set of assets that can be added or removed from a scene.
  93098. */
  93099. export class AssetContainer extends AbstractScene {
  93100. /**
  93101. * The scene the AssetContainer belongs to.
  93102. */
  93103. scene: Scene;
  93104. /**
  93105. * Instantiates an AssetContainer.
  93106. * @param scene The scene the AssetContainer belongs to.
  93107. */
  93108. constructor(scene: Scene);
  93109. /**
  93110. * Adds all the assets from the container to the scene.
  93111. */
  93112. addAllToScene(): void;
  93113. /**
  93114. * Removes all the assets in the container from the scene
  93115. */
  93116. removeAllFromScene(): void;
  93117. /**
  93118. * Disposes all the assets in the container
  93119. */
  93120. dispose(): void;
  93121. private _moveAssets;
  93122. /**
  93123. * Removes all the assets contained in the scene and adds them to the container.
  93124. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  93125. */
  93126. moveAllFromScene(keepAssets?: KeepAssets): void;
  93127. /**
  93128. * 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.
  93129. * @returns the root mesh
  93130. */
  93131. createRootMesh(): Mesh;
  93132. }
  93133. }
  93134. declare module BABYLON {
  93135. /**
  93136. * Defines how the parser contract is defined.
  93137. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  93138. */
  93139. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  93140. /**
  93141. * Defines how the individual parser contract is defined.
  93142. * These parser can parse an individual asset
  93143. */
  93144. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  93145. /**
  93146. * Base class of the scene acting as a container for the different elements composing a scene.
  93147. * This class is dynamically extended by the different components of the scene increasing
  93148. * flexibility and reducing coupling
  93149. */
  93150. export abstract class AbstractScene {
  93151. /**
  93152. * Stores the list of available parsers in the application.
  93153. */
  93154. private static _BabylonFileParsers;
  93155. /**
  93156. * Stores the list of available individual parsers in the application.
  93157. */
  93158. private static _IndividualBabylonFileParsers;
  93159. /**
  93160. * Adds a parser in the list of available ones
  93161. * @param name Defines the name of the parser
  93162. * @param parser Defines the parser to add
  93163. */
  93164. static AddParser(name: string, parser: BabylonFileParser): void;
  93165. /**
  93166. * Gets a general parser from the list of avaialble ones
  93167. * @param name Defines the name of the parser
  93168. * @returns the requested parser or null
  93169. */
  93170. static GetParser(name: string): Nullable<BabylonFileParser>;
  93171. /**
  93172. * Adds n individual parser in the list of available ones
  93173. * @param name Defines the name of the parser
  93174. * @param parser Defines the parser to add
  93175. */
  93176. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  93177. /**
  93178. * Gets an individual parser from the list of avaialble ones
  93179. * @param name Defines the name of the parser
  93180. * @returns the requested parser or null
  93181. */
  93182. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  93183. /**
  93184. * Parser json data and populate both a scene and its associated container object
  93185. * @param jsonData Defines the data to parse
  93186. * @param scene Defines the scene to parse the data for
  93187. * @param container Defines the container attached to the parsing sequence
  93188. * @param rootUrl Defines the root url of the data
  93189. */
  93190. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  93191. /**
  93192. * Gets the list of root nodes (ie. nodes with no parent)
  93193. */
  93194. rootNodes: Node[];
  93195. /** All of the cameras added to this scene
  93196. * @see http://doc.babylonjs.com/babylon101/cameras
  93197. */
  93198. cameras: Camera[];
  93199. /**
  93200. * All of the lights added to this scene
  93201. * @see http://doc.babylonjs.com/babylon101/lights
  93202. */
  93203. lights: Light[];
  93204. /**
  93205. * All of the (abstract) meshes added to this scene
  93206. */
  93207. meshes: AbstractMesh[];
  93208. /**
  93209. * The list of skeletons added to the scene
  93210. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  93211. */
  93212. skeletons: Skeleton[];
  93213. /**
  93214. * All of the particle systems added to this scene
  93215. * @see http://doc.babylonjs.com/babylon101/particles
  93216. */
  93217. particleSystems: IParticleSystem[];
  93218. /**
  93219. * Gets a list of Animations associated with the scene
  93220. */
  93221. animations: Animation[];
  93222. /**
  93223. * All of the animation groups added to this scene
  93224. * @see http://doc.babylonjs.com/how_to/group
  93225. */
  93226. animationGroups: AnimationGroup[];
  93227. /**
  93228. * All of the multi-materials added to this scene
  93229. * @see http://doc.babylonjs.com/how_to/multi_materials
  93230. */
  93231. multiMaterials: MultiMaterial[];
  93232. /**
  93233. * All of the materials added to this scene
  93234. * In the context of a Scene, it is not supposed to be modified manually.
  93235. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  93236. * Note also that the order of the Material wihin the array is not significant and might change.
  93237. * @see http://doc.babylonjs.com/babylon101/materials
  93238. */
  93239. materials: Material[];
  93240. /**
  93241. * The list of morph target managers added to the scene
  93242. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  93243. */
  93244. morphTargetManagers: MorphTargetManager[];
  93245. /**
  93246. * The list of geometries used in the scene.
  93247. */
  93248. geometries: Geometry[];
  93249. /**
  93250. * All of the tranform nodes added to this scene
  93251. * In the context of a Scene, it is not supposed to be modified manually.
  93252. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  93253. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  93254. * @see http://doc.babylonjs.com/how_to/transformnode
  93255. */
  93256. transformNodes: TransformNode[];
  93257. /**
  93258. * ActionManagers available on the scene.
  93259. */
  93260. actionManagers: AbstractActionManager[];
  93261. /**
  93262. * Textures to keep.
  93263. */
  93264. textures: BaseTexture[];
  93265. /**
  93266. * Environment texture for the scene
  93267. */
  93268. environmentTexture: Nullable<BaseTexture>;
  93269. }
  93270. }
  93271. declare module BABYLON {
  93272. /**
  93273. * Defines a sound that can be played in the application.
  93274. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  93275. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93276. */
  93277. export class Sound {
  93278. /**
  93279. * The name of the sound in the scene.
  93280. */
  93281. name: string;
  93282. /**
  93283. * Does the sound autoplay once loaded.
  93284. */
  93285. autoplay: boolean;
  93286. /**
  93287. * Does the sound loop after it finishes playing once.
  93288. */
  93289. loop: boolean;
  93290. /**
  93291. * Does the sound use a custom attenuation curve to simulate the falloff
  93292. * happening when the source gets further away from the camera.
  93293. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93294. */
  93295. useCustomAttenuation: boolean;
  93296. /**
  93297. * The sound track id this sound belongs to.
  93298. */
  93299. soundTrackId: number;
  93300. /**
  93301. * Is this sound currently played.
  93302. */
  93303. isPlaying: boolean;
  93304. /**
  93305. * Is this sound currently paused.
  93306. */
  93307. isPaused: boolean;
  93308. /**
  93309. * Does this sound enables spatial sound.
  93310. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93311. */
  93312. spatialSound: boolean;
  93313. /**
  93314. * Define the reference distance the sound should be heard perfectly.
  93315. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93316. */
  93317. refDistance: number;
  93318. /**
  93319. * Define the roll off factor of spatial sounds.
  93320. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93321. */
  93322. rolloffFactor: number;
  93323. /**
  93324. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  93325. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93326. */
  93327. maxDistance: number;
  93328. /**
  93329. * Define the distance attenuation model the sound will follow.
  93330. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93331. */
  93332. distanceModel: string;
  93333. /**
  93334. * @hidden
  93335. * Back Compat
  93336. **/
  93337. onended: () => any;
  93338. /**
  93339. * Observable event when the current playing sound finishes.
  93340. */
  93341. onEndedObservable: Observable<Sound>;
  93342. private _panningModel;
  93343. private _playbackRate;
  93344. private _streaming;
  93345. private _startTime;
  93346. private _startOffset;
  93347. private _position;
  93348. /** @hidden */
  93349. _positionInEmitterSpace: boolean;
  93350. private _localDirection;
  93351. private _volume;
  93352. private _isReadyToPlay;
  93353. private _isDirectional;
  93354. private _readyToPlayCallback;
  93355. private _audioBuffer;
  93356. private _soundSource;
  93357. private _streamingSource;
  93358. private _soundPanner;
  93359. private _soundGain;
  93360. private _inputAudioNode;
  93361. private _outputAudioNode;
  93362. private _coneInnerAngle;
  93363. private _coneOuterAngle;
  93364. private _coneOuterGain;
  93365. private _scene;
  93366. private _connectedTransformNode;
  93367. private _customAttenuationFunction;
  93368. private _registerFunc;
  93369. private _isOutputConnected;
  93370. private _htmlAudioElement;
  93371. private _urlType;
  93372. /** @hidden */
  93373. static _SceneComponentInitialization: (scene: Scene) => void;
  93374. /**
  93375. * Create a sound and attach it to a scene
  93376. * @param name Name of your sound
  93377. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  93378. * @param scene defines the scene the sound belongs to
  93379. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  93380. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  93381. */
  93382. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: any);
  93383. /**
  93384. * Release the sound and its associated resources
  93385. */
  93386. dispose(): void;
  93387. /**
  93388. * Gets if the sounds is ready to be played or not.
  93389. * @returns true if ready, otherwise false
  93390. */
  93391. isReady(): boolean;
  93392. private _soundLoaded;
  93393. /**
  93394. * Sets the data of the sound from an audiobuffer
  93395. * @param audioBuffer The audioBuffer containing the data
  93396. */
  93397. setAudioBuffer(audioBuffer: AudioBuffer): void;
  93398. /**
  93399. * Updates the current sounds options such as maxdistance, loop...
  93400. * @param options A JSON object containing values named as the object properties
  93401. */
  93402. updateOptions(options: any): void;
  93403. private _createSpatialParameters;
  93404. private _updateSpatialParameters;
  93405. /**
  93406. * Switch the panning model to HRTF:
  93407. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93408. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93409. */
  93410. switchPanningModelToHRTF(): void;
  93411. /**
  93412. * Switch the panning model to Equal Power:
  93413. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93414. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93415. */
  93416. switchPanningModelToEqualPower(): void;
  93417. private _switchPanningModel;
  93418. /**
  93419. * Connect this sound to a sound track audio node like gain...
  93420. * @param soundTrackAudioNode the sound track audio node to connect to
  93421. */
  93422. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  93423. /**
  93424. * Transform this sound into a directional source
  93425. * @param coneInnerAngle Size of the inner cone in degree
  93426. * @param coneOuterAngle Size of the outer cone in degree
  93427. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  93428. */
  93429. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  93430. /**
  93431. * Gets or sets the inner angle for the directional cone.
  93432. */
  93433. /**
  93434. * Gets or sets the inner angle for the directional cone.
  93435. */
  93436. directionalConeInnerAngle: number;
  93437. /**
  93438. * Gets or sets the outer angle for the directional cone.
  93439. */
  93440. /**
  93441. * Gets or sets the outer angle for the directional cone.
  93442. */
  93443. directionalConeOuterAngle: number;
  93444. /**
  93445. * Sets the position of the emitter if spatial sound is enabled
  93446. * @param newPosition Defines the new posisiton
  93447. */
  93448. setPosition(newPosition: Vector3): void;
  93449. /**
  93450. * Sets the local direction of the emitter if spatial sound is enabled
  93451. * @param newLocalDirection Defines the new local direction
  93452. */
  93453. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  93454. private _updateDirection;
  93455. /** @hidden */
  93456. updateDistanceFromListener(): void;
  93457. /**
  93458. * Sets a new custom attenuation function for the sound.
  93459. * @param callback Defines the function used for the attenuation
  93460. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  93461. */
  93462. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  93463. /**
  93464. * Play the sound
  93465. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  93466. * @param offset (optional) Start the sound setting it at a specific time
  93467. */
  93468. play(time?: number, offset?: number): void;
  93469. private _onended;
  93470. /**
  93471. * Stop the sound
  93472. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  93473. */
  93474. stop(time?: number): void;
  93475. /**
  93476. * Put the sound in pause
  93477. */
  93478. pause(): void;
  93479. /**
  93480. * Sets a dedicated volume for this sounds
  93481. * @param newVolume Define the new volume of the sound
  93482. * @param time Define in how long the sound should be at this value
  93483. */
  93484. setVolume(newVolume: number, time?: number): void;
  93485. /**
  93486. * Set the sound play back rate
  93487. * @param newPlaybackRate Define the playback rate the sound should be played at
  93488. */
  93489. setPlaybackRate(newPlaybackRate: number): void;
  93490. /**
  93491. * Gets the volume of the sound.
  93492. * @returns the volume of the sound
  93493. */
  93494. getVolume(): number;
  93495. /**
  93496. * Attach the sound to a dedicated mesh
  93497. * @param transformNode The transform node to connect the sound with
  93498. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93499. */
  93500. attachToMesh(transformNode: TransformNode): void;
  93501. /**
  93502. * Detach the sound from the previously attached mesh
  93503. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  93504. */
  93505. detachFromMesh(): void;
  93506. private _onRegisterAfterWorldMatrixUpdate;
  93507. /**
  93508. * Clone the current sound in the scene.
  93509. * @returns the new sound clone
  93510. */
  93511. clone(): Nullable<Sound>;
  93512. /**
  93513. * Gets the current underlying audio buffer containing the data
  93514. * @returns the audio buffer
  93515. */
  93516. getAudioBuffer(): Nullable<AudioBuffer>;
  93517. /**
  93518. * Serializes the Sound in a JSON representation
  93519. * @returns the JSON representation of the sound
  93520. */
  93521. serialize(): any;
  93522. /**
  93523. * Parse a JSON representation of a sound to innstantiate in a given scene
  93524. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  93525. * @param scene Define the scene the new parsed sound should be created in
  93526. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  93527. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  93528. * @returns the newly parsed sound
  93529. */
  93530. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  93531. }
  93532. }
  93533. declare module BABYLON {
  93534. /**
  93535. * This defines an action helpful to play a defined sound on a triggered action.
  93536. */
  93537. export class PlaySoundAction extends Action {
  93538. private _sound;
  93539. /**
  93540. * Instantiate the action
  93541. * @param triggerOptions defines the trigger options
  93542. * @param sound defines the sound to play
  93543. * @param condition defines the trigger related conditions
  93544. */
  93545. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93546. /** @hidden */
  93547. _prepare(): void;
  93548. /**
  93549. * Execute the action and play the sound.
  93550. */
  93551. execute(): void;
  93552. /**
  93553. * Serializes the actions and its related information.
  93554. * @param parent defines the object to serialize in
  93555. * @returns the serialized object
  93556. */
  93557. serialize(parent: any): any;
  93558. }
  93559. /**
  93560. * This defines an action helpful to stop a defined sound on a triggered action.
  93561. */
  93562. export class StopSoundAction extends Action {
  93563. private _sound;
  93564. /**
  93565. * Instantiate the action
  93566. * @param triggerOptions defines the trigger options
  93567. * @param sound defines the sound to stop
  93568. * @param condition defines the trigger related conditions
  93569. */
  93570. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  93571. /** @hidden */
  93572. _prepare(): void;
  93573. /**
  93574. * Execute the action and stop the sound.
  93575. */
  93576. execute(): void;
  93577. /**
  93578. * Serializes the actions and its related information.
  93579. * @param parent defines the object to serialize in
  93580. * @returns the serialized object
  93581. */
  93582. serialize(parent: any): any;
  93583. }
  93584. }
  93585. declare module BABYLON {
  93586. /**
  93587. * This defines an action responsible to change the value of a property
  93588. * by interpolating between its current value and the newly set one once triggered.
  93589. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  93590. */
  93591. export class InterpolateValueAction extends Action {
  93592. /**
  93593. * Defines the path of the property where the value should be interpolated
  93594. */
  93595. propertyPath: string;
  93596. /**
  93597. * Defines the target value at the end of the interpolation.
  93598. */
  93599. value: any;
  93600. /**
  93601. * Defines the time it will take for the property to interpolate to the value.
  93602. */
  93603. duration: number;
  93604. /**
  93605. * Defines if the other scene animations should be stopped when the action has been triggered
  93606. */
  93607. stopOtherAnimations?: boolean;
  93608. /**
  93609. * Defines a callback raised once the interpolation animation has been done.
  93610. */
  93611. onInterpolationDone?: () => void;
  93612. /**
  93613. * Observable triggered once the interpolation animation has been done.
  93614. */
  93615. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  93616. private _target;
  93617. private _effectiveTarget;
  93618. private _property;
  93619. /**
  93620. * Instantiate the action
  93621. * @param triggerOptions defines the trigger options
  93622. * @param target defines the object containing the value to interpolate
  93623. * @param propertyPath defines the path to the property in the target object
  93624. * @param value defines the target value at the end of the interpolation
  93625. * @param duration deines the time it will take for the property to interpolate to the value.
  93626. * @param condition defines the trigger related conditions
  93627. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  93628. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  93629. */
  93630. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  93631. /** @hidden */
  93632. _prepare(): void;
  93633. /**
  93634. * Execute the action starts the value interpolation.
  93635. */
  93636. execute(): void;
  93637. /**
  93638. * Serializes the actions and its related information.
  93639. * @param parent defines the object to serialize in
  93640. * @returns the serialized object
  93641. */
  93642. serialize(parent: any): any;
  93643. }
  93644. }
  93645. declare module BABYLON {
  93646. /**
  93647. * Options allowed during the creation of a sound track.
  93648. */
  93649. export interface ISoundTrackOptions {
  93650. /**
  93651. * The volume the sound track should take during creation
  93652. */
  93653. volume?: number;
  93654. /**
  93655. * Define if the sound track is the main sound track of the scene
  93656. */
  93657. mainTrack?: boolean;
  93658. }
  93659. /**
  93660. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  93661. * It will be also used in a future release to apply effects on a specific track.
  93662. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93663. */
  93664. export class SoundTrack {
  93665. /**
  93666. * The unique identifier of the sound track in the scene.
  93667. */
  93668. id: number;
  93669. /**
  93670. * The list of sounds included in the sound track.
  93671. */
  93672. soundCollection: Array<Sound>;
  93673. private _outputAudioNode;
  93674. private _scene;
  93675. private _isMainTrack;
  93676. private _connectedAnalyser;
  93677. private _options;
  93678. private _isInitialized;
  93679. /**
  93680. * Creates a new sound track.
  93681. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  93682. * @param scene Define the scene the sound track belongs to
  93683. * @param options
  93684. */
  93685. constructor(scene: Scene, options?: ISoundTrackOptions);
  93686. private _initializeSoundTrackAudioGraph;
  93687. /**
  93688. * Release the sound track and its associated resources
  93689. */
  93690. dispose(): void;
  93691. /**
  93692. * Adds a sound to this sound track
  93693. * @param sound define the cound to add
  93694. * @ignoreNaming
  93695. */
  93696. AddSound(sound: Sound): void;
  93697. /**
  93698. * Removes a sound to this sound track
  93699. * @param sound define the cound to remove
  93700. * @ignoreNaming
  93701. */
  93702. RemoveSound(sound: Sound): void;
  93703. /**
  93704. * Set a global volume for the full sound track.
  93705. * @param newVolume Define the new volume of the sound track
  93706. */
  93707. setVolume(newVolume: number): void;
  93708. /**
  93709. * Switch the panning model to HRTF:
  93710. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  93711. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93712. */
  93713. switchPanningModelToHRTF(): void;
  93714. /**
  93715. * Switch the panning model to Equal Power:
  93716. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  93717. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  93718. */
  93719. switchPanningModelToEqualPower(): void;
  93720. /**
  93721. * Connect the sound track to an audio analyser allowing some amazing
  93722. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  93723. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  93724. * @param analyser The analyser to connect to the engine
  93725. */
  93726. connectToAnalyser(analyser: Analyser): void;
  93727. }
  93728. }
  93729. declare module BABYLON {
  93730. interface AbstractScene {
  93731. /**
  93732. * The list of sounds used in the scene.
  93733. */
  93734. sounds: Nullable<Array<Sound>>;
  93735. }
  93736. interface Scene {
  93737. /**
  93738. * @hidden
  93739. * Backing field
  93740. */
  93741. _mainSoundTrack: SoundTrack;
  93742. /**
  93743. * The main sound track played by the scene.
  93744. * It cotains your primary collection of sounds.
  93745. */
  93746. mainSoundTrack: SoundTrack;
  93747. /**
  93748. * The list of sound tracks added to the scene
  93749. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93750. */
  93751. soundTracks: Nullable<Array<SoundTrack>>;
  93752. /**
  93753. * Gets a sound using a given name
  93754. * @param name defines the name to search for
  93755. * @return the found sound or null if not found at all.
  93756. */
  93757. getSoundByName(name: string): Nullable<Sound>;
  93758. /**
  93759. * Gets or sets if audio support is enabled
  93760. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93761. */
  93762. audioEnabled: boolean;
  93763. /**
  93764. * Gets or sets if audio will be output to headphones
  93765. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  93766. */
  93767. headphone: boolean;
  93768. }
  93769. /**
  93770. * Defines the sound scene component responsible to manage any sounds
  93771. * in a given scene.
  93772. */
  93773. export class AudioSceneComponent implements ISceneSerializableComponent {
  93774. /**
  93775. * The component name helpfull to identify the component in the list of scene components.
  93776. */
  93777. readonly name: string;
  93778. /**
  93779. * The scene the component belongs to.
  93780. */
  93781. scene: Scene;
  93782. private _audioEnabled;
  93783. /**
  93784. * Gets whether audio is enabled or not.
  93785. * Please use related enable/disable method to switch state.
  93786. */
  93787. readonly audioEnabled: boolean;
  93788. private _headphone;
  93789. /**
  93790. * Gets whether audio is outputing to headphone or not.
  93791. * Please use the according Switch methods to change output.
  93792. */
  93793. readonly headphone: boolean;
  93794. /**
  93795. * Creates a new instance of the component for the given scene
  93796. * @param scene Defines the scene to register the component in
  93797. */
  93798. constructor(scene: Scene);
  93799. /**
  93800. * Registers the component in a given scene
  93801. */
  93802. register(): void;
  93803. /**
  93804. * Rebuilds the elements related to this component in case of
  93805. * context lost for instance.
  93806. */
  93807. rebuild(): void;
  93808. /**
  93809. * Serializes the component data to the specified json object
  93810. * @param serializationObject The object to serialize to
  93811. */
  93812. serialize(serializationObject: any): void;
  93813. /**
  93814. * Adds all the element from the container to the scene
  93815. * @param container the container holding the elements
  93816. */
  93817. addFromContainer(container: AbstractScene): void;
  93818. /**
  93819. * Removes all the elements in the container from the scene
  93820. * @param container contains the elements to remove
  93821. * @param dispose if the removed element should be disposed (default: false)
  93822. */
  93823. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  93824. /**
  93825. * Disposes the component and the associated ressources.
  93826. */
  93827. dispose(): void;
  93828. /**
  93829. * Disables audio in the associated scene.
  93830. */
  93831. disableAudio(): void;
  93832. /**
  93833. * Enables audio in the associated scene.
  93834. */
  93835. enableAudio(): void;
  93836. /**
  93837. * Switch audio to headphone output.
  93838. */
  93839. switchAudioModeForHeadphones(): void;
  93840. /**
  93841. * Switch audio to normal speakers.
  93842. */
  93843. switchAudioModeForNormalSpeakers(): void;
  93844. private _afterRender;
  93845. }
  93846. }
  93847. declare module BABYLON {
  93848. /**
  93849. * Wraps one or more Sound objects and selects one with random weight for playback.
  93850. */
  93851. export class WeightedSound {
  93852. /** When true a Sound will be selected and played when the current playing Sound completes. */
  93853. loop: boolean;
  93854. private _coneInnerAngle;
  93855. private _coneOuterAngle;
  93856. private _volume;
  93857. /** A Sound is currently playing. */
  93858. isPlaying: boolean;
  93859. /** A Sound is currently paused. */
  93860. isPaused: boolean;
  93861. private _sounds;
  93862. private _weights;
  93863. private _currentIndex?;
  93864. /**
  93865. * Creates a new WeightedSound from the list of sounds given.
  93866. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  93867. * @param sounds Array of Sounds that will be selected from.
  93868. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  93869. */
  93870. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  93871. /**
  93872. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  93873. */
  93874. /**
  93875. * The size of cone in degress for a directional sound in which there will be no attenuation.
  93876. */
  93877. directionalConeInnerAngle: number;
  93878. /**
  93879. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93880. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93881. */
  93882. /**
  93883. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  93884. * Listener angles between innerAngle and outerAngle will falloff linearly.
  93885. */
  93886. directionalConeOuterAngle: number;
  93887. /**
  93888. * Playback volume.
  93889. */
  93890. /**
  93891. * Playback volume.
  93892. */
  93893. volume: number;
  93894. private _onended;
  93895. /**
  93896. * Suspend playback
  93897. */
  93898. pause(): void;
  93899. /**
  93900. * Stop playback
  93901. */
  93902. stop(): void;
  93903. /**
  93904. * Start playback.
  93905. * @param startOffset Position the clip head at a specific time in seconds.
  93906. */
  93907. play(startOffset?: number): void;
  93908. }
  93909. }
  93910. declare module BABYLON {
  93911. /**
  93912. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  93913. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  93914. */
  93915. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  93916. /**
  93917. * Gets the name of the behavior.
  93918. */
  93919. readonly name: string;
  93920. /**
  93921. * The easing function used by animations
  93922. */
  93923. static EasingFunction: BackEase;
  93924. /**
  93925. * The easing mode used by animations
  93926. */
  93927. static EasingMode: number;
  93928. /**
  93929. * The duration of the animation, in milliseconds
  93930. */
  93931. transitionDuration: number;
  93932. /**
  93933. * Length of the distance animated by the transition when lower radius is reached
  93934. */
  93935. lowerRadiusTransitionRange: number;
  93936. /**
  93937. * Length of the distance animated by the transition when upper radius is reached
  93938. */
  93939. upperRadiusTransitionRange: number;
  93940. private _autoTransitionRange;
  93941. /**
  93942. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93943. */
  93944. /**
  93945. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  93946. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  93947. */
  93948. autoTransitionRange: boolean;
  93949. private _attachedCamera;
  93950. private _onAfterCheckInputsObserver;
  93951. private _onMeshTargetChangedObserver;
  93952. /**
  93953. * Initializes the behavior.
  93954. */
  93955. init(): void;
  93956. /**
  93957. * Attaches the behavior to its arc rotate camera.
  93958. * @param camera Defines the camera to attach the behavior to
  93959. */
  93960. attach(camera: ArcRotateCamera): void;
  93961. /**
  93962. * Detaches the behavior from its current arc rotate camera.
  93963. */
  93964. detach(): void;
  93965. private _radiusIsAnimating;
  93966. private _radiusBounceTransition;
  93967. private _animatables;
  93968. private _cachedWheelPrecision;
  93969. /**
  93970. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  93971. * @param radiusLimit The limit to check against.
  93972. * @return Bool to indicate if at limit.
  93973. */
  93974. private _isRadiusAtLimit;
  93975. /**
  93976. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  93977. * @param radiusDelta The delta by which to animate to. Can be negative.
  93978. */
  93979. private _applyBoundRadiusAnimation;
  93980. /**
  93981. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  93982. */
  93983. protected _clearAnimationLocks(): void;
  93984. /**
  93985. * Stops and removes all animations that have been applied to the camera
  93986. */
  93987. stopAllAnimations(): void;
  93988. }
  93989. }
  93990. declare module BABYLON {
  93991. /**
  93992. * 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.
  93993. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  93994. */
  93995. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  93996. /**
  93997. * Gets the name of the behavior.
  93998. */
  93999. readonly name: string;
  94000. private _mode;
  94001. private _radiusScale;
  94002. private _positionScale;
  94003. private _defaultElevation;
  94004. private _elevationReturnTime;
  94005. private _elevationReturnWaitTime;
  94006. private _zoomStopsAnimation;
  94007. private _framingTime;
  94008. /**
  94009. * The easing function used by animations
  94010. */
  94011. static EasingFunction: ExponentialEase;
  94012. /**
  94013. * The easing mode used by animations
  94014. */
  94015. static EasingMode: number;
  94016. /**
  94017. * Sets the current mode used by the behavior
  94018. */
  94019. /**
  94020. * Gets current mode used by the behavior.
  94021. */
  94022. mode: number;
  94023. /**
  94024. * Sets the scale applied to the radius (1 by default)
  94025. */
  94026. /**
  94027. * Gets the scale applied to the radius
  94028. */
  94029. radiusScale: number;
  94030. /**
  94031. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94032. */
  94033. /**
  94034. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  94035. */
  94036. positionScale: number;
  94037. /**
  94038. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94039. * behaviour is triggered, in radians.
  94040. */
  94041. /**
  94042. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  94043. * behaviour is triggered, in radians.
  94044. */
  94045. defaultElevation: number;
  94046. /**
  94047. * Sets the time (in milliseconds) taken to return to the default beta position.
  94048. * Negative value indicates camera should not return to default.
  94049. */
  94050. /**
  94051. * Gets the time (in milliseconds) taken to return to the default beta position.
  94052. * Negative value indicates camera should not return to default.
  94053. */
  94054. elevationReturnTime: number;
  94055. /**
  94056. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94057. */
  94058. /**
  94059. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  94060. */
  94061. elevationReturnWaitTime: number;
  94062. /**
  94063. * Sets the flag that indicates if user zooming should stop animation.
  94064. */
  94065. /**
  94066. * Gets the flag that indicates if user zooming should stop animation.
  94067. */
  94068. zoomStopsAnimation: boolean;
  94069. /**
  94070. * Sets the transition time when framing the mesh, in milliseconds
  94071. */
  94072. /**
  94073. * Gets the transition time when framing the mesh, in milliseconds
  94074. */
  94075. framingTime: number;
  94076. /**
  94077. * Define if the behavior should automatically change the configured
  94078. * camera limits and sensibilities.
  94079. */
  94080. autoCorrectCameraLimitsAndSensibility: boolean;
  94081. private _onPrePointerObservableObserver;
  94082. private _onAfterCheckInputsObserver;
  94083. private _onMeshTargetChangedObserver;
  94084. private _attachedCamera;
  94085. private _isPointerDown;
  94086. private _lastInteractionTime;
  94087. /**
  94088. * Initializes the behavior.
  94089. */
  94090. init(): void;
  94091. /**
  94092. * Attaches the behavior to its arc rotate camera.
  94093. * @param camera Defines the camera to attach the behavior to
  94094. */
  94095. attach(camera: ArcRotateCamera): void;
  94096. /**
  94097. * Detaches the behavior from its current arc rotate camera.
  94098. */
  94099. detach(): void;
  94100. private _animatables;
  94101. private _betaIsAnimating;
  94102. private _betaTransition;
  94103. private _radiusTransition;
  94104. private _vectorTransition;
  94105. /**
  94106. * Targets the given mesh and updates zoom level accordingly.
  94107. * @param mesh The mesh to target.
  94108. * @param radius Optional. If a cached radius position already exists, overrides default.
  94109. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94110. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94111. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94112. */
  94113. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94114. /**
  94115. * Targets the given mesh with its children and updates zoom level accordingly.
  94116. * @param mesh The mesh to target.
  94117. * @param radius Optional. If a cached radius position already exists, overrides default.
  94118. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94119. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94120. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94121. */
  94122. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94123. /**
  94124. * Targets the given meshes with their children and updates zoom level accordingly.
  94125. * @param meshes The mesh to target.
  94126. * @param radius Optional. If a cached radius position already exists, overrides default.
  94127. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  94128. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94129. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94130. */
  94131. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94132. /**
  94133. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  94134. * @param minimumWorld Determines the smaller position of the bounding box extend
  94135. * @param maximumWorld Determines the bigger position of the bounding box extend
  94136. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  94137. * @param onAnimationEnd Callback triggered at the end of the framing animation
  94138. */
  94139. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  94140. /**
  94141. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  94142. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  94143. * frustum width.
  94144. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  94145. * to fully enclose the mesh in the viewing frustum.
  94146. */
  94147. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  94148. /**
  94149. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  94150. * is automatically returned to its default position (expected to be above ground plane).
  94151. */
  94152. private _maintainCameraAboveGround;
  94153. /**
  94154. * Returns the frustum slope based on the canvas ratio and camera FOV
  94155. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  94156. */
  94157. private _getFrustumSlope;
  94158. /**
  94159. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  94160. */
  94161. private _clearAnimationLocks;
  94162. /**
  94163. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94164. */
  94165. private _applyUserInteraction;
  94166. /**
  94167. * Stops and removes all animations that have been applied to the camera
  94168. */
  94169. stopAllAnimations(): void;
  94170. /**
  94171. * Gets a value indicating if the user is moving the camera
  94172. */
  94173. readonly isUserIsMoving: boolean;
  94174. /**
  94175. * The camera can move all the way towards the mesh.
  94176. */
  94177. static IgnoreBoundsSizeMode: number;
  94178. /**
  94179. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  94180. */
  94181. static FitFrustumSidesMode: number;
  94182. }
  94183. }
  94184. declare module BABYLON {
  94185. /**
  94186. * Base class for Camera Pointer Inputs.
  94187. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  94188. * for example usage.
  94189. */
  94190. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  94191. /**
  94192. * Defines the camera the input is attached to.
  94193. */
  94194. abstract camera: Camera;
  94195. /**
  94196. * Whether keyboard modifier keys are pressed at time of last mouse event.
  94197. */
  94198. protected _altKey: boolean;
  94199. protected _ctrlKey: boolean;
  94200. protected _metaKey: boolean;
  94201. protected _shiftKey: boolean;
  94202. /**
  94203. * Which mouse buttons were pressed at time of last mouse event.
  94204. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  94205. */
  94206. protected _buttonsPressed: number;
  94207. /**
  94208. * Defines the buttons associated with the input to handle camera move.
  94209. */
  94210. buttons: number[];
  94211. /**
  94212. * Attach the input controls to a specific dom element to get the input from.
  94213. * @param element Defines the element the controls should be listened from
  94214. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94215. */
  94216. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94217. /**
  94218. * Detach the current controls from the specified dom element.
  94219. * @param element Defines the element to stop listening the inputs from
  94220. */
  94221. detachControl(element: Nullable<HTMLElement>): void;
  94222. /**
  94223. * Gets the class name of the current input.
  94224. * @returns the class name
  94225. */
  94226. getClassName(): string;
  94227. /**
  94228. * Get the friendly name associated with the input class.
  94229. * @returns the input friendly name
  94230. */
  94231. getSimpleName(): string;
  94232. /**
  94233. * Called on pointer POINTERDOUBLETAP event.
  94234. * Override this method to provide functionality on POINTERDOUBLETAP event.
  94235. */
  94236. protected onDoubleTap(type: string): void;
  94237. /**
  94238. * Called on pointer POINTERMOVE event if only a single touch is active.
  94239. * Override this method to provide functionality.
  94240. */
  94241. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94242. /**
  94243. * Called on pointer POINTERMOVE event if multiple touches are active.
  94244. * Override this method to provide functionality.
  94245. */
  94246. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94247. /**
  94248. * Called on JS contextmenu event.
  94249. * Override this method to provide functionality.
  94250. */
  94251. protected onContextMenu(evt: PointerEvent): void;
  94252. /**
  94253. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94254. * press.
  94255. * Override this method to provide functionality.
  94256. */
  94257. protected onButtonDown(evt: PointerEvent): void;
  94258. /**
  94259. * Called each time a new POINTERUP event occurs. Ie, for each button
  94260. * release.
  94261. * Override this method to provide functionality.
  94262. */
  94263. protected onButtonUp(evt: PointerEvent): void;
  94264. /**
  94265. * Called when window becomes inactive.
  94266. * Override this method to provide functionality.
  94267. */
  94268. protected onLostFocus(): void;
  94269. private _pointerInput;
  94270. private _observer;
  94271. private _onLostFocus;
  94272. private pointA;
  94273. private pointB;
  94274. }
  94275. }
  94276. declare module BABYLON {
  94277. /**
  94278. * Manage the pointers inputs to control an arc rotate camera.
  94279. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94280. */
  94281. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  94282. /**
  94283. * Defines the camera the input is attached to.
  94284. */
  94285. camera: ArcRotateCamera;
  94286. /**
  94287. * Gets the class name of the current input.
  94288. * @returns the class name
  94289. */
  94290. getClassName(): string;
  94291. /**
  94292. * Defines the buttons associated with the input to handle camera move.
  94293. */
  94294. buttons: number[];
  94295. /**
  94296. * Defines the pointer angular sensibility along the X axis or how fast is
  94297. * the camera rotating.
  94298. */
  94299. angularSensibilityX: number;
  94300. /**
  94301. * Defines the pointer angular sensibility along the Y axis or how fast is
  94302. * the camera rotating.
  94303. */
  94304. angularSensibilityY: number;
  94305. /**
  94306. * Defines the pointer pinch precision or how fast is the camera zooming.
  94307. */
  94308. pinchPrecision: number;
  94309. /**
  94310. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  94311. * from 0.
  94312. * It defines the percentage of current camera.radius to use as delta when
  94313. * pinch zoom is used.
  94314. */
  94315. pinchDeltaPercentage: number;
  94316. /**
  94317. * Defines the pointer panning sensibility or how fast is the camera moving.
  94318. */
  94319. panningSensibility: number;
  94320. /**
  94321. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  94322. */
  94323. multiTouchPanning: boolean;
  94324. /**
  94325. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  94326. * zoom (pinch) through multitouch.
  94327. */
  94328. multiTouchPanAndZoom: boolean;
  94329. /**
  94330. * Revers pinch action direction.
  94331. */
  94332. pinchInwards: boolean;
  94333. private _isPanClick;
  94334. private _twoFingerActivityCount;
  94335. private _isPinching;
  94336. /**
  94337. * Called on pointer POINTERMOVE event if only a single touch is active.
  94338. */
  94339. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  94340. /**
  94341. * Called on pointer POINTERDOUBLETAP event.
  94342. */
  94343. protected onDoubleTap(type: string): void;
  94344. /**
  94345. * Called on pointer POINTERMOVE event if multiple touches are active.
  94346. */
  94347. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  94348. /**
  94349. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  94350. * press.
  94351. */
  94352. protected onButtonDown(evt: PointerEvent): void;
  94353. /**
  94354. * Called each time a new POINTERUP event occurs. Ie, for each button
  94355. * release.
  94356. */
  94357. protected onButtonUp(evt: PointerEvent): void;
  94358. /**
  94359. * Called when window becomes inactive.
  94360. */
  94361. protected onLostFocus(): void;
  94362. }
  94363. }
  94364. declare module BABYLON {
  94365. /**
  94366. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  94367. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94368. */
  94369. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  94370. /**
  94371. * Defines the camera the input is attached to.
  94372. */
  94373. camera: ArcRotateCamera;
  94374. /**
  94375. * Defines the list of key codes associated with the up action (increase alpha)
  94376. */
  94377. keysUp: number[];
  94378. /**
  94379. * Defines the list of key codes associated with the down action (decrease alpha)
  94380. */
  94381. keysDown: number[];
  94382. /**
  94383. * Defines the list of key codes associated with the left action (increase beta)
  94384. */
  94385. keysLeft: number[];
  94386. /**
  94387. * Defines the list of key codes associated with the right action (decrease beta)
  94388. */
  94389. keysRight: number[];
  94390. /**
  94391. * Defines the list of key codes associated with the reset action.
  94392. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  94393. */
  94394. keysReset: number[];
  94395. /**
  94396. * Defines the panning sensibility of the inputs.
  94397. * (How fast is the camera paning)
  94398. */
  94399. panningSensibility: number;
  94400. /**
  94401. * Defines the zooming sensibility of the inputs.
  94402. * (How fast is the camera zooming)
  94403. */
  94404. zoomingSensibility: number;
  94405. /**
  94406. * Defines wether maintaining the alt key down switch the movement mode from
  94407. * orientation to zoom.
  94408. */
  94409. useAltToZoom: boolean;
  94410. /**
  94411. * Rotation speed of the camera
  94412. */
  94413. angularSpeed: number;
  94414. private _keys;
  94415. private _ctrlPressed;
  94416. private _altPressed;
  94417. private _onCanvasBlurObserver;
  94418. private _onKeyboardObserver;
  94419. private _engine;
  94420. private _scene;
  94421. /**
  94422. * Attach the input controls to a specific dom element to get the input from.
  94423. * @param element Defines the element the controls should be listened from
  94424. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94425. */
  94426. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94427. /**
  94428. * Detach the current controls from the specified dom element.
  94429. * @param element Defines the element to stop listening the inputs from
  94430. */
  94431. detachControl(element: Nullable<HTMLElement>): void;
  94432. /**
  94433. * Update the current camera state depending on the inputs that have been used this frame.
  94434. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  94435. */
  94436. checkInputs(): void;
  94437. /**
  94438. * Gets the class name of the current intput.
  94439. * @returns the class name
  94440. */
  94441. getClassName(): string;
  94442. /**
  94443. * Get the friendly name associated with the input class.
  94444. * @returns the input friendly name
  94445. */
  94446. getSimpleName(): string;
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /**
  94451. * Manage the mouse wheel inputs to control an arc rotate camera.
  94452. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94453. */
  94454. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  94455. /**
  94456. * Defines the camera the input is attached to.
  94457. */
  94458. camera: ArcRotateCamera;
  94459. /**
  94460. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94461. */
  94462. wheelPrecision: number;
  94463. /**
  94464. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  94465. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  94466. */
  94467. wheelDeltaPercentage: number;
  94468. private _wheel;
  94469. private _observer;
  94470. /**
  94471. * Attach the input controls to a specific dom element to get the input from.
  94472. * @param element Defines the element the controls should be listened from
  94473. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94474. */
  94475. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  94476. /**
  94477. * Detach the current controls from the specified dom element.
  94478. * @param element Defines the element to stop listening the inputs from
  94479. */
  94480. detachControl(element: Nullable<HTMLElement>): void;
  94481. /**
  94482. * Gets the class name of the current intput.
  94483. * @returns the class name
  94484. */
  94485. getClassName(): string;
  94486. /**
  94487. * Get the friendly name associated with the input class.
  94488. * @returns the input friendly name
  94489. */
  94490. getSimpleName(): string;
  94491. }
  94492. }
  94493. declare module BABYLON {
  94494. /**
  94495. * Default Inputs manager for the ArcRotateCamera.
  94496. * It groups all the default supported inputs for ease of use.
  94497. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  94498. */
  94499. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  94500. /**
  94501. * Instantiates a new ArcRotateCameraInputsManager.
  94502. * @param camera Defines the camera the inputs belong to
  94503. */
  94504. constructor(camera: ArcRotateCamera);
  94505. /**
  94506. * Add mouse wheel input support to the input manager.
  94507. * @returns the current input manager
  94508. */
  94509. addMouseWheel(): ArcRotateCameraInputsManager;
  94510. /**
  94511. * Add pointers input support to the input manager.
  94512. * @returns the current input manager
  94513. */
  94514. addPointers(): ArcRotateCameraInputsManager;
  94515. /**
  94516. * Add keyboard input support to the input manager.
  94517. * @returns the current input manager
  94518. */
  94519. addKeyboard(): ArcRotateCameraInputsManager;
  94520. }
  94521. }
  94522. declare module BABYLON {
  94523. /**
  94524. * This represents an orbital type of camera.
  94525. *
  94526. * 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.
  94527. * 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.
  94528. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  94529. */
  94530. export class ArcRotateCamera extends TargetCamera {
  94531. /**
  94532. * Defines the rotation angle of the camera along the longitudinal axis.
  94533. */
  94534. alpha: number;
  94535. /**
  94536. * Defines the rotation angle of the camera along the latitudinal axis.
  94537. */
  94538. beta: number;
  94539. /**
  94540. * Defines the radius of the camera from it s target point.
  94541. */
  94542. radius: number;
  94543. protected _target: Vector3;
  94544. protected _targetHost: Nullable<AbstractMesh>;
  94545. /**
  94546. * Defines the target point of the camera.
  94547. * The camera looks towards it form the radius distance.
  94548. */
  94549. target: Vector3;
  94550. /**
  94551. * Define the current local position of the camera in the scene
  94552. */
  94553. position: Vector3;
  94554. protected _upVector: Vector3;
  94555. protected _upToYMatrix: Matrix;
  94556. protected _YToUpMatrix: Matrix;
  94557. /**
  94558. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  94559. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  94560. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  94561. */
  94562. upVector: Vector3;
  94563. /**
  94564. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  94565. */
  94566. setMatUp(): void;
  94567. /**
  94568. * Current inertia value on the longitudinal axis.
  94569. * The bigger this number the longer it will take for the camera to stop.
  94570. */
  94571. inertialAlphaOffset: number;
  94572. /**
  94573. * Current inertia value on the latitudinal axis.
  94574. * The bigger this number the longer it will take for the camera to stop.
  94575. */
  94576. inertialBetaOffset: number;
  94577. /**
  94578. * Current inertia value on the radius axis.
  94579. * The bigger this number the longer it will take for the camera to stop.
  94580. */
  94581. inertialRadiusOffset: number;
  94582. /**
  94583. * Minimum allowed angle on the longitudinal axis.
  94584. * This can help limiting how the Camera is able to move in the scene.
  94585. */
  94586. lowerAlphaLimit: Nullable<number>;
  94587. /**
  94588. * Maximum allowed angle on the longitudinal axis.
  94589. * This can help limiting how the Camera is able to move in the scene.
  94590. */
  94591. upperAlphaLimit: Nullable<number>;
  94592. /**
  94593. * Minimum allowed angle on the latitudinal axis.
  94594. * This can help limiting how the Camera is able to move in the scene.
  94595. */
  94596. lowerBetaLimit: number;
  94597. /**
  94598. * Maximum allowed angle on the latitudinal axis.
  94599. * This can help limiting how the Camera is able to move in the scene.
  94600. */
  94601. upperBetaLimit: number;
  94602. /**
  94603. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  94604. * This can help limiting how the Camera is able to move in the scene.
  94605. */
  94606. lowerRadiusLimit: Nullable<number>;
  94607. /**
  94608. * Maximum allowed distance of the camera to the target (The camera can not get further).
  94609. * This can help limiting how the Camera is able to move in the scene.
  94610. */
  94611. upperRadiusLimit: Nullable<number>;
  94612. /**
  94613. * Defines the current inertia value used during panning of the camera along the X axis.
  94614. */
  94615. inertialPanningX: number;
  94616. /**
  94617. * Defines the current inertia value used during panning of the camera along the Y axis.
  94618. */
  94619. inertialPanningY: number;
  94620. /**
  94621. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  94622. * Basically if your fingers moves away from more than this distance you will be considered
  94623. * in pinch mode.
  94624. */
  94625. pinchToPanMaxDistance: number;
  94626. /**
  94627. * Defines the maximum distance the camera can pan.
  94628. * This could help keeping the cammera always in your scene.
  94629. */
  94630. panningDistanceLimit: Nullable<number>;
  94631. /**
  94632. * Defines the target of the camera before paning.
  94633. */
  94634. panningOriginTarget: Vector3;
  94635. /**
  94636. * Defines the value of the inertia used during panning.
  94637. * 0 would mean stop inertia and one would mean no decelleration at all.
  94638. */
  94639. panningInertia: number;
  94640. /**
  94641. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  94642. */
  94643. angularSensibilityX: number;
  94644. /**
  94645. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  94646. */
  94647. angularSensibilityY: number;
  94648. /**
  94649. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  94650. */
  94651. pinchPrecision: number;
  94652. /**
  94653. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  94654. * It will be used instead of pinchDeltaPrecision if different from 0.
  94655. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94656. */
  94657. pinchDeltaPercentage: number;
  94658. /**
  94659. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  94660. */
  94661. panningSensibility: number;
  94662. /**
  94663. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  94664. */
  94665. keysUp: number[];
  94666. /**
  94667. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  94668. */
  94669. keysDown: number[];
  94670. /**
  94671. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  94672. */
  94673. keysLeft: number[];
  94674. /**
  94675. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  94676. */
  94677. keysRight: number[];
  94678. /**
  94679. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  94680. */
  94681. wheelPrecision: number;
  94682. /**
  94683. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  94684. * It will be used instead of pinchDeltaPrecision if different from 0.
  94685. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  94686. */
  94687. wheelDeltaPercentage: number;
  94688. /**
  94689. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  94690. */
  94691. zoomOnFactor: number;
  94692. /**
  94693. * Defines a screen offset for the camera position.
  94694. */
  94695. targetScreenOffset: Vector2;
  94696. /**
  94697. * Allows the camera to be completely reversed.
  94698. * If false the camera can not arrive upside down.
  94699. */
  94700. allowUpsideDown: boolean;
  94701. /**
  94702. * Define if double tap/click is used to restore the previously saved state of the camera.
  94703. */
  94704. useInputToRestoreState: boolean;
  94705. /** @hidden */
  94706. _viewMatrix: Matrix;
  94707. /** @hidden */
  94708. _useCtrlForPanning: boolean;
  94709. /** @hidden */
  94710. _panningMouseButton: number;
  94711. /**
  94712. * Defines the input associated to the camera.
  94713. */
  94714. inputs: ArcRotateCameraInputsManager;
  94715. /** @hidden */
  94716. _reset: () => void;
  94717. /**
  94718. * Defines the allowed panning axis.
  94719. */
  94720. panningAxis: Vector3;
  94721. protected _localDirection: Vector3;
  94722. protected _transformedDirection: Vector3;
  94723. private _bouncingBehavior;
  94724. /**
  94725. * Gets the bouncing behavior of the camera if it has been enabled.
  94726. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94727. */
  94728. readonly bouncingBehavior: Nullable<BouncingBehavior>;
  94729. /**
  94730. * Defines if the bouncing behavior of the camera is enabled on the camera.
  94731. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  94732. */
  94733. useBouncingBehavior: boolean;
  94734. private _framingBehavior;
  94735. /**
  94736. * Gets the framing behavior of the camera if it has been enabled.
  94737. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94738. */
  94739. readonly framingBehavior: Nullable<FramingBehavior>;
  94740. /**
  94741. * Defines if the framing behavior of the camera is enabled on the camera.
  94742. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  94743. */
  94744. useFramingBehavior: boolean;
  94745. private _autoRotationBehavior;
  94746. /**
  94747. * Gets the auto rotation behavior of the camera if it has been enabled.
  94748. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94749. */
  94750. readonly autoRotationBehavior: Nullable<AutoRotationBehavior>;
  94751. /**
  94752. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  94753. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94754. */
  94755. useAutoRotationBehavior: boolean;
  94756. /**
  94757. * Observable triggered when the mesh target has been changed on the camera.
  94758. */
  94759. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  94760. /**
  94761. * Event raised when the camera is colliding with a mesh.
  94762. */
  94763. onCollide: (collidedMesh: AbstractMesh) => void;
  94764. /**
  94765. * Defines whether the camera should check collision with the objects oh the scene.
  94766. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  94767. */
  94768. checkCollisions: boolean;
  94769. /**
  94770. * Defines the collision radius of the camera.
  94771. * This simulates a sphere around the camera.
  94772. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  94773. */
  94774. collisionRadius: Vector3;
  94775. protected _collider: Collider;
  94776. protected _previousPosition: Vector3;
  94777. protected _collisionVelocity: Vector3;
  94778. protected _newPosition: Vector3;
  94779. protected _previousAlpha: number;
  94780. protected _previousBeta: number;
  94781. protected _previousRadius: number;
  94782. protected _collisionTriggered: boolean;
  94783. protected _targetBoundingCenter: Nullable<Vector3>;
  94784. private _computationVector;
  94785. /**
  94786. * Instantiates a new ArcRotateCamera in a given scene
  94787. * @param name Defines the name of the camera
  94788. * @param alpha Defines the camera rotation along the logitudinal axis
  94789. * @param beta Defines the camera rotation along the latitudinal axis
  94790. * @param radius Defines the camera distance from its target
  94791. * @param target Defines the camera target
  94792. * @param scene Defines the scene the camera belongs to
  94793. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  94794. */
  94795. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  94796. /** @hidden */
  94797. _initCache(): void;
  94798. /** @hidden */
  94799. _updateCache(ignoreParentClass?: boolean): void;
  94800. protected _getTargetPosition(): Vector3;
  94801. private _storedAlpha;
  94802. private _storedBeta;
  94803. private _storedRadius;
  94804. private _storedTarget;
  94805. /**
  94806. * Stores the current state of the camera (alpha, beta, radius and target)
  94807. * @returns the camera itself
  94808. */
  94809. storeState(): Camera;
  94810. /**
  94811. * @hidden
  94812. * Restored camera state. You must call storeState() first
  94813. */
  94814. _restoreStateValues(): boolean;
  94815. /** @hidden */
  94816. _isSynchronizedViewMatrix(): boolean;
  94817. /**
  94818. * Attached controls to the current camera.
  94819. * @param element Defines the element the controls should be listened from
  94820. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  94821. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  94822. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  94823. */
  94824. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  94825. /**
  94826. * Detach the current controls from the camera.
  94827. * The camera will stop reacting to inputs.
  94828. * @param element Defines the element to stop listening the inputs from
  94829. */
  94830. detachControl(element: HTMLElement): void;
  94831. /** @hidden */
  94832. _checkInputs(): void;
  94833. protected _checkLimits(): void;
  94834. /**
  94835. * Rebuilds angles (alpha, beta) and radius from the give position and target
  94836. */
  94837. rebuildAnglesAndRadius(): void;
  94838. /**
  94839. * Use a position to define the current camera related information like aplha, beta and radius
  94840. * @param position Defines the position to set the camera at
  94841. */
  94842. setPosition(position: Vector3): void;
  94843. /**
  94844. * Defines the target the camera should look at.
  94845. * This will automatically adapt alpha beta and radius to fit within the new target.
  94846. * @param target Defines the new target as a Vector or a mesh
  94847. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  94848. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  94849. */
  94850. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  94851. /** @hidden */
  94852. _getViewMatrix(): Matrix;
  94853. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  94854. /**
  94855. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  94856. * @param meshes Defines the mesh to zoom on
  94857. * @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)
  94858. */
  94859. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  94860. /**
  94861. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  94862. * The target will be changed but the radius
  94863. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  94864. * @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)
  94865. */
  94866. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  94867. min: Vector3;
  94868. max: Vector3;
  94869. distance: number;
  94870. }, doNotUpdateMaxZ?: boolean): void;
  94871. /**
  94872. * @override
  94873. * Override Camera.createRigCamera
  94874. */
  94875. createRigCamera(name: string, cameraIndex: number): Camera;
  94876. /**
  94877. * @hidden
  94878. * @override
  94879. * Override Camera._updateRigCameras
  94880. */
  94881. _updateRigCameras(): void;
  94882. /**
  94883. * Destroy the camera and release the current resources hold by it.
  94884. */
  94885. dispose(): void;
  94886. /**
  94887. * Gets the current object class name.
  94888. * @return the class name
  94889. */
  94890. getClassName(): string;
  94891. }
  94892. }
  94893. declare module BABYLON {
  94894. /**
  94895. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  94896. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  94897. */
  94898. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  94899. /**
  94900. * Gets the name of the behavior.
  94901. */
  94902. readonly name: string;
  94903. private _zoomStopsAnimation;
  94904. private _idleRotationSpeed;
  94905. private _idleRotationWaitTime;
  94906. private _idleRotationSpinupTime;
  94907. /**
  94908. * Sets the flag that indicates if user zooming should stop animation.
  94909. */
  94910. /**
  94911. * Gets the flag that indicates if user zooming should stop animation.
  94912. */
  94913. zoomStopsAnimation: boolean;
  94914. /**
  94915. * Sets the default speed at which the camera rotates around the model.
  94916. */
  94917. /**
  94918. * Gets the default speed at which the camera rotates around the model.
  94919. */
  94920. idleRotationSpeed: number;
  94921. /**
  94922. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  94923. */
  94924. /**
  94925. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  94926. */
  94927. idleRotationWaitTime: number;
  94928. /**
  94929. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94930. */
  94931. /**
  94932. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  94933. */
  94934. idleRotationSpinupTime: number;
  94935. /**
  94936. * Gets a value indicating if the camera is currently rotating because of this behavior
  94937. */
  94938. readonly rotationInProgress: boolean;
  94939. private _onPrePointerObservableObserver;
  94940. private _onAfterCheckInputsObserver;
  94941. private _attachedCamera;
  94942. private _isPointerDown;
  94943. private _lastFrameTime;
  94944. private _lastInteractionTime;
  94945. private _cameraRotationSpeed;
  94946. /**
  94947. * Initializes the behavior.
  94948. */
  94949. init(): void;
  94950. /**
  94951. * Attaches the behavior to its arc rotate camera.
  94952. * @param camera Defines the camera to attach the behavior to
  94953. */
  94954. attach(camera: ArcRotateCamera): void;
  94955. /**
  94956. * Detaches the behavior from its current arc rotate camera.
  94957. */
  94958. detach(): void;
  94959. /**
  94960. * Returns true if user is scrolling.
  94961. * @return true if user is scrolling.
  94962. */
  94963. private _userIsZooming;
  94964. private _lastFrameRadius;
  94965. private _shouldAnimationStopForInteraction;
  94966. /**
  94967. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  94968. */
  94969. private _applyUserInteraction;
  94970. private _userIsMoving;
  94971. }
  94972. }
  94973. declare module BABYLON {
  94974. /**
  94975. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  94976. */
  94977. export class AttachToBoxBehavior implements Behavior<Mesh> {
  94978. private ui;
  94979. /**
  94980. * The name of the behavior
  94981. */
  94982. name: string;
  94983. /**
  94984. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  94985. */
  94986. distanceAwayFromFace: number;
  94987. /**
  94988. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  94989. */
  94990. distanceAwayFromBottomOfFace: number;
  94991. private _faceVectors;
  94992. private _target;
  94993. private _scene;
  94994. private _onRenderObserver;
  94995. private _tmpMatrix;
  94996. private _tmpVector;
  94997. /**
  94998. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  94999. * @param ui The transform node that should be attched to the mesh
  95000. */
  95001. constructor(ui: TransformNode);
  95002. /**
  95003. * Initializes the behavior
  95004. */
  95005. init(): void;
  95006. private _closestFace;
  95007. private _zeroVector;
  95008. private _lookAtTmpMatrix;
  95009. private _lookAtToRef;
  95010. /**
  95011. * Attaches the AttachToBoxBehavior to the passed in mesh
  95012. * @param target The mesh that the specified node will be attached to
  95013. */
  95014. attach(target: Mesh): void;
  95015. /**
  95016. * Detaches the behavior from the mesh
  95017. */
  95018. detach(): void;
  95019. }
  95020. }
  95021. declare module BABYLON {
  95022. /**
  95023. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  95024. */
  95025. export class FadeInOutBehavior implements Behavior<Mesh> {
  95026. /**
  95027. * Time in milliseconds to delay before fading in (Default: 0)
  95028. */
  95029. delay: number;
  95030. /**
  95031. * Time in milliseconds for the mesh to fade in (Default: 300)
  95032. */
  95033. fadeInTime: number;
  95034. private _millisecondsPerFrame;
  95035. private _hovered;
  95036. private _hoverValue;
  95037. private _ownerNode;
  95038. /**
  95039. * Instatiates the FadeInOutBehavior
  95040. */
  95041. constructor();
  95042. /**
  95043. * The name of the behavior
  95044. */
  95045. readonly name: string;
  95046. /**
  95047. * Initializes the behavior
  95048. */
  95049. init(): void;
  95050. /**
  95051. * Attaches the fade behavior on the passed in mesh
  95052. * @param ownerNode The mesh that will be faded in/out once attached
  95053. */
  95054. attach(ownerNode: Mesh): void;
  95055. /**
  95056. * Detaches the behavior from the mesh
  95057. */
  95058. detach(): void;
  95059. /**
  95060. * Triggers the mesh to begin fading in or out
  95061. * @param value if the object should fade in or out (true to fade in)
  95062. */
  95063. fadeIn(value: boolean): void;
  95064. private _update;
  95065. private _setAllVisibility;
  95066. }
  95067. }
  95068. declare module BABYLON {
  95069. /**
  95070. * Class containing a set of static utilities functions for managing Pivots
  95071. * @hidden
  95072. */
  95073. export class PivotTools {
  95074. private static _PivotCached;
  95075. private static _OldPivotPoint;
  95076. private static _PivotTranslation;
  95077. private static _PivotTmpVector;
  95078. /** @hidden */
  95079. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  95080. /** @hidden */
  95081. static _RestorePivotPoint(mesh: AbstractMesh): void;
  95082. }
  95083. }
  95084. declare module BABYLON {
  95085. /**
  95086. * Class containing static functions to help procedurally build meshes
  95087. */
  95088. export class PlaneBuilder {
  95089. /**
  95090. * Creates a plane mesh
  95091. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  95092. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  95093. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  95094. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  95095. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  95096. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  95097. * @param name defines the name of the mesh
  95098. * @param options defines the options used to create the mesh
  95099. * @param scene defines the hosting scene
  95100. * @returns the plane mesh
  95101. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  95102. */
  95103. static CreatePlane(name: string, options: {
  95104. size?: number;
  95105. width?: number;
  95106. height?: number;
  95107. sideOrientation?: number;
  95108. frontUVs?: Vector4;
  95109. backUVs?: Vector4;
  95110. updatable?: boolean;
  95111. sourcePlane?: Plane;
  95112. }, scene?: Nullable<Scene>): Mesh;
  95113. }
  95114. }
  95115. declare module BABYLON {
  95116. /**
  95117. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  95118. */
  95119. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  95120. private static _AnyMouseID;
  95121. private _attachedNode;
  95122. private _dragPlane;
  95123. private _scene;
  95124. private _pointerObserver;
  95125. private _beforeRenderObserver;
  95126. private static _planeScene;
  95127. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  95128. /**
  95129. * 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)
  95130. */
  95131. maxDragAngle: number;
  95132. /**
  95133. * @hidden
  95134. */
  95135. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  95136. /**
  95137. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95138. */
  95139. currentDraggingPointerID: number;
  95140. /**
  95141. * The last position where the pointer hit the drag plane in world space
  95142. */
  95143. lastDragPosition: Vector3;
  95144. /**
  95145. * If the behavior is currently in a dragging state
  95146. */
  95147. dragging: boolean;
  95148. /**
  95149. * 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)
  95150. */
  95151. dragDeltaRatio: number;
  95152. /**
  95153. * If the drag plane orientation should be updated during the dragging (Default: true)
  95154. */
  95155. updateDragPlane: boolean;
  95156. private _debugMode;
  95157. private _moving;
  95158. /**
  95159. * Fires each time the attached mesh is dragged with the pointer
  95160. * * delta between last drag position and current drag position in world space
  95161. * * dragDistance along the drag axis
  95162. * * dragPlaneNormal normal of the current drag plane used during the drag
  95163. * * dragPlanePoint in world space where the drag intersects the drag plane
  95164. */
  95165. onDragObservable: Observable<{
  95166. delta: Vector3;
  95167. dragPlanePoint: Vector3;
  95168. dragPlaneNormal: Vector3;
  95169. dragDistance: number;
  95170. pointerId: number;
  95171. }>;
  95172. /**
  95173. * Fires each time a drag begins (eg. mouse down on mesh)
  95174. */
  95175. onDragStartObservable: Observable<{
  95176. dragPlanePoint: Vector3;
  95177. pointerId: number;
  95178. }>;
  95179. /**
  95180. * Fires each time a drag ends (eg. mouse release after drag)
  95181. */
  95182. onDragEndObservable: Observable<{
  95183. dragPlanePoint: Vector3;
  95184. pointerId: number;
  95185. }>;
  95186. /**
  95187. * If the attached mesh should be moved when dragged
  95188. */
  95189. moveAttached: boolean;
  95190. /**
  95191. * If the drag behavior will react to drag events (Default: true)
  95192. */
  95193. enabled: boolean;
  95194. /**
  95195. * If camera controls should be detached during the drag
  95196. */
  95197. detachCameraControls: boolean;
  95198. /**
  95199. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  95200. */
  95201. useObjectOrienationForDragging: boolean;
  95202. private _options;
  95203. /**
  95204. * Creates a pointer drag behavior that can be attached to a mesh
  95205. * @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)
  95206. */
  95207. constructor(options?: {
  95208. dragAxis?: Vector3;
  95209. dragPlaneNormal?: Vector3;
  95210. });
  95211. /**
  95212. * Predicate to determine if it is valid to move the object to a new position when it is moved
  95213. */
  95214. validateDrag: (targetPosition: Vector3) => boolean;
  95215. /**
  95216. * The name of the behavior
  95217. */
  95218. readonly name: string;
  95219. /**
  95220. * Initializes the behavior
  95221. */
  95222. init(): void;
  95223. private _tmpVector;
  95224. private _alternatePickedPoint;
  95225. private _worldDragAxis;
  95226. private _targetPosition;
  95227. private _attachedElement;
  95228. /**
  95229. * Attaches the drag behavior the passed in mesh
  95230. * @param ownerNode The mesh that will be dragged around once attached
  95231. */
  95232. attach(ownerNode: AbstractMesh): void;
  95233. /**
  95234. * Force relase the drag action by code.
  95235. */
  95236. releaseDrag(): void;
  95237. private _startDragRay;
  95238. private _lastPointerRay;
  95239. /**
  95240. * Simulates the start of a pointer drag event on the behavior
  95241. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  95242. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  95243. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  95244. */
  95245. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  95246. private _startDrag;
  95247. private _dragDelta;
  95248. private _moveDrag;
  95249. private _pickWithRayOnDragPlane;
  95250. private _pointA;
  95251. private _pointB;
  95252. private _pointC;
  95253. private _lineA;
  95254. private _lineB;
  95255. private _localAxis;
  95256. private _lookAt;
  95257. private _updateDragPlanePosition;
  95258. /**
  95259. * Detaches the behavior from the mesh
  95260. */
  95261. detach(): void;
  95262. }
  95263. }
  95264. declare module BABYLON {
  95265. /**
  95266. * A behavior that when attached to a mesh will allow the mesh to be scaled
  95267. */
  95268. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  95269. private _dragBehaviorA;
  95270. private _dragBehaviorB;
  95271. private _startDistance;
  95272. private _initialScale;
  95273. private _targetScale;
  95274. private _ownerNode;
  95275. private _sceneRenderObserver;
  95276. /**
  95277. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  95278. */
  95279. constructor();
  95280. /**
  95281. * The name of the behavior
  95282. */
  95283. readonly name: string;
  95284. /**
  95285. * Initializes the behavior
  95286. */
  95287. init(): void;
  95288. private _getCurrentDistance;
  95289. /**
  95290. * Attaches the scale behavior the passed in mesh
  95291. * @param ownerNode The mesh that will be scaled around once attached
  95292. */
  95293. attach(ownerNode: Mesh): void;
  95294. /**
  95295. * Detaches the behavior from the mesh
  95296. */
  95297. detach(): void;
  95298. }
  95299. }
  95300. declare module BABYLON {
  95301. /**
  95302. * 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
  95303. */
  95304. export class SixDofDragBehavior implements Behavior<Mesh> {
  95305. private static _virtualScene;
  95306. private _ownerNode;
  95307. private _sceneRenderObserver;
  95308. private _scene;
  95309. private _targetPosition;
  95310. private _virtualOriginMesh;
  95311. private _virtualDragMesh;
  95312. private _pointerObserver;
  95313. private _moving;
  95314. private _startingOrientation;
  95315. /**
  95316. * 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)
  95317. */
  95318. private zDragFactor;
  95319. /**
  95320. * If the object should rotate to face the drag origin
  95321. */
  95322. rotateDraggedObject: boolean;
  95323. /**
  95324. * If the behavior is currently in a dragging state
  95325. */
  95326. dragging: boolean;
  95327. /**
  95328. * 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)
  95329. */
  95330. dragDeltaRatio: number;
  95331. /**
  95332. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  95333. */
  95334. currentDraggingPointerID: number;
  95335. /**
  95336. * If camera controls should be detached during the drag
  95337. */
  95338. detachCameraControls: boolean;
  95339. /**
  95340. * Fires each time a drag starts
  95341. */
  95342. onDragStartObservable: Observable<{}>;
  95343. /**
  95344. * Fires each time a drag ends (eg. mouse release after drag)
  95345. */
  95346. onDragEndObservable: Observable<{}>;
  95347. /**
  95348. * 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
  95349. */
  95350. constructor();
  95351. /**
  95352. * The name of the behavior
  95353. */
  95354. readonly name: string;
  95355. /**
  95356. * Initializes the behavior
  95357. */
  95358. init(): void;
  95359. /**
  95360. * Attaches the scale behavior the passed in mesh
  95361. * @param ownerNode The mesh that will be scaled around once attached
  95362. */
  95363. attach(ownerNode: Mesh): void;
  95364. /**
  95365. * Detaches the behavior from the mesh
  95366. */
  95367. detach(): void;
  95368. }
  95369. }
  95370. declare module BABYLON {
  95371. /**
  95372. * Class used to apply inverse kinematics to bones
  95373. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  95374. */
  95375. export class BoneIKController {
  95376. private static _tmpVecs;
  95377. private static _tmpQuat;
  95378. private static _tmpMats;
  95379. /**
  95380. * Gets or sets the target mesh
  95381. */
  95382. targetMesh: AbstractMesh;
  95383. /** Gets or sets the mesh used as pole */
  95384. poleTargetMesh: AbstractMesh;
  95385. /**
  95386. * Gets or sets the bone used as pole
  95387. */
  95388. poleTargetBone: Nullable<Bone>;
  95389. /**
  95390. * Gets or sets the target position
  95391. */
  95392. targetPosition: Vector3;
  95393. /**
  95394. * Gets or sets the pole target position
  95395. */
  95396. poleTargetPosition: Vector3;
  95397. /**
  95398. * Gets or sets the pole target local offset
  95399. */
  95400. poleTargetLocalOffset: Vector3;
  95401. /**
  95402. * Gets or sets the pole angle
  95403. */
  95404. poleAngle: number;
  95405. /**
  95406. * Gets or sets the mesh associated with the controller
  95407. */
  95408. mesh: AbstractMesh;
  95409. /**
  95410. * 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)
  95411. */
  95412. slerpAmount: number;
  95413. private _bone1Quat;
  95414. private _bone1Mat;
  95415. private _bone2Ang;
  95416. private _bone1;
  95417. private _bone2;
  95418. private _bone1Length;
  95419. private _bone2Length;
  95420. private _maxAngle;
  95421. private _maxReach;
  95422. private _rightHandedSystem;
  95423. private _bendAxis;
  95424. private _slerping;
  95425. private _adjustRoll;
  95426. /**
  95427. * Gets or sets maximum allowed angle
  95428. */
  95429. maxAngle: number;
  95430. /**
  95431. * Creates a new BoneIKController
  95432. * @param mesh defines the mesh to control
  95433. * @param bone defines the bone to control
  95434. * @param options defines options to set up the controller
  95435. */
  95436. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  95437. targetMesh?: AbstractMesh;
  95438. poleTargetMesh?: AbstractMesh;
  95439. poleTargetBone?: Bone;
  95440. poleTargetLocalOffset?: Vector3;
  95441. poleAngle?: number;
  95442. bendAxis?: Vector3;
  95443. maxAngle?: number;
  95444. slerpAmount?: number;
  95445. });
  95446. private _setMaxAngle;
  95447. /**
  95448. * Force the controller to update the bones
  95449. */
  95450. update(): void;
  95451. }
  95452. }
  95453. declare module BABYLON {
  95454. /**
  95455. * Class used to make a bone look toward a point in space
  95456. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  95457. */
  95458. export class BoneLookController {
  95459. private static _tmpVecs;
  95460. private static _tmpQuat;
  95461. private static _tmpMats;
  95462. /**
  95463. * The target Vector3 that the bone will look at
  95464. */
  95465. target: Vector3;
  95466. /**
  95467. * The mesh that the bone is attached to
  95468. */
  95469. mesh: AbstractMesh;
  95470. /**
  95471. * The bone that will be looking to the target
  95472. */
  95473. bone: Bone;
  95474. /**
  95475. * The up axis of the coordinate system that is used when the bone is rotated
  95476. */
  95477. upAxis: Vector3;
  95478. /**
  95479. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  95480. */
  95481. upAxisSpace: Space;
  95482. /**
  95483. * Used to make an adjustment to the yaw of the bone
  95484. */
  95485. adjustYaw: number;
  95486. /**
  95487. * Used to make an adjustment to the pitch of the bone
  95488. */
  95489. adjustPitch: number;
  95490. /**
  95491. * Used to make an adjustment to the roll of the bone
  95492. */
  95493. adjustRoll: number;
  95494. /**
  95495. * 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)
  95496. */
  95497. slerpAmount: number;
  95498. private _minYaw;
  95499. private _maxYaw;
  95500. private _minPitch;
  95501. private _maxPitch;
  95502. private _minYawSin;
  95503. private _minYawCos;
  95504. private _maxYawSin;
  95505. private _maxYawCos;
  95506. private _midYawConstraint;
  95507. private _minPitchTan;
  95508. private _maxPitchTan;
  95509. private _boneQuat;
  95510. private _slerping;
  95511. private _transformYawPitch;
  95512. private _transformYawPitchInv;
  95513. private _firstFrameSkipped;
  95514. private _yawRange;
  95515. private _fowardAxis;
  95516. /**
  95517. * Gets or sets the minimum yaw angle that the bone can look to
  95518. */
  95519. minYaw: number;
  95520. /**
  95521. * Gets or sets the maximum yaw angle that the bone can look to
  95522. */
  95523. maxYaw: number;
  95524. /**
  95525. * Gets or sets the minimum pitch angle that the bone can look to
  95526. */
  95527. minPitch: number;
  95528. /**
  95529. * Gets or sets the maximum pitch angle that the bone can look to
  95530. */
  95531. maxPitch: number;
  95532. /**
  95533. * Create a BoneLookController
  95534. * @param mesh the mesh that the bone belongs to
  95535. * @param bone the bone that will be looking to the target
  95536. * @param target the target Vector3 to look at
  95537. * @param options optional settings:
  95538. * * maxYaw: the maximum angle the bone will yaw to
  95539. * * minYaw: the minimum angle the bone will yaw to
  95540. * * maxPitch: the maximum angle the bone will pitch to
  95541. * * minPitch: the minimum angle the bone will yaw to
  95542. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  95543. * * upAxis: the up axis of the coordinate system
  95544. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  95545. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  95546. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  95547. * * adjustYaw: used to make an adjustment to the yaw of the bone
  95548. * * adjustPitch: used to make an adjustment to the pitch of the bone
  95549. * * adjustRoll: used to make an adjustment to the roll of the bone
  95550. **/
  95551. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  95552. maxYaw?: number;
  95553. minYaw?: number;
  95554. maxPitch?: number;
  95555. minPitch?: number;
  95556. slerpAmount?: number;
  95557. upAxis?: Vector3;
  95558. upAxisSpace?: Space;
  95559. yawAxis?: Vector3;
  95560. pitchAxis?: Vector3;
  95561. adjustYaw?: number;
  95562. adjustPitch?: number;
  95563. adjustRoll?: number;
  95564. });
  95565. /**
  95566. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  95567. */
  95568. update(): void;
  95569. private _getAngleDiff;
  95570. private _getAngleBetween;
  95571. private _isAngleBetween;
  95572. }
  95573. }
  95574. declare module BABYLON {
  95575. /**
  95576. * Manage the gamepad inputs to control an arc rotate camera.
  95577. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95578. */
  95579. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  95580. /**
  95581. * Defines the camera the input is attached to.
  95582. */
  95583. camera: ArcRotateCamera;
  95584. /**
  95585. * Defines the gamepad the input is gathering event from.
  95586. */
  95587. gamepad: Nullable<Gamepad>;
  95588. /**
  95589. * Defines the gamepad rotation sensiblity.
  95590. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  95591. */
  95592. gamepadRotationSensibility: number;
  95593. /**
  95594. * Defines the gamepad move sensiblity.
  95595. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  95596. */
  95597. gamepadMoveSensibility: number;
  95598. private _onGamepadConnectedObserver;
  95599. private _onGamepadDisconnectedObserver;
  95600. /**
  95601. * Attach the input controls to a specific dom element to get the input from.
  95602. * @param element Defines the element the controls should be listened from
  95603. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95604. */
  95605. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95606. /**
  95607. * Detach the current controls from the specified dom element.
  95608. * @param element Defines the element to stop listening the inputs from
  95609. */
  95610. detachControl(element: Nullable<HTMLElement>): void;
  95611. /**
  95612. * Update the current camera state depending on the inputs that have been used this frame.
  95613. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95614. */
  95615. checkInputs(): void;
  95616. /**
  95617. * Gets the class name of the current intput.
  95618. * @returns the class name
  95619. */
  95620. getClassName(): string;
  95621. /**
  95622. * Get the friendly name associated with the input class.
  95623. * @returns the input friendly name
  95624. */
  95625. getSimpleName(): string;
  95626. }
  95627. }
  95628. declare module BABYLON {
  95629. interface ArcRotateCameraInputsManager {
  95630. /**
  95631. * Add orientation input support to the input manager.
  95632. * @returns the current input manager
  95633. */
  95634. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  95635. }
  95636. /**
  95637. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  95638. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95639. */
  95640. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  95641. /**
  95642. * Defines the camera the input is attached to.
  95643. */
  95644. camera: ArcRotateCamera;
  95645. /**
  95646. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  95647. */
  95648. alphaCorrection: number;
  95649. /**
  95650. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  95651. */
  95652. gammaCorrection: number;
  95653. private _alpha;
  95654. private _gamma;
  95655. private _dirty;
  95656. private _deviceOrientationHandler;
  95657. /**
  95658. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  95659. */
  95660. constructor();
  95661. /**
  95662. * Attach the input controls to a specific dom element to get the input from.
  95663. * @param element Defines the element the controls should be listened from
  95664. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  95665. */
  95666. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95667. /** @hidden */
  95668. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  95669. /**
  95670. * Update the current camera state depending on the inputs that have been used this frame.
  95671. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  95672. */
  95673. checkInputs(): void;
  95674. /**
  95675. * Detach the current controls from the specified dom element.
  95676. * @param element Defines the element to stop listening the inputs from
  95677. */
  95678. detachControl(element: Nullable<HTMLElement>): void;
  95679. /**
  95680. * Gets the class name of the current intput.
  95681. * @returns the class name
  95682. */
  95683. getClassName(): string;
  95684. /**
  95685. * Get the friendly name associated with the input class.
  95686. * @returns the input friendly name
  95687. */
  95688. getSimpleName(): string;
  95689. }
  95690. }
  95691. declare module BABYLON {
  95692. /**
  95693. * Listen to mouse events to control the camera.
  95694. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95695. */
  95696. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  95697. /**
  95698. * Defines the camera the input is attached to.
  95699. */
  95700. camera: FlyCamera;
  95701. /**
  95702. * Defines if touch is enabled. (Default is true.)
  95703. */
  95704. touchEnabled: boolean;
  95705. /**
  95706. * Defines the buttons associated with the input to handle camera rotation.
  95707. */
  95708. buttons: number[];
  95709. /**
  95710. * Assign buttons for Yaw control.
  95711. */
  95712. buttonsYaw: number[];
  95713. /**
  95714. * Assign buttons for Pitch control.
  95715. */
  95716. buttonsPitch: number[];
  95717. /**
  95718. * Assign buttons for Roll control.
  95719. */
  95720. buttonsRoll: number[];
  95721. /**
  95722. * Detect if any button is being pressed while mouse is moved.
  95723. * -1 = Mouse locked.
  95724. * 0 = Left button.
  95725. * 1 = Middle Button.
  95726. * 2 = Right Button.
  95727. */
  95728. activeButton: number;
  95729. /**
  95730. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  95731. * Higher values reduce its sensitivity.
  95732. */
  95733. angularSensibility: number;
  95734. private _mousemoveCallback;
  95735. private _observer;
  95736. private _rollObserver;
  95737. private previousPosition;
  95738. private noPreventDefault;
  95739. private element;
  95740. /**
  95741. * Listen to mouse events to control the camera.
  95742. * @param touchEnabled Define if touch is enabled. (Default is true.)
  95743. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95744. */
  95745. constructor(touchEnabled?: boolean);
  95746. /**
  95747. * Attach the mouse control to the HTML DOM element.
  95748. * @param element Defines the element that listens to the input events.
  95749. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  95750. */
  95751. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95752. /**
  95753. * Detach the current controls from the specified dom element.
  95754. * @param element Defines the element to stop listening the inputs from
  95755. */
  95756. detachControl(element: Nullable<HTMLElement>): void;
  95757. /**
  95758. * Gets the class name of the current input.
  95759. * @returns the class name.
  95760. */
  95761. getClassName(): string;
  95762. /**
  95763. * Get the friendly name associated with the input class.
  95764. * @returns the input's friendly name.
  95765. */
  95766. getSimpleName(): string;
  95767. private _pointerInput;
  95768. private _onMouseMove;
  95769. /**
  95770. * Rotate camera by mouse offset.
  95771. */
  95772. private rotateCamera;
  95773. }
  95774. }
  95775. declare module BABYLON {
  95776. /**
  95777. * Default Inputs manager for the FlyCamera.
  95778. * It groups all the default supported inputs for ease of use.
  95779. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95780. */
  95781. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  95782. /**
  95783. * Instantiates a new FlyCameraInputsManager.
  95784. * @param camera Defines the camera the inputs belong to.
  95785. */
  95786. constructor(camera: FlyCamera);
  95787. /**
  95788. * Add keyboard input support to the input manager.
  95789. * @returns the new FlyCameraKeyboardMoveInput().
  95790. */
  95791. addKeyboard(): FlyCameraInputsManager;
  95792. /**
  95793. * Add mouse input support to the input manager.
  95794. * @param touchEnabled Enable touch screen support.
  95795. * @returns the new FlyCameraMouseInput().
  95796. */
  95797. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  95798. }
  95799. }
  95800. declare module BABYLON {
  95801. /**
  95802. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95803. * such as in a 3D Space Shooter or a Flight Simulator.
  95804. */
  95805. export class FlyCamera extends TargetCamera {
  95806. /**
  95807. * Define the collision ellipsoid of the camera.
  95808. * This is helpful for simulating a camera body, like a player's body.
  95809. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  95810. */
  95811. ellipsoid: Vector3;
  95812. /**
  95813. * Define an offset for the position of the ellipsoid around the camera.
  95814. * This can be helpful if the camera is attached away from the player's body center,
  95815. * such as at its head.
  95816. */
  95817. ellipsoidOffset: Vector3;
  95818. /**
  95819. * Enable or disable collisions of the camera with the rest of the scene objects.
  95820. */
  95821. checkCollisions: boolean;
  95822. /**
  95823. * Enable or disable gravity on the camera.
  95824. */
  95825. applyGravity: boolean;
  95826. /**
  95827. * Define the current direction the camera is moving to.
  95828. */
  95829. cameraDirection: Vector3;
  95830. /**
  95831. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  95832. * This overrides and empties cameraRotation.
  95833. */
  95834. rotationQuaternion: Quaternion;
  95835. /**
  95836. * Track Roll to maintain the wanted Rolling when looking around.
  95837. */
  95838. _trackRoll: number;
  95839. /**
  95840. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  95841. */
  95842. rollCorrect: number;
  95843. /**
  95844. * Mimic a banked turn, Rolling the camera when Yawing.
  95845. * It's recommended to use rollCorrect = 10 for faster banking correction.
  95846. */
  95847. bankedTurn: boolean;
  95848. /**
  95849. * Limit in radians for how much Roll banking will add. (Default: 90°)
  95850. */
  95851. bankedTurnLimit: number;
  95852. /**
  95853. * Value of 0 disables the banked Roll.
  95854. * Value of 1 is equal to the Yaw angle in radians.
  95855. */
  95856. bankedTurnMultiplier: number;
  95857. /**
  95858. * The inputs manager loads all the input sources, such as keyboard and mouse.
  95859. */
  95860. inputs: FlyCameraInputsManager;
  95861. /**
  95862. * Gets the input sensibility for mouse input.
  95863. * Higher values reduce sensitivity.
  95864. */
  95865. /**
  95866. * Sets the input sensibility for a mouse input.
  95867. * Higher values reduce sensitivity.
  95868. */
  95869. angularSensibility: number;
  95870. /**
  95871. * Get the keys for camera movement forward.
  95872. */
  95873. /**
  95874. * Set the keys for camera movement forward.
  95875. */
  95876. keysForward: number[];
  95877. /**
  95878. * Get the keys for camera movement backward.
  95879. */
  95880. keysBackward: number[];
  95881. /**
  95882. * Get the keys for camera movement up.
  95883. */
  95884. /**
  95885. * Set the keys for camera movement up.
  95886. */
  95887. keysUp: number[];
  95888. /**
  95889. * Get the keys for camera movement down.
  95890. */
  95891. /**
  95892. * Set the keys for camera movement down.
  95893. */
  95894. keysDown: number[];
  95895. /**
  95896. * Get the keys for camera movement left.
  95897. */
  95898. /**
  95899. * Set the keys for camera movement left.
  95900. */
  95901. keysLeft: number[];
  95902. /**
  95903. * Set the keys for camera movement right.
  95904. */
  95905. /**
  95906. * Set the keys for camera movement right.
  95907. */
  95908. keysRight: number[];
  95909. /**
  95910. * Event raised when the camera collides with a mesh in the scene.
  95911. */
  95912. onCollide: (collidedMesh: AbstractMesh) => void;
  95913. private _collider;
  95914. private _needMoveForGravity;
  95915. private _oldPosition;
  95916. private _diffPosition;
  95917. private _newPosition;
  95918. /** @hidden */
  95919. _localDirection: Vector3;
  95920. /** @hidden */
  95921. _transformedDirection: Vector3;
  95922. /**
  95923. * Instantiates a FlyCamera.
  95924. * This is a flying camera, designed for 3D movement and rotation in all directions,
  95925. * such as in a 3D Space Shooter or a Flight Simulator.
  95926. * @param name Define the name of the camera in the scene.
  95927. * @param position Define the starting position of the camera in the scene.
  95928. * @param scene Define the scene the camera belongs to.
  95929. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  95930. */
  95931. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  95932. /**
  95933. * Attach a control to the HTML DOM element.
  95934. * @param element Defines the element that listens to the input events.
  95935. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  95936. */
  95937. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  95938. /**
  95939. * Detach a control from the HTML DOM element.
  95940. * The camera will stop reacting to that input.
  95941. * @param element Defines the element that listens to the input events.
  95942. */
  95943. detachControl(element: HTMLElement): void;
  95944. private _collisionMask;
  95945. /**
  95946. * Get the mask that the camera ignores in collision events.
  95947. */
  95948. /**
  95949. * Set the mask that the camera ignores in collision events.
  95950. */
  95951. collisionMask: number;
  95952. /** @hidden */
  95953. _collideWithWorld(displacement: Vector3): void;
  95954. /** @hidden */
  95955. private _onCollisionPositionChange;
  95956. /** @hidden */
  95957. _checkInputs(): void;
  95958. /** @hidden */
  95959. _decideIfNeedsToMove(): boolean;
  95960. /** @hidden */
  95961. _updatePosition(): void;
  95962. /**
  95963. * Restore the Roll to its target value at the rate specified.
  95964. * @param rate - Higher means slower restoring.
  95965. * @hidden
  95966. */
  95967. restoreRoll(rate: number): void;
  95968. /**
  95969. * Destroy the camera and release the current resources held by it.
  95970. */
  95971. dispose(): void;
  95972. /**
  95973. * Get the current object class name.
  95974. * @returns the class name.
  95975. */
  95976. getClassName(): string;
  95977. }
  95978. }
  95979. declare module BABYLON {
  95980. /**
  95981. * Listen to keyboard events to control the camera.
  95982. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  95983. */
  95984. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  95985. /**
  95986. * Defines the camera the input is attached to.
  95987. */
  95988. camera: FlyCamera;
  95989. /**
  95990. * The list of keyboard keys used to control the forward move of the camera.
  95991. */
  95992. keysForward: number[];
  95993. /**
  95994. * The list of keyboard keys used to control the backward move of the camera.
  95995. */
  95996. keysBackward: number[];
  95997. /**
  95998. * The list of keyboard keys used to control the forward move of the camera.
  95999. */
  96000. keysUp: number[];
  96001. /**
  96002. * The list of keyboard keys used to control the backward move of the camera.
  96003. */
  96004. keysDown: number[];
  96005. /**
  96006. * The list of keyboard keys used to control the right strafe move of the camera.
  96007. */
  96008. keysRight: number[];
  96009. /**
  96010. * The list of keyboard keys used to control the left strafe move of the camera.
  96011. */
  96012. keysLeft: number[];
  96013. private _keys;
  96014. private _onCanvasBlurObserver;
  96015. private _onKeyboardObserver;
  96016. private _engine;
  96017. private _scene;
  96018. /**
  96019. * Attach the input controls to a specific dom element to get the input from.
  96020. * @param element Defines the element the controls should be listened from
  96021. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96022. */
  96023. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96024. /**
  96025. * Detach the current controls from the specified dom element.
  96026. * @param element Defines the element to stop listening the inputs from
  96027. */
  96028. detachControl(element: Nullable<HTMLElement>): void;
  96029. /**
  96030. * Gets the class name of the current intput.
  96031. * @returns the class name
  96032. */
  96033. getClassName(): string;
  96034. /** @hidden */
  96035. _onLostFocus(e: FocusEvent): void;
  96036. /**
  96037. * Get the friendly name associated with the input class.
  96038. * @returns the input friendly name
  96039. */
  96040. getSimpleName(): string;
  96041. /**
  96042. * Update the current camera state depending on the inputs that have been used this frame.
  96043. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96044. */
  96045. checkInputs(): void;
  96046. }
  96047. }
  96048. declare module BABYLON {
  96049. /**
  96050. * Manage the mouse wheel inputs to control a follow camera.
  96051. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96052. */
  96053. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  96054. /**
  96055. * Defines the camera the input is attached to.
  96056. */
  96057. camera: FollowCamera;
  96058. /**
  96059. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  96060. */
  96061. axisControlRadius: boolean;
  96062. /**
  96063. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  96064. */
  96065. axisControlHeight: boolean;
  96066. /**
  96067. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  96068. */
  96069. axisControlRotation: boolean;
  96070. /**
  96071. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  96072. * relation to mouseWheel events.
  96073. */
  96074. wheelPrecision: number;
  96075. /**
  96076. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  96077. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  96078. */
  96079. wheelDeltaPercentage: number;
  96080. private _wheel;
  96081. private _observer;
  96082. /**
  96083. * Attach the input controls to a specific dom element to get the input from.
  96084. * @param element Defines the element the controls should be listened from
  96085. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96086. */
  96087. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96088. /**
  96089. * Detach the current controls from the specified dom element.
  96090. * @param element Defines the element to stop listening the inputs from
  96091. */
  96092. detachControl(element: Nullable<HTMLElement>): void;
  96093. /**
  96094. * Gets the class name of the current intput.
  96095. * @returns the class name
  96096. */
  96097. getClassName(): string;
  96098. /**
  96099. * Get the friendly name associated with the input class.
  96100. * @returns the input friendly name
  96101. */
  96102. getSimpleName(): string;
  96103. }
  96104. }
  96105. declare module BABYLON {
  96106. /**
  96107. * Manage the pointers inputs to control an follow camera.
  96108. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96109. */
  96110. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  96111. /**
  96112. * Defines the camera the input is attached to.
  96113. */
  96114. camera: FollowCamera;
  96115. /**
  96116. * Gets the class name of the current input.
  96117. * @returns the class name
  96118. */
  96119. getClassName(): string;
  96120. /**
  96121. * Defines the pointer angular sensibility along the X axis or how fast is
  96122. * the camera rotating.
  96123. * A negative number will reverse the axis direction.
  96124. */
  96125. angularSensibilityX: number;
  96126. /**
  96127. * Defines the pointer angular sensibility along the Y axis or how fast is
  96128. * the camera rotating.
  96129. * A negative number will reverse the axis direction.
  96130. */
  96131. angularSensibilityY: number;
  96132. /**
  96133. * Defines the pointer pinch precision or how fast is the camera zooming.
  96134. * A negative number will reverse the axis direction.
  96135. */
  96136. pinchPrecision: number;
  96137. /**
  96138. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  96139. * from 0.
  96140. * It defines the percentage of current camera.radius to use as delta when
  96141. * pinch zoom is used.
  96142. */
  96143. pinchDeltaPercentage: number;
  96144. /**
  96145. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  96146. */
  96147. axisXControlRadius: boolean;
  96148. /**
  96149. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  96150. */
  96151. axisXControlHeight: boolean;
  96152. /**
  96153. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  96154. */
  96155. axisXControlRotation: boolean;
  96156. /**
  96157. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  96158. */
  96159. axisYControlRadius: boolean;
  96160. /**
  96161. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  96162. */
  96163. axisYControlHeight: boolean;
  96164. /**
  96165. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  96166. */
  96167. axisYControlRotation: boolean;
  96168. /**
  96169. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  96170. */
  96171. axisPinchControlRadius: boolean;
  96172. /**
  96173. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  96174. */
  96175. axisPinchControlHeight: boolean;
  96176. /**
  96177. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  96178. */
  96179. axisPinchControlRotation: boolean;
  96180. /**
  96181. * Log error messages if basic misconfiguration has occurred.
  96182. */
  96183. warningEnable: boolean;
  96184. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  96185. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  96186. private _warningCounter;
  96187. private _warning;
  96188. }
  96189. }
  96190. declare module BABYLON {
  96191. /**
  96192. * Default Inputs manager for the FollowCamera.
  96193. * It groups all the default supported inputs for ease of use.
  96194. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96195. */
  96196. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  96197. /**
  96198. * Instantiates a new FollowCameraInputsManager.
  96199. * @param camera Defines the camera the inputs belong to
  96200. */
  96201. constructor(camera: FollowCamera);
  96202. /**
  96203. * Add keyboard input support to the input manager.
  96204. * @returns the current input manager
  96205. */
  96206. addKeyboard(): FollowCameraInputsManager;
  96207. /**
  96208. * Add mouse wheel input support to the input manager.
  96209. * @returns the current input manager
  96210. */
  96211. addMouseWheel(): FollowCameraInputsManager;
  96212. /**
  96213. * Add pointers input support to the input manager.
  96214. * @returns the current input manager
  96215. */
  96216. addPointers(): FollowCameraInputsManager;
  96217. /**
  96218. * Add orientation input support to the input manager.
  96219. * @returns the current input manager
  96220. */
  96221. addVRDeviceOrientation(): FollowCameraInputsManager;
  96222. }
  96223. }
  96224. declare module BABYLON {
  96225. /**
  96226. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  96227. * an arc rotate version arcFollowCamera are available.
  96228. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96229. */
  96230. export class FollowCamera extends TargetCamera {
  96231. /**
  96232. * Distance the follow camera should follow an object at
  96233. */
  96234. radius: number;
  96235. /**
  96236. * Minimum allowed distance of the camera to the axis of rotation
  96237. * (The camera can not get closer).
  96238. * This can help limiting how the Camera is able to move in the scene.
  96239. */
  96240. lowerRadiusLimit: Nullable<number>;
  96241. /**
  96242. * Maximum allowed distance of the camera to the axis of rotation
  96243. * (The camera can not get further).
  96244. * This can help limiting how the Camera is able to move in the scene.
  96245. */
  96246. upperRadiusLimit: Nullable<number>;
  96247. /**
  96248. * Define a rotation offset between the camera and the object it follows
  96249. */
  96250. rotationOffset: number;
  96251. /**
  96252. * Minimum allowed angle to camera position relative to target object.
  96253. * This can help limiting how the Camera is able to move in the scene.
  96254. */
  96255. lowerRotationOffsetLimit: Nullable<number>;
  96256. /**
  96257. * Maximum allowed angle to camera position relative to target object.
  96258. * This can help limiting how the Camera is able to move in the scene.
  96259. */
  96260. upperRotationOffsetLimit: Nullable<number>;
  96261. /**
  96262. * Define a height offset between the camera and the object it follows.
  96263. * It can help following an object from the top (like a car chaing a plane)
  96264. */
  96265. heightOffset: number;
  96266. /**
  96267. * Minimum allowed height of camera position relative to target object.
  96268. * This can help limiting how the Camera is able to move in the scene.
  96269. */
  96270. lowerHeightOffsetLimit: Nullable<number>;
  96271. /**
  96272. * Maximum allowed height of camera position relative to target object.
  96273. * This can help limiting how the Camera is able to move in the scene.
  96274. */
  96275. upperHeightOffsetLimit: Nullable<number>;
  96276. /**
  96277. * Define how fast the camera can accelerate to follow it s target.
  96278. */
  96279. cameraAcceleration: number;
  96280. /**
  96281. * Define the speed limit of the camera following an object.
  96282. */
  96283. maxCameraSpeed: number;
  96284. /**
  96285. * Define the target of the camera.
  96286. */
  96287. lockedTarget: Nullable<AbstractMesh>;
  96288. /**
  96289. * Defines the input associated with the camera.
  96290. */
  96291. inputs: FollowCameraInputsManager;
  96292. /**
  96293. * Instantiates the follow camera.
  96294. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96295. * @param name Define the name of the camera in the scene
  96296. * @param position Define the position of the camera
  96297. * @param scene Define the scene the camera belong to
  96298. * @param lockedTarget Define the target of the camera
  96299. */
  96300. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  96301. private _follow;
  96302. /**
  96303. * Attached controls to the current camera.
  96304. * @param element Defines the element the controls should be listened from
  96305. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96306. */
  96307. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96308. /**
  96309. * Detach the current controls from the camera.
  96310. * The camera will stop reacting to inputs.
  96311. * @param element Defines the element to stop listening the inputs from
  96312. */
  96313. detachControl(element: HTMLElement): void;
  96314. /** @hidden */
  96315. _checkInputs(): void;
  96316. private _checkLimits;
  96317. /**
  96318. * Gets the camera class name.
  96319. * @returns the class name
  96320. */
  96321. getClassName(): string;
  96322. }
  96323. /**
  96324. * Arc Rotate version of the follow camera.
  96325. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  96326. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96327. */
  96328. export class ArcFollowCamera extends TargetCamera {
  96329. /** The longitudinal angle of the camera */
  96330. alpha: number;
  96331. /** The latitudinal angle of the camera */
  96332. beta: number;
  96333. /** The radius of the camera from its target */
  96334. radius: number;
  96335. /** Define the camera target (the messh it should follow) */
  96336. target: Nullable<AbstractMesh>;
  96337. private _cartesianCoordinates;
  96338. /**
  96339. * Instantiates a new ArcFollowCamera
  96340. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  96341. * @param name Define the name of the camera
  96342. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  96343. * @param beta Define the rotation angle of the camera around the elevation axis
  96344. * @param radius Define the radius of the camera from its target point
  96345. * @param target Define the target of the camera
  96346. * @param scene Define the scene the camera belongs to
  96347. */
  96348. constructor(name: string,
  96349. /** The longitudinal angle of the camera */
  96350. alpha: number,
  96351. /** The latitudinal angle of the camera */
  96352. beta: number,
  96353. /** The radius of the camera from its target */
  96354. radius: number,
  96355. /** Define the camera target (the messh it should follow) */
  96356. target: Nullable<AbstractMesh>, scene: Scene);
  96357. private _follow;
  96358. /** @hidden */
  96359. _checkInputs(): void;
  96360. /**
  96361. * Returns the class name of the object.
  96362. * It is mostly used internally for serialization purposes.
  96363. */
  96364. getClassName(): string;
  96365. }
  96366. }
  96367. declare module BABYLON {
  96368. /**
  96369. * Manage the keyboard inputs to control the movement of a follow camera.
  96370. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96371. */
  96372. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  96373. /**
  96374. * Defines the camera the input is attached to.
  96375. */
  96376. camera: FollowCamera;
  96377. /**
  96378. * Defines the list of key codes associated with the up action (increase heightOffset)
  96379. */
  96380. keysHeightOffsetIncr: number[];
  96381. /**
  96382. * Defines the list of key codes associated with the down action (decrease heightOffset)
  96383. */
  96384. keysHeightOffsetDecr: number[];
  96385. /**
  96386. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  96387. */
  96388. keysHeightOffsetModifierAlt: boolean;
  96389. /**
  96390. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  96391. */
  96392. keysHeightOffsetModifierCtrl: boolean;
  96393. /**
  96394. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  96395. */
  96396. keysHeightOffsetModifierShift: boolean;
  96397. /**
  96398. * Defines the list of key codes associated with the left action (increase rotationOffset)
  96399. */
  96400. keysRotationOffsetIncr: number[];
  96401. /**
  96402. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  96403. */
  96404. keysRotationOffsetDecr: number[];
  96405. /**
  96406. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  96407. */
  96408. keysRotationOffsetModifierAlt: boolean;
  96409. /**
  96410. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  96411. */
  96412. keysRotationOffsetModifierCtrl: boolean;
  96413. /**
  96414. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  96415. */
  96416. keysRotationOffsetModifierShift: boolean;
  96417. /**
  96418. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  96419. */
  96420. keysRadiusIncr: number[];
  96421. /**
  96422. * Defines the list of key codes associated with the zoom-out action (increase radius)
  96423. */
  96424. keysRadiusDecr: number[];
  96425. /**
  96426. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  96427. */
  96428. keysRadiusModifierAlt: boolean;
  96429. /**
  96430. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  96431. */
  96432. keysRadiusModifierCtrl: boolean;
  96433. /**
  96434. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  96435. */
  96436. keysRadiusModifierShift: boolean;
  96437. /**
  96438. * Defines the rate of change of heightOffset.
  96439. */
  96440. heightSensibility: number;
  96441. /**
  96442. * Defines the rate of change of rotationOffset.
  96443. */
  96444. rotationSensibility: number;
  96445. /**
  96446. * Defines the rate of change of radius.
  96447. */
  96448. radiusSensibility: number;
  96449. private _keys;
  96450. private _ctrlPressed;
  96451. private _altPressed;
  96452. private _shiftPressed;
  96453. private _onCanvasBlurObserver;
  96454. private _onKeyboardObserver;
  96455. private _engine;
  96456. private _scene;
  96457. /**
  96458. * Attach the input controls to a specific dom element to get the input from.
  96459. * @param element Defines the element the controls should be listened from
  96460. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96461. */
  96462. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96463. /**
  96464. * Detach the current controls from the specified dom element.
  96465. * @param element Defines the element to stop listening the inputs from
  96466. */
  96467. detachControl(element: Nullable<HTMLElement>): void;
  96468. /**
  96469. * Update the current camera state depending on the inputs that have been used this frame.
  96470. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96471. */
  96472. checkInputs(): void;
  96473. /**
  96474. * Gets the class name of the current input.
  96475. * @returns the class name
  96476. */
  96477. getClassName(): string;
  96478. /**
  96479. * Get the friendly name associated with the input class.
  96480. * @returns the input friendly name
  96481. */
  96482. getSimpleName(): string;
  96483. /**
  96484. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96485. * allow modification of the heightOffset value.
  96486. */
  96487. private _modifierHeightOffset;
  96488. /**
  96489. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96490. * allow modification of the rotationOffset value.
  96491. */
  96492. private _modifierRotationOffset;
  96493. /**
  96494. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  96495. * allow modification of the radius value.
  96496. */
  96497. private _modifierRadius;
  96498. }
  96499. }
  96500. declare module BABYLON {
  96501. interface FreeCameraInputsManager {
  96502. /**
  96503. * @hidden
  96504. */
  96505. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  96506. /**
  96507. * Add orientation input support to the input manager.
  96508. * @returns the current input manager
  96509. */
  96510. addDeviceOrientation(): FreeCameraInputsManager;
  96511. }
  96512. /**
  96513. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  96514. * Screen rotation is taken into account.
  96515. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96516. */
  96517. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  96518. private _camera;
  96519. private _screenOrientationAngle;
  96520. private _constantTranform;
  96521. private _screenQuaternion;
  96522. private _alpha;
  96523. private _beta;
  96524. private _gamma;
  96525. /**
  96526. * @hidden
  96527. */
  96528. _onDeviceOrientationChangedObservable: Observable<void>;
  96529. /**
  96530. * Instantiates a new input
  96531. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96532. */
  96533. constructor();
  96534. /**
  96535. * Define the camera controlled by the input.
  96536. */
  96537. camera: FreeCamera;
  96538. /**
  96539. * Attach the input controls to a specific dom element to get the input from.
  96540. * @param element Defines the element the controls should be listened from
  96541. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96542. */
  96543. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96544. private _orientationChanged;
  96545. private _deviceOrientation;
  96546. /**
  96547. * Detach the current controls from the specified dom element.
  96548. * @param element Defines the element to stop listening the inputs from
  96549. */
  96550. detachControl(element: Nullable<HTMLElement>): void;
  96551. /**
  96552. * Update the current camera state depending on the inputs that have been used this frame.
  96553. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96554. */
  96555. checkInputs(): void;
  96556. /**
  96557. * Gets the class name of the current intput.
  96558. * @returns the class name
  96559. */
  96560. getClassName(): string;
  96561. /**
  96562. * Get the friendly name associated with the input class.
  96563. * @returns the input friendly name
  96564. */
  96565. getSimpleName(): string;
  96566. }
  96567. }
  96568. declare module BABYLON {
  96569. /**
  96570. * Manage the gamepad inputs to control a free camera.
  96571. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96572. */
  96573. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  96574. /**
  96575. * Define the camera the input is attached to.
  96576. */
  96577. camera: FreeCamera;
  96578. /**
  96579. * Define the Gamepad controlling the input
  96580. */
  96581. gamepad: Nullable<Gamepad>;
  96582. /**
  96583. * Defines the gamepad rotation sensiblity.
  96584. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96585. */
  96586. gamepadAngularSensibility: number;
  96587. /**
  96588. * Defines the gamepad move sensiblity.
  96589. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96590. */
  96591. gamepadMoveSensibility: number;
  96592. private _onGamepadConnectedObserver;
  96593. private _onGamepadDisconnectedObserver;
  96594. private _cameraTransform;
  96595. private _deltaTransform;
  96596. private _vector3;
  96597. private _vector2;
  96598. /**
  96599. * Attach the input controls to a specific dom element to get the input from.
  96600. * @param element Defines the element the controls should be listened from
  96601. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96602. */
  96603. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96604. /**
  96605. * Detach the current controls from the specified dom element.
  96606. * @param element Defines the element to stop listening the inputs from
  96607. */
  96608. detachControl(element: Nullable<HTMLElement>): void;
  96609. /**
  96610. * Update the current camera state depending on the inputs that have been used this frame.
  96611. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96612. */
  96613. checkInputs(): void;
  96614. /**
  96615. * Gets the class name of the current intput.
  96616. * @returns the class name
  96617. */
  96618. getClassName(): string;
  96619. /**
  96620. * Get the friendly name associated with the input class.
  96621. * @returns the input friendly name
  96622. */
  96623. getSimpleName(): string;
  96624. }
  96625. }
  96626. declare module BABYLON {
  96627. /**
  96628. * Defines the potential axis of a Joystick
  96629. */
  96630. export enum JoystickAxis {
  96631. /** X axis */
  96632. X = 0,
  96633. /** Y axis */
  96634. Y = 1,
  96635. /** Z axis */
  96636. Z = 2
  96637. }
  96638. /**
  96639. * Class used to define virtual joystick (used in touch mode)
  96640. */
  96641. export class VirtualJoystick {
  96642. /**
  96643. * Gets or sets a boolean indicating that left and right values must be inverted
  96644. */
  96645. reverseLeftRight: boolean;
  96646. /**
  96647. * Gets or sets a boolean indicating that up and down values must be inverted
  96648. */
  96649. reverseUpDown: boolean;
  96650. /**
  96651. * Gets the offset value for the position (ie. the change of the position value)
  96652. */
  96653. deltaPosition: Vector3;
  96654. /**
  96655. * Gets a boolean indicating if the virtual joystick was pressed
  96656. */
  96657. pressed: boolean;
  96658. /**
  96659. * Canvas the virtual joystick will render onto, default z-index of this is 5
  96660. */
  96661. static Canvas: Nullable<HTMLCanvasElement>;
  96662. private static _globalJoystickIndex;
  96663. private static vjCanvasContext;
  96664. private static vjCanvasWidth;
  96665. private static vjCanvasHeight;
  96666. private static halfWidth;
  96667. private _action;
  96668. private _axisTargetedByLeftAndRight;
  96669. private _axisTargetedByUpAndDown;
  96670. private _joystickSensibility;
  96671. private _inversedSensibility;
  96672. private _joystickPointerID;
  96673. private _joystickColor;
  96674. private _joystickPointerPos;
  96675. private _joystickPreviousPointerPos;
  96676. private _joystickPointerStartPos;
  96677. private _deltaJoystickVector;
  96678. private _leftJoystick;
  96679. private _touches;
  96680. private _onPointerDownHandlerRef;
  96681. private _onPointerMoveHandlerRef;
  96682. private _onPointerUpHandlerRef;
  96683. private _onResize;
  96684. /**
  96685. * Creates a new virtual joystick
  96686. * @param leftJoystick defines that the joystick is for left hand (false by default)
  96687. */
  96688. constructor(leftJoystick?: boolean);
  96689. /**
  96690. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  96691. * @param newJoystickSensibility defines the new sensibility
  96692. */
  96693. setJoystickSensibility(newJoystickSensibility: number): void;
  96694. private _onPointerDown;
  96695. private _onPointerMove;
  96696. private _onPointerUp;
  96697. /**
  96698. * Change the color of the virtual joystick
  96699. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  96700. */
  96701. setJoystickColor(newColor: string): void;
  96702. /**
  96703. * Defines a callback to call when the joystick is touched
  96704. * @param action defines the callback
  96705. */
  96706. setActionOnTouch(action: () => any): void;
  96707. /**
  96708. * Defines which axis you'd like to control for left & right
  96709. * @param axis defines the axis to use
  96710. */
  96711. setAxisForLeftRight(axis: JoystickAxis): void;
  96712. /**
  96713. * Defines which axis you'd like to control for up & down
  96714. * @param axis defines the axis to use
  96715. */
  96716. setAxisForUpDown(axis: JoystickAxis): void;
  96717. private _drawVirtualJoystick;
  96718. /**
  96719. * Release internal HTML canvas
  96720. */
  96721. releaseCanvas(): void;
  96722. }
  96723. }
  96724. declare module BABYLON {
  96725. interface FreeCameraInputsManager {
  96726. /**
  96727. * Add virtual joystick input support to the input manager.
  96728. * @returns the current input manager
  96729. */
  96730. addVirtualJoystick(): FreeCameraInputsManager;
  96731. }
  96732. /**
  96733. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  96734. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  96735. */
  96736. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  96737. /**
  96738. * Defines the camera the input is attached to.
  96739. */
  96740. camera: FreeCamera;
  96741. private _leftjoystick;
  96742. private _rightjoystick;
  96743. /**
  96744. * Gets the left stick of the virtual joystick.
  96745. * @returns The virtual Joystick
  96746. */
  96747. getLeftJoystick(): VirtualJoystick;
  96748. /**
  96749. * Gets the right stick of the virtual joystick.
  96750. * @returns The virtual Joystick
  96751. */
  96752. getRightJoystick(): VirtualJoystick;
  96753. /**
  96754. * Update the current camera state depending on the inputs that have been used this frame.
  96755. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  96756. */
  96757. checkInputs(): void;
  96758. /**
  96759. * Attach the input controls to a specific dom element to get the input from.
  96760. * @param element Defines the element the controls should be listened from
  96761. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  96762. */
  96763. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  96764. /**
  96765. * Detach the current controls from the specified dom element.
  96766. * @param element Defines the element to stop listening the inputs from
  96767. */
  96768. detachControl(element: Nullable<HTMLElement>): void;
  96769. /**
  96770. * Gets the class name of the current intput.
  96771. * @returns the class name
  96772. */
  96773. getClassName(): string;
  96774. /**
  96775. * Get the friendly name associated with the input class.
  96776. * @returns the input friendly name
  96777. */
  96778. getSimpleName(): string;
  96779. }
  96780. }
  96781. declare module BABYLON {
  96782. /**
  96783. * This represents a FPS type of camera controlled by touch.
  96784. * This is like a universal camera minus the Gamepad controls.
  96785. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96786. */
  96787. export class TouchCamera extends FreeCamera {
  96788. /**
  96789. * Defines the touch sensibility for rotation.
  96790. * The higher the faster.
  96791. */
  96792. touchAngularSensibility: number;
  96793. /**
  96794. * Defines the touch sensibility for move.
  96795. * The higher the faster.
  96796. */
  96797. touchMoveSensibility: number;
  96798. /**
  96799. * Instantiates a new touch camera.
  96800. * This represents a FPS type of camera controlled by touch.
  96801. * This is like a universal camera minus the Gamepad controls.
  96802. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96803. * @param name Define the name of the camera in the scene
  96804. * @param position Define the start position of the camera in the scene
  96805. * @param scene Define the scene the camera belongs to
  96806. */
  96807. constructor(name: string, position: Vector3, scene: Scene);
  96808. /**
  96809. * Gets the current object class name.
  96810. * @return the class name
  96811. */
  96812. getClassName(): string;
  96813. /** @hidden */
  96814. _setupInputs(): void;
  96815. }
  96816. }
  96817. declare module BABYLON {
  96818. /**
  96819. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  96820. * being tilted forward or back and left or right.
  96821. */
  96822. export class DeviceOrientationCamera extends FreeCamera {
  96823. private _initialQuaternion;
  96824. private _quaternionCache;
  96825. private _tmpDragQuaternion;
  96826. /**
  96827. * Creates a new device orientation camera
  96828. * @param name The name of the camera
  96829. * @param position The start position camera
  96830. * @param scene The scene the camera belongs to
  96831. */
  96832. constructor(name: string, position: Vector3, scene: Scene);
  96833. /**
  96834. * @hidden
  96835. * Disabled pointer input on first orientation sensor update (Default: true)
  96836. */
  96837. _disablePointerInputWhenUsingDeviceOrientation: boolean;
  96838. private _dragFactor;
  96839. /**
  96840. * Enabled turning on the y axis when the orientation sensor is active
  96841. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  96842. */
  96843. enableHorizontalDragging(dragFactor?: number): void;
  96844. /**
  96845. * Gets the current instance class name ("DeviceOrientationCamera").
  96846. * This helps avoiding instanceof at run time.
  96847. * @returns the class name
  96848. */
  96849. getClassName(): string;
  96850. /**
  96851. * @hidden
  96852. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  96853. */
  96854. _checkInputs(): void;
  96855. /**
  96856. * Reset the camera to its default orientation on the specified axis only.
  96857. * @param axis The axis to reset
  96858. */
  96859. resetToCurrentRotation(axis?: Axis): void;
  96860. }
  96861. }
  96862. declare module BABYLON {
  96863. /**
  96864. * 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,
  96865. * which still works and will still be found in many Playgrounds.
  96866. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96867. */
  96868. export class UniversalCamera extends TouchCamera {
  96869. /**
  96870. * Defines the gamepad rotation sensiblity.
  96871. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  96872. */
  96873. gamepadAngularSensibility: number;
  96874. /**
  96875. * Defines the gamepad move sensiblity.
  96876. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  96877. */
  96878. gamepadMoveSensibility: number;
  96879. /**
  96880. * 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,
  96881. * which still works and will still be found in many Playgrounds.
  96882. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96883. * @param name Define the name of the camera in the scene
  96884. * @param position Define the start position of the camera in the scene
  96885. * @param scene Define the scene the camera belongs to
  96886. */
  96887. constructor(name: string, position: Vector3, scene: Scene);
  96888. /**
  96889. * Gets the current object class name.
  96890. * @return the class name
  96891. */
  96892. getClassName(): string;
  96893. }
  96894. }
  96895. declare module BABYLON {
  96896. /**
  96897. * This represents a FPS type of camera. This is only here for back compat purpose.
  96898. * Please use the UniversalCamera instead as both are identical.
  96899. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96900. */
  96901. export class GamepadCamera extends UniversalCamera {
  96902. /**
  96903. * Instantiates a new Gamepad Camera
  96904. * This represents a FPS type of camera. This is only here for back compat purpose.
  96905. * Please use the UniversalCamera instead as both are identical.
  96906. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  96907. * @param name Define the name of the camera in the scene
  96908. * @param position Define the start position of the camera in the scene
  96909. * @param scene Define the scene the camera belongs to
  96910. */
  96911. constructor(name: string, position: Vector3, scene: Scene);
  96912. /**
  96913. * Gets the current object class name.
  96914. * @return the class name
  96915. */
  96916. getClassName(): string;
  96917. }
  96918. }
  96919. declare module BABYLON {
  96920. /** @hidden */
  96921. export var passPixelShader: {
  96922. name: string;
  96923. shader: string;
  96924. };
  96925. }
  96926. declare module BABYLON {
  96927. /** @hidden */
  96928. export var passCubePixelShader: {
  96929. name: string;
  96930. shader: string;
  96931. };
  96932. }
  96933. declare module BABYLON {
  96934. /**
  96935. * PassPostProcess which produces an output the same as it's input
  96936. */
  96937. export class PassPostProcess extends PostProcess {
  96938. /**
  96939. * Creates the PassPostProcess
  96940. * @param name The name of the effect.
  96941. * @param options The required width/height ratio to downsize to before computing the render pass.
  96942. * @param camera The camera to apply the render pass to.
  96943. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96944. * @param engine The engine which the post process will be applied. (default: current engine)
  96945. * @param reusable If the post process can be reused on the same frame. (default: false)
  96946. * @param textureType The type of texture to be used when performing the post processing.
  96947. * @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)
  96948. */
  96949. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96950. }
  96951. /**
  96952. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  96953. */
  96954. export class PassCubePostProcess extends PostProcess {
  96955. private _face;
  96956. /**
  96957. * Gets or sets the cube face to display.
  96958. * * 0 is +X
  96959. * * 1 is -X
  96960. * * 2 is +Y
  96961. * * 3 is -Y
  96962. * * 4 is +Z
  96963. * * 5 is -Z
  96964. */
  96965. face: number;
  96966. /**
  96967. * Creates the PassCubePostProcess
  96968. * @param name The name of the effect.
  96969. * @param options The required width/height ratio to downsize to before computing the render pass.
  96970. * @param camera The camera to apply the render pass to.
  96971. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  96972. * @param engine The engine which the post process will be applied. (default: current engine)
  96973. * @param reusable If the post process can be reused on the same frame. (default: false)
  96974. * @param textureType The type of texture to be used when performing the post processing.
  96975. * @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)
  96976. */
  96977. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  96978. }
  96979. }
  96980. declare module BABYLON {
  96981. /** @hidden */
  96982. export var anaglyphPixelShader: {
  96983. name: string;
  96984. shader: string;
  96985. };
  96986. }
  96987. declare module BABYLON {
  96988. /**
  96989. * Postprocess used to generate anaglyphic rendering
  96990. */
  96991. export class AnaglyphPostProcess extends PostProcess {
  96992. private _passedProcess;
  96993. /**
  96994. * Creates a new AnaglyphPostProcess
  96995. * @param name defines postprocess name
  96996. * @param options defines creation options or target ratio scale
  96997. * @param rigCameras defines cameras using this postprocess
  96998. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  96999. * @param engine defines hosting engine
  97000. * @param reusable defines if the postprocess will be reused multiple times per frame
  97001. */
  97002. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  97003. }
  97004. }
  97005. declare module BABYLON {
  97006. /**
  97007. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  97008. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97009. */
  97010. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  97011. /**
  97012. * Creates a new AnaglyphArcRotateCamera
  97013. * @param name defines camera name
  97014. * @param alpha defines alpha angle (in radians)
  97015. * @param beta defines beta angle (in radians)
  97016. * @param radius defines radius
  97017. * @param target defines camera target
  97018. * @param interaxialDistance defines distance between each color axis
  97019. * @param scene defines the hosting scene
  97020. */
  97021. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  97022. /**
  97023. * Gets camera class name
  97024. * @returns AnaglyphArcRotateCamera
  97025. */
  97026. getClassName(): string;
  97027. }
  97028. }
  97029. declare module BABYLON {
  97030. /**
  97031. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  97032. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97033. */
  97034. export class AnaglyphFreeCamera extends FreeCamera {
  97035. /**
  97036. * Creates a new AnaglyphFreeCamera
  97037. * @param name defines camera name
  97038. * @param position defines initial position
  97039. * @param interaxialDistance defines distance between each color axis
  97040. * @param scene defines the hosting scene
  97041. */
  97042. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97043. /**
  97044. * Gets camera class name
  97045. * @returns AnaglyphFreeCamera
  97046. */
  97047. getClassName(): string;
  97048. }
  97049. }
  97050. declare module BABYLON {
  97051. /**
  97052. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  97053. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97054. */
  97055. export class AnaglyphGamepadCamera extends GamepadCamera {
  97056. /**
  97057. * Creates a new AnaglyphGamepadCamera
  97058. * @param name defines camera name
  97059. * @param position defines initial position
  97060. * @param interaxialDistance defines distance between each color axis
  97061. * @param scene defines the hosting scene
  97062. */
  97063. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97064. /**
  97065. * Gets camera class name
  97066. * @returns AnaglyphGamepadCamera
  97067. */
  97068. getClassName(): string;
  97069. }
  97070. }
  97071. declare module BABYLON {
  97072. /**
  97073. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  97074. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  97075. */
  97076. export class AnaglyphUniversalCamera extends UniversalCamera {
  97077. /**
  97078. * Creates a new AnaglyphUniversalCamera
  97079. * @param name defines camera name
  97080. * @param position defines initial position
  97081. * @param interaxialDistance defines distance between each color axis
  97082. * @param scene defines the hosting scene
  97083. */
  97084. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  97085. /**
  97086. * Gets camera class name
  97087. * @returns AnaglyphUniversalCamera
  97088. */
  97089. getClassName(): string;
  97090. }
  97091. }
  97092. declare module BABYLON {
  97093. /** @hidden */
  97094. export var stereoscopicInterlacePixelShader: {
  97095. name: string;
  97096. shader: string;
  97097. };
  97098. }
  97099. declare module BABYLON {
  97100. /**
  97101. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  97102. */
  97103. export class StereoscopicInterlacePostProcess extends PostProcess {
  97104. private _stepSize;
  97105. private _passedProcess;
  97106. /**
  97107. * Initializes a StereoscopicInterlacePostProcess
  97108. * @param name The name of the effect.
  97109. * @param rigCameras The rig cameras to be appled to the post process
  97110. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  97111. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  97112. * @param engine The engine which the post process will be applied. (default: current engine)
  97113. * @param reusable If the post process can be reused on the same frame. (default: false)
  97114. */
  97115. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  97116. }
  97117. }
  97118. declare module BABYLON {
  97119. /**
  97120. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  97121. * @see http://doc.babylonjs.com/features/cameras
  97122. */
  97123. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  97124. /**
  97125. * Creates a new StereoscopicArcRotateCamera
  97126. * @param name defines camera name
  97127. * @param alpha defines alpha angle (in radians)
  97128. * @param beta defines beta angle (in radians)
  97129. * @param radius defines radius
  97130. * @param target defines camera target
  97131. * @param interaxialDistance defines distance between each color axis
  97132. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97133. * @param scene defines the hosting scene
  97134. */
  97135. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97136. /**
  97137. * Gets camera class name
  97138. * @returns StereoscopicArcRotateCamera
  97139. */
  97140. getClassName(): string;
  97141. }
  97142. }
  97143. declare module BABYLON {
  97144. /**
  97145. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  97146. * @see http://doc.babylonjs.com/features/cameras
  97147. */
  97148. export class StereoscopicFreeCamera extends FreeCamera {
  97149. /**
  97150. * Creates a new StereoscopicFreeCamera
  97151. * @param name defines camera name
  97152. * @param position defines initial position
  97153. * @param interaxialDistance defines distance between each color axis
  97154. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97155. * @param scene defines the hosting scene
  97156. */
  97157. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97158. /**
  97159. * Gets camera class name
  97160. * @returns StereoscopicFreeCamera
  97161. */
  97162. getClassName(): string;
  97163. }
  97164. }
  97165. declare module BABYLON {
  97166. /**
  97167. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  97168. * @see http://doc.babylonjs.com/features/cameras
  97169. */
  97170. export class StereoscopicGamepadCamera extends GamepadCamera {
  97171. /**
  97172. * Creates a new StereoscopicGamepadCamera
  97173. * @param name defines camera name
  97174. * @param position defines initial position
  97175. * @param interaxialDistance defines distance between each color axis
  97176. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97177. * @param scene defines the hosting scene
  97178. */
  97179. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97180. /**
  97181. * Gets camera class name
  97182. * @returns StereoscopicGamepadCamera
  97183. */
  97184. getClassName(): string;
  97185. }
  97186. }
  97187. declare module BABYLON {
  97188. /**
  97189. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  97190. * @see http://doc.babylonjs.com/features/cameras
  97191. */
  97192. export class StereoscopicUniversalCamera extends UniversalCamera {
  97193. /**
  97194. * Creates a new StereoscopicUniversalCamera
  97195. * @param name defines camera name
  97196. * @param position defines initial position
  97197. * @param interaxialDistance defines distance between each color axis
  97198. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  97199. * @param scene defines the hosting scene
  97200. */
  97201. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  97202. /**
  97203. * Gets camera class name
  97204. * @returns StereoscopicUniversalCamera
  97205. */
  97206. getClassName(): string;
  97207. }
  97208. }
  97209. declare module BABYLON {
  97210. /**
  97211. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  97212. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97213. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97214. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97215. */
  97216. export class VirtualJoysticksCamera extends FreeCamera {
  97217. /**
  97218. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  97219. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  97220. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  97221. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  97222. * @param name Define the name of the camera in the scene
  97223. * @param position Define the start position of the camera in the scene
  97224. * @param scene Define the scene the camera belongs to
  97225. */
  97226. constructor(name: string, position: Vector3, scene: Scene);
  97227. /**
  97228. * Gets the current object class name.
  97229. * @return the class name
  97230. */
  97231. getClassName(): string;
  97232. }
  97233. }
  97234. declare module BABYLON {
  97235. /**
  97236. * This represents all the required metrics to create a VR camera.
  97237. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  97238. */
  97239. export class VRCameraMetrics {
  97240. /**
  97241. * Define the horizontal resolution off the screen.
  97242. */
  97243. hResolution: number;
  97244. /**
  97245. * Define the vertical resolution off the screen.
  97246. */
  97247. vResolution: number;
  97248. /**
  97249. * Define the horizontal screen size.
  97250. */
  97251. hScreenSize: number;
  97252. /**
  97253. * Define the vertical screen size.
  97254. */
  97255. vScreenSize: number;
  97256. /**
  97257. * Define the vertical screen center position.
  97258. */
  97259. vScreenCenter: number;
  97260. /**
  97261. * Define the distance of the eyes to the screen.
  97262. */
  97263. eyeToScreenDistance: number;
  97264. /**
  97265. * Define the distance between both lenses
  97266. */
  97267. lensSeparationDistance: number;
  97268. /**
  97269. * Define the distance between both viewer's eyes.
  97270. */
  97271. interpupillaryDistance: number;
  97272. /**
  97273. * Define the distortion factor of the VR postprocess.
  97274. * Please, touch with care.
  97275. */
  97276. distortionK: number[];
  97277. /**
  97278. * Define the chromatic aberration correction factors for the VR post process.
  97279. */
  97280. chromaAbCorrection: number[];
  97281. /**
  97282. * Define the scale factor of the post process.
  97283. * The smaller the better but the slower.
  97284. */
  97285. postProcessScaleFactor: number;
  97286. /**
  97287. * Define an offset for the lens center.
  97288. */
  97289. lensCenterOffset: number;
  97290. /**
  97291. * Define if the current vr camera should compensate the distortion of the lense or not.
  97292. */
  97293. compensateDistortion: boolean;
  97294. /**
  97295. * Defines if multiview should be enabled when rendering (Default: false)
  97296. */
  97297. multiviewEnabled: boolean;
  97298. /**
  97299. * Gets the rendering aspect ratio based on the provided resolutions.
  97300. */
  97301. readonly aspectRatio: number;
  97302. /**
  97303. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  97304. */
  97305. readonly aspectRatioFov: number;
  97306. /**
  97307. * @hidden
  97308. */
  97309. readonly leftHMatrix: Matrix;
  97310. /**
  97311. * @hidden
  97312. */
  97313. readonly rightHMatrix: Matrix;
  97314. /**
  97315. * @hidden
  97316. */
  97317. readonly leftPreViewMatrix: Matrix;
  97318. /**
  97319. * @hidden
  97320. */
  97321. readonly rightPreViewMatrix: Matrix;
  97322. /**
  97323. * Get the default VRMetrics based on the most generic setup.
  97324. * @returns the default vr metrics
  97325. */
  97326. static GetDefault(): VRCameraMetrics;
  97327. }
  97328. }
  97329. declare module BABYLON {
  97330. /** @hidden */
  97331. export var vrDistortionCorrectionPixelShader: {
  97332. name: string;
  97333. shader: string;
  97334. };
  97335. }
  97336. declare module BABYLON {
  97337. /**
  97338. * VRDistortionCorrectionPostProcess used for mobile VR
  97339. */
  97340. export class VRDistortionCorrectionPostProcess extends PostProcess {
  97341. private _isRightEye;
  97342. private _distortionFactors;
  97343. private _postProcessScaleFactor;
  97344. private _lensCenterOffset;
  97345. private _scaleIn;
  97346. private _scaleFactor;
  97347. private _lensCenter;
  97348. /**
  97349. * Initializes the VRDistortionCorrectionPostProcess
  97350. * @param name The name of the effect.
  97351. * @param camera The camera to apply the render pass to.
  97352. * @param isRightEye If this is for the right eye distortion
  97353. * @param vrMetrics All the required metrics for the VR camera
  97354. */
  97355. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  97356. }
  97357. }
  97358. declare module BABYLON {
  97359. /**
  97360. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  97361. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97362. */
  97363. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  97364. /**
  97365. * Creates a new VRDeviceOrientationArcRotateCamera
  97366. * @param name defines camera name
  97367. * @param alpha defines the camera rotation along the logitudinal axis
  97368. * @param beta defines the camera rotation along the latitudinal axis
  97369. * @param radius defines the camera distance from its target
  97370. * @param target defines the camera target
  97371. * @param scene defines the scene the camera belongs to
  97372. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97373. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97374. */
  97375. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97376. /**
  97377. * Gets camera class name
  97378. * @returns VRDeviceOrientationArcRotateCamera
  97379. */
  97380. getClassName(): string;
  97381. }
  97382. }
  97383. declare module BABYLON {
  97384. /**
  97385. * Camera used to simulate VR rendering (based on FreeCamera)
  97386. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97387. */
  97388. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  97389. /**
  97390. * Creates a new VRDeviceOrientationFreeCamera
  97391. * @param name defines camera name
  97392. * @param position defines the start position of the camera
  97393. * @param scene defines the scene the camera belongs to
  97394. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97395. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97396. */
  97397. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97398. /**
  97399. * Gets camera class name
  97400. * @returns VRDeviceOrientationFreeCamera
  97401. */
  97402. getClassName(): string;
  97403. }
  97404. }
  97405. declare module BABYLON {
  97406. /**
  97407. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  97408. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  97409. */
  97410. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  97411. /**
  97412. * Creates a new VRDeviceOrientationGamepadCamera
  97413. * @param name defines camera name
  97414. * @param position defines the start position of the camera
  97415. * @param scene defines the scene the camera belongs to
  97416. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  97417. * @param vrCameraMetrics defines the vr metrics associated to the camera
  97418. */
  97419. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  97420. /**
  97421. * Gets camera class name
  97422. * @returns VRDeviceOrientationGamepadCamera
  97423. */
  97424. getClassName(): string;
  97425. }
  97426. }
  97427. declare module BABYLON {
  97428. /**
  97429. * Defines supported buttons for XBox360 compatible gamepads
  97430. */
  97431. export enum Xbox360Button {
  97432. /** A */
  97433. A = 0,
  97434. /** B */
  97435. B = 1,
  97436. /** X */
  97437. X = 2,
  97438. /** Y */
  97439. Y = 3,
  97440. /** Start */
  97441. Start = 4,
  97442. /** Back */
  97443. Back = 5,
  97444. /** Left button */
  97445. LB = 6,
  97446. /** Right button */
  97447. RB = 7,
  97448. /** Left stick */
  97449. LeftStick = 8,
  97450. /** Right stick */
  97451. RightStick = 9
  97452. }
  97453. /** Defines values for XBox360 DPad */
  97454. export enum Xbox360Dpad {
  97455. /** Up */
  97456. Up = 0,
  97457. /** Down */
  97458. Down = 1,
  97459. /** Left */
  97460. Left = 2,
  97461. /** Right */
  97462. Right = 3
  97463. }
  97464. /**
  97465. * Defines a XBox360 gamepad
  97466. */
  97467. export class Xbox360Pad extends Gamepad {
  97468. private _leftTrigger;
  97469. private _rightTrigger;
  97470. private _onlefttriggerchanged;
  97471. private _onrighttriggerchanged;
  97472. private _onbuttondown;
  97473. private _onbuttonup;
  97474. private _ondpaddown;
  97475. private _ondpadup;
  97476. /** Observable raised when a button is pressed */
  97477. onButtonDownObservable: Observable<Xbox360Button>;
  97478. /** Observable raised when a button is released */
  97479. onButtonUpObservable: Observable<Xbox360Button>;
  97480. /** Observable raised when a pad is pressed */
  97481. onPadDownObservable: Observable<Xbox360Dpad>;
  97482. /** Observable raised when a pad is released */
  97483. onPadUpObservable: Observable<Xbox360Dpad>;
  97484. private _buttonA;
  97485. private _buttonB;
  97486. private _buttonX;
  97487. private _buttonY;
  97488. private _buttonBack;
  97489. private _buttonStart;
  97490. private _buttonLB;
  97491. private _buttonRB;
  97492. private _buttonLeftStick;
  97493. private _buttonRightStick;
  97494. private _dPadUp;
  97495. private _dPadDown;
  97496. private _dPadLeft;
  97497. private _dPadRight;
  97498. private _isXboxOnePad;
  97499. /**
  97500. * Creates a new XBox360 gamepad object
  97501. * @param id defines the id of this gamepad
  97502. * @param index defines its index
  97503. * @param gamepad defines the internal HTML gamepad object
  97504. * @param xboxOne defines if it is a XBox One gamepad
  97505. */
  97506. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  97507. /**
  97508. * Defines the callback to call when left trigger is pressed
  97509. * @param callback defines the callback to use
  97510. */
  97511. onlefttriggerchanged(callback: (value: number) => void): void;
  97512. /**
  97513. * Defines the callback to call when right trigger is pressed
  97514. * @param callback defines the callback to use
  97515. */
  97516. onrighttriggerchanged(callback: (value: number) => void): void;
  97517. /**
  97518. * Gets the left trigger value
  97519. */
  97520. /**
  97521. * Sets the left trigger value
  97522. */
  97523. leftTrigger: number;
  97524. /**
  97525. * Gets the right trigger value
  97526. */
  97527. /**
  97528. * Sets the right trigger value
  97529. */
  97530. rightTrigger: number;
  97531. /**
  97532. * Defines the callback to call when a button is pressed
  97533. * @param callback defines the callback to use
  97534. */
  97535. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  97536. /**
  97537. * Defines the callback to call when a button is released
  97538. * @param callback defines the callback to use
  97539. */
  97540. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  97541. /**
  97542. * Defines the callback to call when a pad is pressed
  97543. * @param callback defines the callback to use
  97544. */
  97545. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  97546. /**
  97547. * Defines the callback to call when a pad is released
  97548. * @param callback defines the callback to use
  97549. */
  97550. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  97551. private _setButtonValue;
  97552. private _setDPadValue;
  97553. /**
  97554. * Gets the value of the `A` button
  97555. */
  97556. /**
  97557. * Sets the value of the `A` button
  97558. */
  97559. buttonA: number;
  97560. /**
  97561. * Gets the value of the `B` button
  97562. */
  97563. /**
  97564. * Sets the value of the `B` button
  97565. */
  97566. buttonB: number;
  97567. /**
  97568. * Gets the value of the `X` button
  97569. */
  97570. /**
  97571. * Sets the value of the `X` button
  97572. */
  97573. buttonX: number;
  97574. /**
  97575. * Gets the value of the `Y` button
  97576. */
  97577. /**
  97578. * Sets the value of the `Y` button
  97579. */
  97580. buttonY: number;
  97581. /**
  97582. * Gets the value of the `Start` button
  97583. */
  97584. /**
  97585. * Sets the value of the `Start` button
  97586. */
  97587. buttonStart: number;
  97588. /**
  97589. * Gets the value of the `Back` button
  97590. */
  97591. /**
  97592. * Sets the value of the `Back` button
  97593. */
  97594. buttonBack: number;
  97595. /**
  97596. * Gets the value of the `Left` button
  97597. */
  97598. /**
  97599. * Sets the value of the `Left` button
  97600. */
  97601. buttonLB: number;
  97602. /**
  97603. * Gets the value of the `Right` button
  97604. */
  97605. /**
  97606. * Sets the value of the `Right` button
  97607. */
  97608. buttonRB: number;
  97609. /**
  97610. * Gets the value of the Left joystick
  97611. */
  97612. /**
  97613. * Sets the value of the Left joystick
  97614. */
  97615. buttonLeftStick: number;
  97616. /**
  97617. * Gets the value of the Right joystick
  97618. */
  97619. /**
  97620. * Sets the value of the Right joystick
  97621. */
  97622. buttonRightStick: number;
  97623. /**
  97624. * Gets the value of D-pad up
  97625. */
  97626. /**
  97627. * Sets the value of D-pad up
  97628. */
  97629. dPadUp: number;
  97630. /**
  97631. * Gets the value of D-pad down
  97632. */
  97633. /**
  97634. * Sets the value of D-pad down
  97635. */
  97636. dPadDown: number;
  97637. /**
  97638. * Gets the value of D-pad left
  97639. */
  97640. /**
  97641. * Sets the value of D-pad left
  97642. */
  97643. dPadLeft: number;
  97644. /**
  97645. * Gets the value of D-pad right
  97646. */
  97647. /**
  97648. * Sets the value of D-pad right
  97649. */
  97650. dPadRight: number;
  97651. /**
  97652. * Force the gamepad to synchronize with device values
  97653. */
  97654. update(): void;
  97655. /**
  97656. * Disposes the gamepad
  97657. */
  97658. dispose(): void;
  97659. }
  97660. }
  97661. declare module BABYLON {
  97662. /**
  97663. * Base class of materials working in push mode in babylon JS
  97664. * @hidden
  97665. */
  97666. export class PushMaterial extends Material {
  97667. protected _activeEffect: Effect;
  97668. protected _normalMatrix: Matrix;
  97669. /**
  97670. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  97671. * This means that the material can keep using a previous shader while a new one is being compiled.
  97672. * This is mostly used when shader parallel compilation is supported (true by default)
  97673. */
  97674. allowShaderHotSwapping: boolean;
  97675. constructor(name: string, scene: Scene);
  97676. getEffect(): Effect;
  97677. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97678. /**
  97679. * Binds the given world matrix to the active effect
  97680. *
  97681. * @param world the matrix to bind
  97682. */
  97683. bindOnlyWorldMatrix(world: Matrix): void;
  97684. /**
  97685. * Binds the given normal matrix to the active effect
  97686. *
  97687. * @param normalMatrix the matrix to bind
  97688. */
  97689. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  97690. bind(world: Matrix, mesh?: Mesh): void;
  97691. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  97692. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  97693. }
  97694. }
  97695. declare module BABYLON {
  97696. /**
  97697. * This groups all the flags used to control the materials channel.
  97698. */
  97699. export class MaterialFlags {
  97700. private static _DiffuseTextureEnabled;
  97701. /**
  97702. * Are diffuse textures enabled in the application.
  97703. */
  97704. static DiffuseTextureEnabled: boolean;
  97705. private static _AmbientTextureEnabled;
  97706. /**
  97707. * Are ambient textures enabled in the application.
  97708. */
  97709. static AmbientTextureEnabled: boolean;
  97710. private static _OpacityTextureEnabled;
  97711. /**
  97712. * Are opacity textures enabled in the application.
  97713. */
  97714. static OpacityTextureEnabled: boolean;
  97715. private static _ReflectionTextureEnabled;
  97716. /**
  97717. * Are reflection textures enabled in the application.
  97718. */
  97719. static ReflectionTextureEnabled: boolean;
  97720. private static _EmissiveTextureEnabled;
  97721. /**
  97722. * Are emissive textures enabled in the application.
  97723. */
  97724. static EmissiveTextureEnabled: boolean;
  97725. private static _SpecularTextureEnabled;
  97726. /**
  97727. * Are specular textures enabled in the application.
  97728. */
  97729. static SpecularTextureEnabled: boolean;
  97730. private static _BumpTextureEnabled;
  97731. /**
  97732. * Are bump textures enabled in the application.
  97733. */
  97734. static BumpTextureEnabled: boolean;
  97735. private static _LightmapTextureEnabled;
  97736. /**
  97737. * Are lightmap textures enabled in the application.
  97738. */
  97739. static LightmapTextureEnabled: boolean;
  97740. private static _RefractionTextureEnabled;
  97741. /**
  97742. * Are refraction textures enabled in the application.
  97743. */
  97744. static RefractionTextureEnabled: boolean;
  97745. private static _ColorGradingTextureEnabled;
  97746. /**
  97747. * Are color grading textures enabled in the application.
  97748. */
  97749. static ColorGradingTextureEnabled: boolean;
  97750. private static _FresnelEnabled;
  97751. /**
  97752. * Are fresnels enabled in the application.
  97753. */
  97754. static FresnelEnabled: boolean;
  97755. private static _ClearCoatTextureEnabled;
  97756. /**
  97757. * Are clear coat textures enabled in the application.
  97758. */
  97759. static ClearCoatTextureEnabled: boolean;
  97760. private static _ClearCoatBumpTextureEnabled;
  97761. /**
  97762. * Are clear coat bump textures enabled in the application.
  97763. */
  97764. static ClearCoatBumpTextureEnabled: boolean;
  97765. private static _ClearCoatTintTextureEnabled;
  97766. /**
  97767. * Are clear coat tint textures enabled in the application.
  97768. */
  97769. static ClearCoatTintTextureEnabled: boolean;
  97770. private static _SheenTextureEnabled;
  97771. /**
  97772. * Are sheen textures enabled in the application.
  97773. */
  97774. static SheenTextureEnabled: boolean;
  97775. private static _AnisotropicTextureEnabled;
  97776. /**
  97777. * Are anisotropic textures enabled in the application.
  97778. */
  97779. static AnisotropicTextureEnabled: boolean;
  97780. private static _ThicknessTextureEnabled;
  97781. /**
  97782. * Are thickness textures enabled in the application.
  97783. */
  97784. static ThicknessTextureEnabled: boolean;
  97785. }
  97786. }
  97787. declare module BABYLON {
  97788. /** @hidden */
  97789. export var defaultFragmentDeclaration: {
  97790. name: string;
  97791. shader: string;
  97792. };
  97793. }
  97794. declare module BABYLON {
  97795. /** @hidden */
  97796. export var defaultUboDeclaration: {
  97797. name: string;
  97798. shader: string;
  97799. };
  97800. }
  97801. declare module BABYLON {
  97802. /** @hidden */
  97803. export var lightFragmentDeclaration: {
  97804. name: string;
  97805. shader: string;
  97806. };
  97807. }
  97808. declare module BABYLON {
  97809. /** @hidden */
  97810. export var lightUboDeclaration: {
  97811. name: string;
  97812. shader: string;
  97813. };
  97814. }
  97815. declare module BABYLON {
  97816. /** @hidden */
  97817. export var lightsFragmentFunctions: {
  97818. name: string;
  97819. shader: string;
  97820. };
  97821. }
  97822. declare module BABYLON {
  97823. /** @hidden */
  97824. export var shadowsFragmentFunctions: {
  97825. name: string;
  97826. shader: string;
  97827. };
  97828. }
  97829. declare module BABYLON {
  97830. /** @hidden */
  97831. export var fresnelFunction: {
  97832. name: string;
  97833. shader: string;
  97834. };
  97835. }
  97836. declare module BABYLON {
  97837. /** @hidden */
  97838. export var reflectionFunction: {
  97839. name: string;
  97840. shader: string;
  97841. };
  97842. }
  97843. declare module BABYLON {
  97844. /** @hidden */
  97845. export var bumpFragmentFunctions: {
  97846. name: string;
  97847. shader: string;
  97848. };
  97849. }
  97850. declare module BABYLON {
  97851. /** @hidden */
  97852. export var logDepthDeclaration: {
  97853. name: string;
  97854. shader: string;
  97855. };
  97856. }
  97857. declare module BABYLON {
  97858. /** @hidden */
  97859. export var bumpFragment: {
  97860. name: string;
  97861. shader: string;
  97862. };
  97863. }
  97864. declare module BABYLON {
  97865. /** @hidden */
  97866. export var depthPrePass: {
  97867. name: string;
  97868. shader: string;
  97869. };
  97870. }
  97871. declare module BABYLON {
  97872. /** @hidden */
  97873. export var lightFragment: {
  97874. name: string;
  97875. shader: string;
  97876. };
  97877. }
  97878. declare module BABYLON {
  97879. /** @hidden */
  97880. export var logDepthFragment: {
  97881. name: string;
  97882. shader: string;
  97883. };
  97884. }
  97885. declare module BABYLON {
  97886. /** @hidden */
  97887. export var defaultPixelShader: {
  97888. name: string;
  97889. shader: string;
  97890. };
  97891. }
  97892. declare module BABYLON {
  97893. /** @hidden */
  97894. export var defaultVertexDeclaration: {
  97895. name: string;
  97896. shader: string;
  97897. };
  97898. }
  97899. declare module BABYLON {
  97900. /** @hidden */
  97901. export var bumpVertexDeclaration: {
  97902. name: string;
  97903. shader: string;
  97904. };
  97905. }
  97906. declare module BABYLON {
  97907. /** @hidden */
  97908. export var bumpVertex: {
  97909. name: string;
  97910. shader: string;
  97911. };
  97912. }
  97913. declare module BABYLON {
  97914. /** @hidden */
  97915. export var fogVertex: {
  97916. name: string;
  97917. shader: string;
  97918. };
  97919. }
  97920. declare module BABYLON {
  97921. /** @hidden */
  97922. export var shadowsVertex: {
  97923. name: string;
  97924. shader: string;
  97925. };
  97926. }
  97927. declare module BABYLON {
  97928. /** @hidden */
  97929. export var pointCloudVertex: {
  97930. name: string;
  97931. shader: string;
  97932. };
  97933. }
  97934. declare module BABYLON {
  97935. /** @hidden */
  97936. export var logDepthVertex: {
  97937. name: string;
  97938. shader: string;
  97939. };
  97940. }
  97941. declare module BABYLON {
  97942. /** @hidden */
  97943. export var defaultVertexShader: {
  97944. name: string;
  97945. shader: string;
  97946. };
  97947. }
  97948. declare module BABYLON {
  97949. /** @hidden */
  97950. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  97951. MAINUV1: boolean;
  97952. MAINUV2: boolean;
  97953. DIFFUSE: boolean;
  97954. DIFFUSEDIRECTUV: number;
  97955. AMBIENT: boolean;
  97956. AMBIENTDIRECTUV: number;
  97957. OPACITY: boolean;
  97958. OPACITYDIRECTUV: number;
  97959. OPACITYRGB: boolean;
  97960. REFLECTION: boolean;
  97961. EMISSIVE: boolean;
  97962. EMISSIVEDIRECTUV: number;
  97963. SPECULAR: boolean;
  97964. SPECULARDIRECTUV: number;
  97965. BUMP: boolean;
  97966. BUMPDIRECTUV: number;
  97967. PARALLAX: boolean;
  97968. PARALLAXOCCLUSION: boolean;
  97969. SPECULAROVERALPHA: boolean;
  97970. CLIPPLANE: boolean;
  97971. CLIPPLANE2: boolean;
  97972. CLIPPLANE3: boolean;
  97973. CLIPPLANE4: boolean;
  97974. ALPHATEST: boolean;
  97975. DEPTHPREPASS: boolean;
  97976. ALPHAFROMDIFFUSE: boolean;
  97977. POINTSIZE: boolean;
  97978. FOG: boolean;
  97979. SPECULARTERM: boolean;
  97980. DIFFUSEFRESNEL: boolean;
  97981. OPACITYFRESNEL: boolean;
  97982. REFLECTIONFRESNEL: boolean;
  97983. REFRACTIONFRESNEL: boolean;
  97984. EMISSIVEFRESNEL: boolean;
  97985. FRESNEL: boolean;
  97986. NORMAL: boolean;
  97987. UV1: boolean;
  97988. UV2: boolean;
  97989. VERTEXCOLOR: boolean;
  97990. VERTEXALPHA: boolean;
  97991. NUM_BONE_INFLUENCERS: number;
  97992. BonesPerMesh: number;
  97993. BONETEXTURE: boolean;
  97994. INSTANCES: boolean;
  97995. GLOSSINESS: boolean;
  97996. ROUGHNESS: boolean;
  97997. EMISSIVEASILLUMINATION: boolean;
  97998. LINKEMISSIVEWITHDIFFUSE: boolean;
  97999. REFLECTIONFRESNELFROMSPECULAR: boolean;
  98000. LIGHTMAP: boolean;
  98001. LIGHTMAPDIRECTUV: number;
  98002. OBJECTSPACE_NORMALMAP: boolean;
  98003. USELIGHTMAPASSHADOWMAP: boolean;
  98004. REFLECTIONMAP_3D: boolean;
  98005. REFLECTIONMAP_SPHERICAL: boolean;
  98006. REFLECTIONMAP_PLANAR: boolean;
  98007. REFLECTIONMAP_CUBIC: boolean;
  98008. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  98009. REFLECTIONMAP_PROJECTION: boolean;
  98010. REFLECTIONMAP_SKYBOX: boolean;
  98011. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  98012. REFLECTIONMAP_EXPLICIT: boolean;
  98013. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  98014. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  98015. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  98016. INVERTCUBICMAP: boolean;
  98017. LOGARITHMICDEPTH: boolean;
  98018. REFRACTION: boolean;
  98019. REFRACTIONMAP_3D: boolean;
  98020. REFLECTIONOVERALPHA: boolean;
  98021. TWOSIDEDLIGHTING: boolean;
  98022. SHADOWFLOAT: boolean;
  98023. MORPHTARGETS: boolean;
  98024. MORPHTARGETS_NORMAL: boolean;
  98025. MORPHTARGETS_TANGENT: boolean;
  98026. NUM_MORPH_INFLUENCERS: number;
  98027. NONUNIFORMSCALING: boolean;
  98028. PREMULTIPLYALPHA: boolean;
  98029. IMAGEPROCESSING: boolean;
  98030. VIGNETTE: boolean;
  98031. VIGNETTEBLENDMODEMULTIPLY: boolean;
  98032. VIGNETTEBLENDMODEOPAQUE: boolean;
  98033. TONEMAPPING: boolean;
  98034. TONEMAPPING_ACES: boolean;
  98035. CONTRAST: boolean;
  98036. COLORCURVES: boolean;
  98037. COLORGRADING: boolean;
  98038. COLORGRADING3D: boolean;
  98039. SAMPLER3DGREENDEPTH: boolean;
  98040. SAMPLER3DBGRMAP: boolean;
  98041. IMAGEPROCESSINGPOSTPROCESS: boolean;
  98042. MULTIVIEW: boolean;
  98043. /**
  98044. * If the reflection texture on this material is in linear color space
  98045. * @hidden
  98046. */
  98047. IS_REFLECTION_LINEAR: boolean;
  98048. /**
  98049. * If the refraction texture on this material is in linear color space
  98050. * @hidden
  98051. */
  98052. IS_REFRACTION_LINEAR: boolean;
  98053. EXPOSURE: boolean;
  98054. constructor();
  98055. setReflectionMode(modeToEnable: string): void;
  98056. }
  98057. /**
  98058. * This is the default material used in Babylon. It is the best trade off between quality
  98059. * and performances.
  98060. * @see http://doc.babylonjs.com/babylon101/materials
  98061. */
  98062. export class StandardMaterial extends PushMaterial {
  98063. private _diffuseTexture;
  98064. /**
  98065. * The basic texture of the material as viewed under a light.
  98066. */
  98067. diffuseTexture: Nullable<BaseTexture>;
  98068. private _ambientTexture;
  98069. /**
  98070. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  98071. */
  98072. ambientTexture: Nullable<BaseTexture>;
  98073. private _opacityTexture;
  98074. /**
  98075. * Define the transparency of the material from a texture.
  98076. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  98077. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  98078. */
  98079. opacityTexture: Nullable<BaseTexture>;
  98080. private _reflectionTexture;
  98081. /**
  98082. * Define the texture used to display the reflection.
  98083. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98084. */
  98085. reflectionTexture: Nullable<BaseTexture>;
  98086. private _emissiveTexture;
  98087. /**
  98088. * Define texture of the material as if self lit.
  98089. * This will be mixed in the final result even in the absence of light.
  98090. */
  98091. emissiveTexture: Nullable<BaseTexture>;
  98092. private _specularTexture;
  98093. /**
  98094. * Define how the color and intensity of the highlight given by the light in the material.
  98095. */
  98096. specularTexture: Nullable<BaseTexture>;
  98097. private _bumpTexture;
  98098. /**
  98099. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  98100. * 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.
  98101. * @see http://doc.babylonjs.com/how_to/more_materials#bump-map
  98102. */
  98103. bumpTexture: Nullable<BaseTexture>;
  98104. private _lightmapTexture;
  98105. /**
  98106. * Complex lighting can be computationally expensive to compute at runtime.
  98107. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  98108. * @see http://doc.babylonjs.com/babylon101/lights#lightmaps
  98109. */
  98110. lightmapTexture: Nullable<BaseTexture>;
  98111. private _refractionTexture;
  98112. /**
  98113. * Define the texture used to display the refraction.
  98114. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98115. */
  98116. refractionTexture: Nullable<BaseTexture>;
  98117. /**
  98118. * The color of the material lit by the environmental background lighting.
  98119. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  98120. */
  98121. ambientColor: Color3;
  98122. /**
  98123. * The basic color of the material as viewed under a light.
  98124. */
  98125. diffuseColor: Color3;
  98126. /**
  98127. * Define how the color and intensity of the highlight given by the light in the material.
  98128. */
  98129. specularColor: Color3;
  98130. /**
  98131. * Define the color of the material as if self lit.
  98132. * This will be mixed in the final result even in the absence of light.
  98133. */
  98134. emissiveColor: Color3;
  98135. /**
  98136. * Defines how sharp are the highlights in the material.
  98137. * The bigger the value the sharper giving a more glossy feeling to the result.
  98138. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  98139. */
  98140. specularPower: number;
  98141. private _useAlphaFromDiffuseTexture;
  98142. /**
  98143. * Does the transparency come from the diffuse texture alpha channel.
  98144. */
  98145. useAlphaFromDiffuseTexture: boolean;
  98146. private _useEmissiveAsIllumination;
  98147. /**
  98148. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  98149. */
  98150. useEmissiveAsIllumination: boolean;
  98151. private _linkEmissiveWithDiffuse;
  98152. /**
  98153. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  98154. * the emissive level when the final color is close to one.
  98155. */
  98156. linkEmissiveWithDiffuse: boolean;
  98157. private _useSpecularOverAlpha;
  98158. /**
  98159. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  98160. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  98161. */
  98162. useSpecularOverAlpha: boolean;
  98163. private _useReflectionOverAlpha;
  98164. /**
  98165. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  98166. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  98167. */
  98168. useReflectionOverAlpha: boolean;
  98169. private _disableLighting;
  98170. /**
  98171. * Does lights from the scene impacts this material.
  98172. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  98173. */
  98174. disableLighting: boolean;
  98175. private _useObjectSpaceNormalMap;
  98176. /**
  98177. * Allows using an object space normal map (instead of tangent space).
  98178. */
  98179. useObjectSpaceNormalMap: boolean;
  98180. private _useParallax;
  98181. /**
  98182. * Is parallax enabled or not.
  98183. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98184. */
  98185. useParallax: boolean;
  98186. private _useParallaxOcclusion;
  98187. /**
  98188. * Is parallax occlusion enabled or not.
  98189. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  98190. * @see http://doc.babylonjs.com/how_to/using_parallax_mapping
  98191. */
  98192. useParallaxOcclusion: boolean;
  98193. /**
  98194. * 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.
  98195. */
  98196. parallaxScaleBias: number;
  98197. private _roughness;
  98198. /**
  98199. * Helps to define how blurry the reflections should appears in the material.
  98200. */
  98201. roughness: number;
  98202. /**
  98203. * In case of refraction, define the value of the indice of refraction.
  98204. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98205. */
  98206. indexOfRefraction: number;
  98207. /**
  98208. * Invert the refraction texture alongside the y axis.
  98209. * It can be useful with procedural textures or probe for instance.
  98210. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  98211. */
  98212. invertRefractionY: boolean;
  98213. /**
  98214. * Defines the alpha limits in alpha test mode.
  98215. */
  98216. alphaCutOff: number;
  98217. private _useLightmapAsShadowmap;
  98218. /**
  98219. * In case of light mapping, define whether the map contains light or shadow informations.
  98220. */
  98221. useLightmapAsShadowmap: boolean;
  98222. private _diffuseFresnelParameters;
  98223. /**
  98224. * Define the diffuse fresnel parameters of the material.
  98225. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98226. */
  98227. diffuseFresnelParameters: FresnelParameters;
  98228. private _opacityFresnelParameters;
  98229. /**
  98230. * Define the opacity fresnel parameters of the material.
  98231. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98232. */
  98233. opacityFresnelParameters: FresnelParameters;
  98234. private _reflectionFresnelParameters;
  98235. /**
  98236. * Define the reflection fresnel parameters of the material.
  98237. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98238. */
  98239. reflectionFresnelParameters: FresnelParameters;
  98240. private _refractionFresnelParameters;
  98241. /**
  98242. * Define the refraction fresnel parameters of the material.
  98243. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98244. */
  98245. refractionFresnelParameters: FresnelParameters;
  98246. private _emissiveFresnelParameters;
  98247. /**
  98248. * Define the emissive fresnel parameters of the material.
  98249. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98250. */
  98251. emissiveFresnelParameters: FresnelParameters;
  98252. private _useReflectionFresnelFromSpecular;
  98253. /**
  98254. * If true automatically deducts the fresnels values from the material specularity.
  98255. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  98256. */
  98257. useReflectionFresnelFromSpecular: boolean;
  98258. private _useGlossinessFromSpecularMapAlpha;
  98259. /**
  98260. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  98261. */
  98262. useGlossinessFromSpecularMapAlpha: boolean;
  98263. private _maxSimultaneousLights;
  98264. /**
  98265. * Defines the maximum number of lights that can be used in the material
  98266. */
  98267. maxSimultaneousLights: number;
  98268. private _invertNormalMapX;
  98269. /**
  98270. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  98271. */
  98272. invertNormalMapX: boolean;
  98273. private _invertNormalMapY;
  98274. /**
  98275. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  98276. */
  98277. invertNormalMapY: boolean;
  98278. private _twoSidedLighting;
  98279. /**
  98280. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  98281. */
  98282. twoSidedLighting: boolean;
  98283. /**
  98284. * Default configuration related to image processing available in the standard Material.
  98285. */
  98286. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98287. /**
  98288. * Gets the image processing configuration used either in this material.
  98289. */
  98290. /**
  98291. * Sets the Default image processing configuration used either in the this material.
  98292. *
  98293. * If sets to null, the scene one is in use.
  98294. */
  98295. imageProcessingConfiguration: ImageProcessingConfiguration;
  98296. /**
  98297. * Keep track of the image processing observer to allow dispose and replace.
  98298. */
  98299. private _imageProcessingObserver;
  98300. /**
  98301. * Attaches a new image processing configuration to the Standard Material.
  98302. * @param configuration
  98303. */
  98304. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  98305. /**
  98306. * Gets wether the color curves effect is enabled.
  98307. */
  98308. /**
  98309. * Sets wether the color curves effect is enabled.
  98310. */
  98311. cameraColorCurvesEnabled: boolean;
  98312. /**
  98313. * Gets wether the color grading effect is enabled.
  98314. */
  98315. /**
  98316. * Gets wether the color grading effect is enabled.
  98317. */
  98318. cameraColorGradingEnabled: boolean;
  98319. /**
  98320. * Gets wether tonemapping is enabled or not.
  98321. */
  98322. /**
  98323. * Sets wether tonemapping is enabled or not
  98324. */
  98325. cameraToneMappingEnabled: boolean;
  98326. /**
  98327. * The camera exposure used on this material.
  98328. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98329. * This corresponds to a photographic exposure.
  98330. */
  98331. /**
  98332. * The camera exposure used on this material.
  98333. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  98334. * This corresponds to a photographic exposure.
  98335. */
  98336. cameraExposure: number;
  98337. /**
  98338. * Gets The camera contrast used on this material.
  98339. */
  98340. /**
  98341. * Sets The camera contrast used on this material.
  98342. */
  98343. cameraContrast: number;
  98344. /**
  98345. * Gets the Color Grading 2D Lookup Texture.
  98346. */
  98347. /**
  98348. * Sets the Color Grading 2D Lookup Texture.
  98349. */
  98350. cameraColorGradingTexture: Nullable<BaseTexture>;
  98351. /**
  98352. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98353. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98354. * 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;
  98355. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98356. */
  98357. /**
  98358. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  98359. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  98360. * 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;
  98361. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  98362. */
  98363. cameraColorCurves: Nullable<ColorCurves>;
  98364. /**
  98365. * Custom callback helping to override the default shader used in the material.
  98366. */
  98367. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: StandardMaterialDefines) => string;
  98368. protected _renderTargets: SmartArray<RenderTargetTexture>;
  98369. protected _worldViewProjectionMatrix: Matrix;
  98370. protected _globalAmbientColor: Color3;
  98371. protected _useLogarithmicDepth: boolean;
  98372. /**
  98373. * Instantiates a new standard material.
  98374. * This is the default material used in Babylon. It is the best trade off between quality
  98375. * and performances.
  98376. * @see http://doc.babylonjs.com/babylon101/materials
  98377. * @param name Define the name of the material in the scene
  98378. * @param scene Define the scene the material belong to
  98379. */
  98380. constructor(name: string, scene: Scene);
  98381. /**
  98382. * Gets a boolean indicating that current material needs to register RTT
  98383. */
  98384. readonly hasRenderTargetTextures: boolean;
  98385. /**
  98386. * Gets the current class name of the material e.g. "StandardMaterial"
  98387. * Mainly use in serialization.
  98388. * @returns the class name
  98389. */
  98390. getClassName(): string;
  98391. /**
  98392. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  98393. * You can try switching to logarithmic depth.
  98394. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  98395. */
  98396. useLogarithmicDepth: boolean;
  98397. /**
  98398. * Specifies if the material will require alpha blending
  98399. * @returns a boolean specifying if alpha blending is needed
  98400. */
  98401. needAlphaBlending(): boolean;
  98402. /**
  98403. * Specifies if this material should be rendered in alpha test mode
  98404. * @returns a boolean specifying if an alpha test is needed.
  98405. */
  98406. needAlphaTesting(): boolean;
  98407. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  98408. /**
  98409. * Get the texture used for alpha test purpose.
  98410. * @returns the diffuse texture in case of the standard material.
  98411. */
  98412. getAlphaTestTexture(): Nullable<BaseTexture>;
  98413. /**
  98414. * Get if the submesh is ready to be used and all its information available.
  98415. * Child classes can use it to update shaders
  98416. * @param mesh defines the mesh to check
  98417. * @param subMesh defines which submesh to check
  98418. * @param useInstances specifies that instances should be used
  98419. * @returns a boolean indicating that the submesh is ready or not
  98420. */
  98421. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  98422. /**
  98423. * Builds the material UBO layouts.
  98424. * Used internally during the effect preparation.
  98425. */
  98426. buildUniformLayout(): void;
  98427. /**
  98428. * Unbinds the material from the mesh
  98429. */
  98430. unbind(): void;
  98431. /**
  98432. * Binds the submesh to this material by preparing the effect and shader to draw
  98433. * @param world defines the world transformation matrix
  98434. * @param mesh defines the mesh containing the submesh
  98435. * @param subMesh defines the submesh to bind the material to
  98436. */
  98437. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  98438. /**
  98439. * Get the list of animatables in the material.
  98440. * @returns the list of animatables object used in the material
  98441. */
  98442. getAnimatables(): IAnimatable[];
  98443. /**
  98444. * Gets the active textures from the material
  98445. * @returns an array of textures
  98446. */
  98447. getActiveTextures(): BaseTexture[];
  98448. /**
  98449. * Specifies if the material uses a texture
  98450. * @param texture defines the texture to check against the material
  98451. * @returns a boolean specifying if the material uses the texture
  98452. */
  98453. hasTexture(texture: BaseTexture): boolean;
  98454. /**
  98455. * Disposes the material
  98456. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  98457. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  98458. */
  98459. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  98460. /**
  98461. * Makes a duplicate of the material, and gives it a new name
  98462. * @param name defines the new name for the duplicated material
  98463. * @returns the cloned material
  98464. */
  98465. clone(name: string): StandardMaterial;
  98466. /**
  98467. * Serializes this material in a JSON representation
  98468. * @returns the serialized material object
  98469. */
  98470. serialize(): any;
  98471. /**
  98472. * Creates a standard material from parsed material data
  98473. * @param source defines the JSON representation of the material
  98474. * @param scene defines the hosting scene
  98475. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  98476. * @returns a new standard material
  98477. */
  98478. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  98479. /**
  98480. * Are diffuse textures enabled in the application.
  98481. */
  98482. static DiffuseTextureEnabled: boolean;
  98483. /**
  98484. * Are ambient textures enabled in the application.
  98485. */
  98486. static AmbientTextureEnabled: boolean;
  98487. /**
  98488. * Are opacity textures enabled in the application.
  98489. */
  98490. static OpacityTextureEnabled: boolean;
  98491. /**
  98492. * Are reflection textures enabled in the application.
  98493. */
  98494. static ReflectionTextureEnabled: boolean;
  98495. /**
  98496. * Are emissive textures enabled in the application.
  98497. */
  98498. static EmissiveTextureEnabled: boolean;
  98499. /**
  98500. * Are specular textures enabled in the application.
  98501. */
  98502. static SpecularTextureEnabled: boolean;
  98503. /**
  98504. * Are bump textures enabled in the application.
  98505. */
  98506. static BumpTextureEnabled: boolean;
  98507. /**
  98508. * Are lightmap textures enabled in the application.
  98509. */
  98510. static LightmapTextureEnabled: boolean;
  98511. /**
  98512. * Are refraction textures enabled in the application.
  98513. */
  98514. static RefractionTextureEnabled: boolean;
  98515. /**
  98516. * Are color grading textures enabled in the application.
  98517. */
  98518. static ColorGradingTextureEnabled: boolean;
  98519. /**
  98520. * Are fresnels enabled in the application.
  98521. */
  98522. static FresnelEnabled: boolean;
  98523. }
  98524. }
  98525. declare module BABYLON {
  98526. /**
  98527. * A class extending Texture allowing drawing on a texture
  98528. * @see http://doc.babylonjs.com/how_to/dynamictexture
  98529. */
  98530. export class DynamicTexture extends Texture {
  98531. private _generateMipMaps;
  98532. private _canvas;
  98533. private _context;
  98534. private _engine;
  98535. /**
  98536. * Creates a DynamicTexture
  98537. * @param name defines the name of the texture
  98538. * @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
  98539. * @param scene defines the scene where you want the texture
  98540. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  98541. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  98542. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  98543. */
  98544. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number);
  98545. /**
  98546. * Get the current class name of the texture useful for serialization or dynamic coding.
  98547. * @returns "DynamicTexture"
  98548. */
  98549. getClassName(): string;
  98550. /**
  98551. * Gets the current state of canRescale
  98552. */
  98553. readonly canRescale: boolean;
  98554. private _recreate;
  98555. /**
  98556. * Scales the texture
  98557. * @param ratio the scale factor to apply to both width and height
  98558. */
  98559. scale(ratio: number): void;
  98560. /**
  98561. * Resizes the texture
  98562. * @param width the new width
  98563. * @param height the new height
  98564. */
  98565. scaleTo(width: number, height: number): void;
  98566. /**
  98567. * Gets the context of the canvas used by the texture
  98568. * @returns the canvas context of the dynamic texture
  98569. */
  98570. getContext(): CanvasRenderingContext2D;
  98571. /**
  98572. * Clears the texture
  98573. */
  98574. clear(): void;
  98575. /**
  98576. * Updates the texture
  98577. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98578. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  98579. */
  98580. update(invertY?: boolean, premulAlpha?: boolean): void;
  98581. /**
  98582. * Draws text onto the texture
  98583. * @param text defines the text to be drawn
  98584. * @param x defines the placement of the text from the left
  98585. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  98586. * @param font defines the font to be used with font-style, font-size, font-name
  98587. * @param color defines the color used for the text
  98588. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  98589. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  98590. * @param update defines whether texture is immediately update (default is true)
  98591. */
  98592. drawText(text: string, x: number, y: number, font: string, color: string, clearColor: string, invertY?: boolean, update?: boolean): void;
  98593. /**
  98594. * Clones the texture
  98595. * @returns the clone of the texture.
  98596. */
  98597. clone(): DynamicTexture;
  98598. /**
  98599. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  98600. * @returns a serialized dynamic texture object
  98601. */
  98602. serialize(): any;
  98603. /** @hidden */
  98604. _rebuild(): void;
  98605. }
  98606. }
  98607. declare module BABYLON {
  98608. /** @hidden */
  98609. export var imageProcessingPixelShader: {
  98610. name: string;
  98611. shader: string;
  98612. };
  98613. }
  98614. declare module BABYLON {
  98615. /**
  98616. * ImageProcessingPostProcess
  98617. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  98618. */
  98619. export class ImageProcessingPostProcess extends PostProcess {
  98620. /**
  98621. * Default configuration related to image processing available in the PBR Material.
  98622. */
  98623. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  98624. /**
  98625. * Gets the image processing configuration used either in this material.
  98626. */
  98627. /**
  98628. * Sets the Default image processing configuration used either in the this material.
  98629. *
  98630. * If sets to null, the scene one is in use.
  98631. */
  98632. imageProcessingConfiguration: ImageProcessingConfiguration;
  98633. /**
  98634. * Keep track of the image processing observer to allow dispose and replace.
  98635. */
  98636. private _imageProcessingObserver;
  98637. /**
  98638. * Attaches a new image processing configuration to the PBR Material.
  98639. * @param configuration
  98640. */
  98641. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  98642. /**
  98643. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98644. */
  98645. /**
  98646. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  98647. */
  98648. colorCurves: Nullable<ColorCurves>;
  98649. /**
  98650. * Gets wether the color curves effect is enabled.
  98651. */
  98652. /**
  98653. * Sets wether the color curves effect is enabled.
  98654. */
  98655. colorCurvesEnabled: boolean;
  98656. /**
  98657. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98658. */
  98659. /**
  98660. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  98661. */
  98662. colorGradingTexture: Nullable<BaseTexture>;
  98663. /**
  98664. * Gets wether the color grading effect is enabled.
  98665. */
  98666. /**
  98667. * Gets wether the color grading effect is enabled.
  98668. */
  98669. colorGradingEnabled: boolean;
  98670. /**
  98671. * Gets exposure used in the effect.
  98672. */
  98673. /**
  98674. * Sets exposure used in the effect.
  98675. */
  98676. exposure: number;
  98677. /**
  98678. * Gets wether tonemapping is enabled or not.
  98679. */
  98680. /**
  98681. * Sets wether tonemapping is enabled or not
  98682. */
  98683. toneMappingEnabled: boolean;
  98684. /**
  98685. * Gets the type of tone mapping effect.
  98686. */
  98687. /**
  98688. * Sets the type of tone mapping effect.
  98689. */
  98690. toneMappingType: number;
  98691. /**
  98692. * Gets contrast used in the effect.
  98693. */
  98694. /**
  98695. * Sets contrast used in the effect.
  98696. */
  98697. contrast: number;
  98698. /**
  98699. * Gets Vignette stretch size.
  98700. */
  98701. /**
  98702. * Sets Vignette stretch size.
  98703. */
  98704. vignetteStretch: number;
  98705. /**
  98706. * Gets Vignette centre X Offset.
  98707. */
  98708. /**
  98709. * Sets Vignette centre X Offset.
  98710. */
  98711. vignetteCentreX: number;
  98712. /**
  98713. * Gets Vignette centre Y Offset.
  98714. */
  98715. /**
  98716. * Sets Vignette centre Y Offset.
  98717. */
  98718. vignetteCentreY: number;
  98719. /**
  98720. * Gets Vignette weight or intensity of the vignette effect.
  98721. */
  98722. /**
  98723. * Sets Vignette weight or intensity of the vignette effect.
  98724. */
  98725. vignetteWeight: number;
  98726. /**
  98727. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98728. * if vignetteEnabled is set to true.
  98729. */
  98730. /**
  98731. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  98732. * if vignetteEnabled is set to true.
  98733. */
  98734. vignetteColor: Color4;
  98735. /**
  98736. * Gets Camera field of view used by the Vignette effect.
  98737. */
  98738. /**
  98739. * Sets Camera field of view used by the Vignette effect.
  98740. */
  98741. vignetteCameraFov: number;
  98742. /**
  98743. * Gets the vignette blend mode allowing different kind of effect.
  98744. */
  98745. /**
  98746. * Sets the vignette blend mode allowing different kind of effect.
  98747. */
  98748. vignetteBlendMode: number;
  98749. /**
  98750. * Gets wether the vignette effect is enabled.
  98751. */
  98752. /**
  98753. * Sets wether the vignette effect is enabled.
  98754. */
  98755. vignetteEnabled: boolean;
  98756. private _fromLinearSpace;
  98757. /**
  98758. * Gets wether the input of the processing is in Gamma or Linear Space.
  98759. */
  98760. /**
  98761. * Sets wether the input of the processing is in Gamma or Linear Space.
  98762. */
  98763. fromLinearSpace: boolean;
  98764. /**
  98765. * Defines cache preventing GC.
  98766. */
  98767. private _defines;
  98768. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  98769. /**
  98770. * "ImageProcessingPostProcess"
  98771. * @returns "ImageProcessingPostProcess"
  98772. */
  98773. getClassName(): string;
  98774. protected _updateParameters(): void;
  98775. dispose(camera?: Camera): void;
  98776. }
  98777. }
  98778. declare module BABYLON {
  98779. /**
  98780. * Class containing static functions to help procedurally build meshes
  98781. */
  98782. export class GroundBuilder {
  98783. /**
  98784. * Creates a ground mesh
  98785. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  98786. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  98787. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  98788. * @param name defines the name of the mesh
  98789. * @param options defines the options used to create the mesh
  98790. * @param scene defines the hosting scene
  98791. * @returns the ground mesh
  98792. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  98793. */
  98794. static CreateGround(name: string, options: {
  98795. width?: number;
  98796. height?: number;
  98797. subdivisions?: number;
  98798. subdivisionsX?: number;
  98799. subdivisionsY?: number;
  98800. updatable?: boolean;
  98801. }, scene: any): Mesh;
  98802. /**
  98803. * Creates a tiled ground mesh
  98804. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  98805. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  98806. * * 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
  98807. * * 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
  98808. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98809. * @param name defines the name of the mesh
  98810. * @param options defines the options used to create the mesh
  98811. * @param scene defines the hosting scene
  98812. * @returns the tiled ground mesh
  98813. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  98814. */
  98815. static CreateTiledGround(name: string, options: {
  98816. xmin: number;
  98817. zmin: number;
  98818. xmax: number;
  98819. zmax: number;
  98820. subdivisions?: {
  98821. w: number;
  98822. h: number;
  98823. };
  98824. precision?: {
  98825. w: number;
  98826. h: number;
  98827. };
  98828. updatable?: boolean;
  98829. }, scene?: Nullable<Scene>): Mesh;
  98830. /**
  98831. * Creates a ground mesh from a height map
  98832. * * The parameter `url` sets the URL of the height map image resource.
  98833. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  98834. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  98835. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  98836. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  98837. * * 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.
  98838. * * 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).
  98839. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  98840. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98841. * @param name defines the name of the mesh
  98842. * @param url defines the url to the height map
  98843. * @param options defines the options used to create the mesh
  98844. * @param scene defines the hosting scene
  98845. * @returns the ground mesh
  98846. * @see https://doc.babylonjs.com/babylon101/height_map
  98847. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  98848. */
  98849. static CreateGroundFromHeightMap(name: string, url: string, options: {
  98850. width?: number;
  98851. height?: number;
  98852. subdivisions?: number;
  98853. minHeight?: number;
  98854. maxHeight?: number;
  98855. colorFilter?: Color3;
  98856. alphaFilter?: number;
  98857. updatable?: boolean;
  98858. onReady?: (mesh: GroundMesh) => void;
  98859. }, scene?: Nullable<Scene>): GroundMesh;
  98860. }
  98861. }
  98862. declare module BABYLON {
  98863. /**
  98864. * Class containing static functions to help procedurally build meshes
  98865. */
  98866. export class TorusBuilder {
  98867. /**
  98868. * Creates a torus mesh
  98869. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  98870. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  98871. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  98872. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98873. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98874. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98875. * @param name defines the name of the mesh
  98876. * @param options defines the options used to create the mesh
  98877. * @param scene defines the hosting scene
  98878. * @returns the torus mesh
  98879. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  98880. */
  98881. static CreateTorus(name: string, options: {
  98882. diameter?: number;
  98883. thickness?: number;
  98884. tessellation?: number;
  98885. updatable?: boolean;
  98886. sideOrientation?: number;
  98887. frontUVs?: Vector4;
  98888. backUVs?: Vector4;
  98889. }, scene: any): Mesh;
  98890. }
  98891. }
  98892. declare module BABYLON {
  98893. /**
  98894. * Class containing static functions to help procedurally build meshes
  98895. */
  98896. export class CylinderBuilder {
  98897. /**
  98898. * Creates a cylinder or a cone mesh
  98899. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  98900. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  98901. * * 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.
  98902. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  98903. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  98904. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  98905. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  98906. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  98907. * * 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).
  98908. * * 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
  98909. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  98910. * * 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
  98911. * * 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.
  98912. * * If `enclose` is false, a ring surface is one element.
  98913. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  98914. * * 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
  98915. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  98916. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  98917. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  98918. * @param name defines the name of the mesh
  98919. * @param options defines the options used to create the mesh
  98920. * @param scene defines the hosting scene
  98921. * @returns the cylinder mesh
  98922. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  98923. */
  98924. static CreateCylinder(name: string, options: {
  98925. height?: number;
  98926. diameterTop?: number;
  98927. diameterBottom?: number;
  98928. diameter?: number;
  98929. tessellation?: number;
  98930. subdivisions?: number;
  98931. arc?: number;
  98932. faceColors?: Color4[];
  98933. faceUV?: Vector4[];
  98934. updatable?: boolean;
  98935. hasRings?: boolean;
  98936. enclose?: boolean;
  98937. sideOrientation?: number;
  98938. frontUVs?: Vector4;
  98939. backUVs?: Vector4;
  98940. }, scene: any): Mesh;
  98941. }
  98942. }
  98943. declare module BABYLON {
  98944. /**
  98945. * Manager for handling gamepads
  98946. */
  98947. export class GamepadManager {
  98948. private _scene?;
  98949. private _babylonGamepads;
  98950. private _oneGamepadConnected;
  98951. /** @hidden */
  98952. _isMonitoring: boolean;
  98953. private _gamepadEventSupported;
  98954. private _gamepadSupport;
  98955. /**
  98956. * observable to be triggered when the gamepad controller has been connected
  98957. */
  98958. onGamepadConnectedObservable: Observable<Gamepad>;
  98959. /**
  98960. * observable to be triggered when the gamepad controller has been disconnected
  98961. */
  98962. onGamepadDisconnectedObservable: Observable<Gamepad>;
  98963. private _onGamepadConnectedEvent;
  98964. private _onGamepadDisconnectedEvent;
  98965. /**
  98966. * Initializes the gamepad manager
  98967. * @param _scene BabylonJS scene
  98968. */
  98969. constructor(_scene?: Scene | undefined);
  98970. /**
  98971. * The gamepads in the game pad manager
  98972. */
  98973. readonly gamepads: Gamepad[];
  98974. /**
  98975. * Get the gamepad controllers based on type
  98976. * @param type The type of gamepad controller
  98977. * @returns Nullable gamepad
  98978. */
  98979. getGamepadByType(type?: number): Nullable<Gamepad>;
  98980. /**
  98981. * Disposes the gamepad manager
  98982. */
  98983. dispose(): void;
  98984. private _addNewGamepad;
  98985. private _startMonitoringGamepads;
  98986. private _stopMonitoringGamepads;
  98987. /** @hidden */
  98988. _checkGamepadsStatus(): void;
  98989. private _updateGamepadObjects;
  98990. }
  98991. }
  98992. declare module BABYLON {
  98993. interface Scene {
  98994. /** @hidden */
  98995. _gamepadManager: Nullable<GamepadManager>;
  98996. /**
  98997. * Gets the gamepad manager associated with the scene
  98998. * @see http://doc.babylonjs.com/how_to/how_to_use_gamepads
  98999. */
  99000. gamepadManager: GamepadManager;
  99001. }
  99002. /**
  99003. * Interface representing a free camera inputs manager
  99004. */
  99005. interface FreeCameraInputsManager {
  99006. /**
  99007. * Adds gamepad input support to the FreeCameraInputsManager.
  99008. * @returns the FreeCameraInputsManager
  99009. */
  99010. addGamepad(): FreeCameraInputsManager;
  99011. }
  99012. /**
  99013. * Interface representing an arc rotate camera inputs manager
  99014. */
  99015. interface ArcRotateCameraInputsManager {
  99016. /**
  99017. * Adds gamepad input support to the ArcRotateCamera InputManager.
  99018. * @returns the camera inputs manager
  99019. */
  99020. addGamepad(): ArcRotateCameraInputsManager;
  99021. }
  99022. /**
  99023. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  99024. */
  99025. export class GamepadSystemSceneComponent implements ISceneComponent {
  99026. /**
  99027. * The component name helpfull to identify the component in the list of scene components.
  99028. */
  99029. readonly name: string;
  99030. /**
  99031. * The scene the component belongs to.
  99032. */
  99033. scene: Scene;
  99034. /**
  99035. * Creates a new instance of the component for the given scene
  99036. * @param scene Defines the scene to register the component in
  99037. */
  99038. constructor(scene: Scene);
  99039. /**
  99040. * Registers the component in a given scene
  99041. */
  99042. register(): void;
  99043. /**
  99044. * Rebuilds the elements related to this component in case of
  99045. * context lost for instance.
  99046. */
  99047. rebuild(): void;
  99048. /**
  99049. * Disposes the component and the associated ressources
  99050. */
  99051. dispose(): void;
  99052. private _beforeCameraUpdate;
  99053. }
  99054. }
  99055. declare module BABYLON {
  99056. /**
  99057. * Options to modify the vr teleportation behavior.
  99058. */
  99059. export interface VRTeleportationOptions {
  99060. /**
  99061. * The name of the mesh which should be used as the teleportation floor. (default: null)
  99062. */
  99063. floorMeshName?: string;
  99064. /**
  99065. * A list of meshes to be used as the teleportation floor. (default: empty)
  99066. */
  99067. floorMeshes?: Mesh[];
  99068. }
  99069. /**
  99070. * Options to modify the vr experience helper's behavior.
  99071. */
  99072. export interface VRExperienceHelperOptions extends WebVROptions {
  99073. /**
  99074. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  99075. */
  99076. createDeviceOrientationCamera?: boolean;
  99077. /**
  99078. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  99079. */
  99080. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  99081. /**
  99082. * Uses the main button on the controller to toggle the laser casted. (default: true)
  99083. */
  99084. laserToggle?: boolean;
  99085. /**
  99086. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  99087. */
  99088. floorMeshes?: Mesh[];
  99089. /**
  99090. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  99091. */
  99092. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  99093. }
  99094. /**
  99095. * Event containing information after VR has been entered
  99096. */
  99097. export class OnAfterEnteringVRObservableEvent {
  99098. /**
  99099. * If entering vr was successful
  99100. */
  99101. success: boolean;
  99102. }
  99103. /**
  99104. * Helps to quickly add VR support to an existing scene.
  99105. * See http://doc.babylonjs.com/how_to/webvr_helper
  99106. */
  99107. export class VRExperienceHelper {
  99108. /** Options to modify the vr experience helper's behavior. */
  99109. webVROptions: VRExperienceHelperOptions;
  99110. private _scene;
  99111. private _position;
  99112. private _btnVR;
  99113. private _btnVRDisplayed;
  99114. private _webVRsupported;
  99115. private _webVRready;
  99116. private _webVRrequesting;
  99117. private _webVRpresenting;
  99118. private _hasEnteredVR;
  99119. private _fullscreenVRpresenting;
  99120. private _canvas;
  99121. private _webVRCamera;
  99122. private _vrDeviceOrientationCamera;
  99123. private _deviceOrientationCamera;
  99124. private _existingCamera;
  99125. private _onKeyDown;
  99126. private _onVrDisplayPresentChange;
  99127. private _onVRDisplayChanged;
  99128. private _onVRRequestPresentStart;
  99129. private _onVRRequestPresentComplete;
  99130. /**
  99131. * Observable raised right before entering VR.
  99132. */
  99133. onEnteringVRObservable: Observable<VRExperienceHelper>;
  99134. /**
  99135. * Observable raised when entering VR has completed.
  99136. */
  99137. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  99138. /**
  99139. * Observable raised when exiting VR.
  99140. */
  99141. onExitingVRObservable: Observable<VRExperienceHelper>;
  99142. /**
  99143. * Observable raised when controller mesh is loaded.
  99144. */
  99145. onControllerMeshLoadedObservable: Observable<WebVRController>;
  99146. /** Return this.onEnteringVRObservable
  99147. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  99148. */
  99149. readonly onEnteringVR: Observable<VRExperienceHelper>;
  99150. /** Return this.onExitingVRObservable
  99151. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  99152. */
  99153. readonly onExitingVR: Observable<VRExperienceHelper>;
  99154. /** Return this.onControllerMeshLoadedObservable
  99155. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  99156. */
  99157. readonly onControllerMeshLoaded: Observable<WebVRController>;
  99158. private _rayLength;
  99159. private _useCustomVRButton;
  99160. private _teleportationRequested;
  99161. private _teleportActive;
  99162. private _floorMeshName;
  99163. private _floorMeshesCollection;
  99164. private _rotationAllowed;
  99165. private _teleportBackwardsVector;
  99166. private _teleportationTarget;
  99167. private _isDefaultTeleportationTarget;
  99168. private _postProcessMove;
  99169. private _teleportationFillColor;
  99170. private _teleportationBorderColor;
  99171. private _rotationAngle;
  99172. private _haloCenter;
  99173. private _cameraGazer;
  99174. private _padSensibilityUp;
  99175. private _padSensibilityDown;
  99176. private _leftController;
  99177. private _rightController;
  99178. /**
  99179. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  99180. */
  99181. onNewMeshSelected: Observable<AbstractMesh>;
  99182. /**
  99183. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  99184. */
  99185. onNewMeshPicked: Observable<PickingInfo>;
  99186. private _circleEase;
  99187. /**
  99188. * Observable raised before camera teleportation
  99189. */
  99190. onBeforeCameraTeleport: Observable<Vector3>;
  99191. /**
  99192. * Observable raised after camera teleportation
  99193. */
  99194. onAfterCameraTeleport: Observable<Vector3>;
  99195. /**
  99196. * Observable raised when current selected mesh gets unselected
  99197. */
  99198. onSelectedMeshUnselected: Observable<AbstractMesh>;
  99199. private _raySelectionPredicate;
  99200. /**
  99201. * To be optionaly changed by user to define custom ray selection
  99202. */
  99203. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  99204. /**
  99205. * To be optionaly changed by user to define custom selection logic (after ray selection)
  99206. */
  99207. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  99208. /**
  99209. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  99210. */
  99211. teleportationEnabled: boolean;
  99212. private _defaultHeight;
  99213. private _teleportationInitialized;
  99214. private _interactionsEnabled;
  99215. private _interactionsRequested;
  99216. private _displayGaze;
  99217. private _displayLaserPointer;
  99218. /**
  99219. * The mesh used to display where the user is going to teleport.
  99220. */
  99221. /**
  99222. * Sets the mesh to be used to display where the user is going to teleport.
  99223. */
  99224. teleportationTarget: Mesh;
  99225. /**
  99226. * 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
  99227. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  99228. * See http://doc.babylonjs.com/resources/baking_transformations
  99229. */
  99230. gazeTrackerMesh: Mesh;
  99231. /**
  99232. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  99233. */
  99234. updateGazeTrackerScale: boolean;
  99235. /**
  99236. * If the gaze trackers color should be updated when selecting meshes
  99237. */
  99238. updateGazeTrackerColor: boolean;
  99239. /**
  99240. * The gaze tracking mesh corresponding to the left controller
  99241. */
  99242. readonly leftControllerGazeTrackerMesh: Nullable<Mesh>;
  99243. /**
  99244. * The gaze tracking mesh corresponding to the right controller
  99245. */
  99246. readonly rightControllerGazeTrackerMesh: Nullable<Mesh>;
  99247. /**
  99248. * If the ray of the gaze should be displayed.
  99249. */
  99250. /**
  99251. * Sets if the ray of the gaze should be displayed.
  99252. */
  99253. displayGaze: boolean;
  99254. /**
  99255. * If the ray of the LaserPointer should be displayed.
  99256. */
  99257. /**
  99258. * Sets if the ray of the LaserPointer should be displayed.
  99259. */
  99260. displayLaserPointer: boolean;
  99261. /**
  99262. * The deviceOrientationCamera used as the camera when not in VR.
  99263. */
  99264. readonly deviceOrientationCamera: Nullable<DeviceOrientationCamera>;
  99265. /**
  99266. * Based on the current WebVR support, returns the current VR camera used.
  99267. */
  99268. readonly currentVRCamera: Nullable<Camera>;
  99269. /**
  99270. * The webVRCamera which is used when in VR.
  99271. */
  99272. readonly webVRCamera: WebVRFreeCamera;
  99273. /**
  99274. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  99275. */
  99276. readonly vrDeviceOrientationCamera: Nullable<VRDeviceOrientationFreeCamera>;
  99277. private readonly _teleportationRequestInitiated;
  99278. /**
  99279. * Defines wether or not Pointer lock should be requested when switching to
  99280. * full screen.
  99281. */
  99282. requestPointerLockOnFullScreen: boolean;
  99283. /**
  99284. * Instantiates a VRExperienceHelper.
  99285. * Helps to quickly add VR support to an existing scene.
  99286. * @param scene The scene the VRExperienceHelper belongs to.
  99287. * @param webVROptions Options to modify the vr experience helper's behavior.
  99288. */
  99289. constructor(scene: Scene,
  99290. /** Options to modify the vr experience helper's behavior. */
  99291. webVROptions?: VRExperienceHelperOptions);
  99292. private _onDefaultMeshLoaded;
  99293. private _onResize;
  99294. private _onFullscreenChange;
  99295. /**
  99296. * Gets a value indicating if we are currently in VR mode.
  99297. */
  99298. readonly isInVRMode: boolean;
  99299. private onVrDisplayPresentChange;
  99300. private onVRDisplayChanged;
  99301. private moveButtonToBottomRight;
  99302. private displayVRButton;
  99303. private updateButtonVisibility;
  99304. private _cachedAngularSensibility;
  99305. /**
  99306. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  99307. * Otherwise, will use the fullscreen API.
  99308. */
  99309. enterVR(): void;
  99310. /**
  99311. * Attempt to exit VR, or fullscreen.
  99312. */
  99313. exitVR(): void;
  99314. /**
  99315. * The position of the vr experience helper.
  99316. */
  99317. /**
  99318. * Sets the position of the vr experience helper.
  99319. */
  99320. position: Vector3;
  99321. /**
  99322. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  99323. */
  99324. enableInteractions(): void;
  99325. private readonly _noControllerIsActive;
  99326. private beforeRender;
  99327. private _isTeleportationFloor;
  99328. /**
  99329. * Adds a floor mesh to be used for teleportation.
  99330. * @param floorMesh the mesh to be used for teleportation.
  99331. */
  99332. addFloorMesh(floorMesh: Mesh): void;
  99333. /**
  99334. * Removes a floor mesh from being used for teleportation.
  99335. * @param floorMesh the mesh to be removed.
  99336. */
  99337. removeFloorMesh(floorMesh: Mesh): void;
  99338. /**
  99339. * Enables interactions and teleportation using the VR controllers and gaze.
  99340. * @param vrTeleportationOptions options to modify teleportation behavior.
  99341. */
  99342. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  99343. private _onNewGamepadConnected;
  99344. private _tryEnableInteractionOnController;
  99345. private _onNewGamepadDisconnected;
  99346. private _enableInteractionOnController;
  99347. private _checkTeleportWithRay;
  99348. private _checkRotate;
  99349. private _checkTeleportBackwards;
  99350. private _enableTeleportationOnController;
  99351. private _createTeleportationCircles;
  99352. private _displayTeleportationTarget;
  99353. private _hideTeleportationTarget;
  99354. private _rotateCamera;
  99355. private _moveTeleportationSelectorTo;
  99356. private _workingVector;
  99357. private _workingQuaternion;
  99358. private _workingMatrix;
  99359. /**
  99360. * Teleports the users feet to the desired location
  99361. * @param location The location where the user's feet should be placed
  99362. */
  99363. teleportCamera(location: Vector3): void;
  99364. private _convertNormalToDirectionOfRay;
  99365. private _castRayAndSelectObject;
  99366. private _notifySelectedMeshUnselected;
  99367. /**
  99368. * Sets the color of the laser ray from the vr controllers.
  99369. * @param color new color for the ray.
  99370. */
  99371. changeLaserColor(color: Color3): void;
  99372. /**
  99373. * Sets the color of the ray from the vr headsets gaze.
  99374. * @param color new color for the ray.
  99375. */
  99376. changeGazeColor(color: Color3): void;
  99377. /**
  99378. * Exits VR and disposes of the vr experience helper
  99379. */
  99380. dispose(): void;
  99381. /**
  99382. * Gets the name of the VRExperienceHelper class
  99383. * @returns "VRExperienceHelper"
  99384. */
  99385. getClassName(): string;
  99386. }
  99387. }
  99388. declare module BABYLON {
  99389. /**
  99390. * Manages an XRSession
  99391. * @see https://doc.babylonjs.com/how_to/webxr
  99392. */
  99393. export class WebXRSessionManager implements IDisposable {
  99394. private scene;
  99395. /**
  99396. * Fires every time a new xrFrame arrives which can be used to update the camera
  99397. */
  99398. onXRFrameObservable: Observable<any>;
  99399. /**
  99400. * Fires when the xr session is ended either by the device or manually done
  99401. */
  99402. onXRSessionEnded: Observable<any>;
  99403. /** @hidden */
  99404. _xrSession: XRSession;
  99405. /** @hidden */
  99406. _frameOfReference: XRFrameOfReference;
  99407. /** @hidden */
  99408. _sessionRenderTargetTexture: Nullable<RenderTargetTexture>;
  99409. /** @hidden */
  99410. _currentXRFrame: Nullable<XRFrame>;
  99411. private _xrNavigator;
  99412. private _xrDevice;
  99413. private _tmpMatrix;
  99414. /**
  99415. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  99416. * @param scene The scene which the session should be created for
  99417. */
  99418. constructor(scene: Scene);
  99419. /**
  99420. * Initializes the manager
  99421. * After initialization enterXR can be called to start an XR session
  99422. * @returns Promise which resolves after it is initialized
  99423. */
  99424. initializeAsync(): Promise<void>;
  99425. /**
  99426. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  99427. * @param sessionCreationOptions xr options to create the session with
  99428. * @param frameOfReferenceType option to configure how the xr pose is expressed
  99429. * @returns Promise which resolves after it enters XR
  99430. */
  99431. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReferenceType: string): Promise<void>;
  99432. /**
  99433. * Stops the xrSession and restores the renderloop
  99434. * @returns Promise which resolves after it exits XR
  99435. */
  99436. exitXRAsync(): Promise<void>;
  99437. /**
  99438. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99439. * @param ray ray to cast into the environment
  99440. * @returns Promise which resolves with a collision point in the environment if it exists
  99441. */
  99442. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99443. /**
  99444. * Checks if a session would be supported for the creation options specified
  99445. * @param options creation options to check if they are supported
  99446. * @returns true if supported
  99447. */
  99448. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99449. /**
  99450. * @hidden
  99451. * Converts the render layer of xrSession to a render target
  99452. * @param session session to create render target for
  99453. * @param scene scene the new render target should be created for
  99454. */
  99455. static _CreateRenderTargetTextureFromSession(session: XRSession, scene: Scene): RenderTargetTexture;
  99456. /**
  99457. * Disposes of the session manager
  99458. */
  99459. dispose(): void;
  99460. }
  99461. }
  99462. declare module BABYLON {
  99463. /**
  99464. * WebXR Camera which holds the views for the xrSession
  99465. * @see https://doc.babylonjs.com/how_to/webxr
  99466. */
  99467. export class WebXRCamera extends FreeCamera {
  99468. private static _TmpMatrix;
  99469. /**
  99470. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  99471. * @param name the name of the camera
  99472. * @param scene the scene to add the camera to
  99473. */
  99474. constructor(name: string, scene: Scene);
  99475. private _updateNumberOfRigCameras;
  99476. /** @hidden */
  99477. _updateForDualEyeDebugging(pupilDistance?: number): void;
  99478. /**
  99479. * Updates the cameras position from the current pose information of the XR session
  99480. * @param xrSessionManager the session containing pose information
  99481. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  99482. */
  99483. updateFromXRSessionManager(xrSessionManager: WebXRSessionManager): boolean;
  99484. }
  99485. }
  99486. declare module BABYLON {
  99487. /**
  99488. * States of the webXR experience
  99489. */
  99490. export enum WebXRState {
  99491. /**
  99492. * Transitioning to being in XR mode
  99493. */
  99494. ENTERING_XR = 0,
  99495. /**
  99496. * Transitioning to non XR mode
  99497. */
  99498. EXITING_XR = 1,
  99499. /**
  99500. * In XR mode and presenting
  99501. */
  99502. IN_XR = 2,
  99503. /**
  99504. * Not entered XR mode
  99505. */
  99506. NOT_IN_XR = 3
  99507. }
  99508. /**
  99509. * Helper class used to enable XR
  99510. * @see https://doc.babylonjs.com/how_to/webxr
  99511. */
  99512. export class WebXRExperienceHelper implements IDisposable {
  99513. private scene;
  99514. /**
  99515. * 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
  99516. */
  99517. container: AbstractMesh;
  99518. /**
  99519. * Camera used to render xr content
  99520. */
  99521. camera: WebXRCamera;
  99522. /**
  99523. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  99524. */
  99525. state: WebXRState;
  99526. private _setState;
  99527. private static _TmpVector;
  99528. /**
  99529. * Fires when the state of the experience helper has changed
  99530. */
  99531. onStateChangedObservable: Observable<WebXRState>;
  99532. /** @hidden */
  99533. _sessionManager: WebXRSessionManager;
  99534. private _nonVRCamera;
  99535. private _originalSceneAutoClear;
  99536. private _supported;
  99537. /**
  99538. * Creates the experience helper
  99539. * @param scene the scene to attach the experience helper to
  99540. * @returns a promise for the experience helper
  99541. */
  99542. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  99543. /**
  99544. * Creates a WebXRExperienceHelper
  99545. * @param scene The scene the helper should be created in
  99546. */
  99547. private constructor();
  99548. /**
  99549. * Exits XR mode and returns the scene to its original state
  99550. * @returns promise that resolves after xr mode has exited
  99551. */
  99552. exitXRAsync(): Promise<void>;
  99553. /**
  99554. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  99555. * @param sessionCreationOptions options for the XR session
  99556. * @param frameOfReference frame of reference of the XR session
  99557. * @returns promise that resolves after xr mode has entered
  99558. */
  99559. enterXRAsync(sessionCreationOptions: XRSessionCreationOptions, frameOfReference: string): Promise<void>;
  99560. /**
  99561. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  99562. * @param ray ray to cast into the environment
  99563. * @returns Promise which resolves with a collision point in the environment if it exists
  99564. */
  99565. environmentPointHitTestAsync(ray: Ray): Promise<Nullable<Vector3>>;
  99566. /**
  99567. * Updates the global position of the camera by moving the camera's container
  99568. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  99569. * @param position The desired global position of the camera
  99570. */
  99571. setPositionOfCameraUsingContainer(position: Vector3): void;
  99572. /**
  99573. * Rotates the xr camera by rotating the camera's container around the camera's position
  99574. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  99575. * @param rotation the desired quaternion rotation to apply to the camera
  99576. */
  99577. rotateCameraByQuaternionUsingContainer(rotation: Quaternion): void;
  99578. /**
  99579. * Checks if the creation options are supported by the xr session
  99580. * @param options creation options
  99581. * @returns true if supported
  99582. */
  99583. supportsSessionAsync(options: XRSessionCreationOptions): Promise<boolean>;
  99584. /**
  99585. * Disposes of the experience helper
  99586. */
  99587. dispose(): void;
  99588. }
  99589. }
  99590. declare module BABYLON {
  99591. /**
  99592. * Button which can be used to enter a different mode of XR
  99593. */
  99594. export class WebXREnterExitUIButton {
  99595. /** button element */
  99596. element: HTMLElement;
  99597. /** XR initialization options for the button */
  99598. initializationOptions: XRSessionCreationOptions;
  99599. /**
  99600. * Creates a WebXREnterExitUIButton
  99601. * @param element button element
  99602. * @param initializationOptions XR initialization options for the button
  99603. */
  99604. constructor(
  99605. /** button element */
  99606. element: HTMLElement,
  99607. /** XR initialization options for the button */
  99608. initializationOptions: XRSessionCreationOptions);
  99609. /**
  99610. * Overwritable function which can be used to update the button's visuals when the state changes
  99611. * @param activeButton the current active button in the UI
  99612. */
  99613. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  99614. }
  99615. /**
  99616. * Options to create the webXR UI
  99617. */
  99618. export class WebXREnterExitUIOptions {
  99619. /**
  99620. * Context to enter xr with
  99621. */
  99622. outputCanvasContext?: Nullable<WebGLRenderingContext>;
  99623. /**
  99624. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  99625. */
  99626. customButtons?: Array<WebXREnterExitUIButton>;
  99627. }
  99628. /**
  99629. * UI to allow the user to enter/exit XR mode
  99630. */
  99631. export class WebXREnterExitUI implements IDisposable {
  99632. private scene;
  99633. private _overlay;
  99634. private _buttons;
  99635. private _activeButton;
  99636. /**
  99637. * Fired every time the active button is changed.
  99638. *
  99639. * When xr is entered via a button that launches xr that button will be the callback parameter
  99640. *
  99641. * When exiting xr the callback parameter will be null)
  99642. */
  99643. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  99644. /**
  99645. * Creates UI to allow the user to enter/exit XR mode
  99646. * @param scene the scene to add the ui to
  99647. * @param helper the xr experience helper to enter/exit xr with
  99648. * @param options options to configure the UI
  99649. * @returns the created ui
  99650. */
  99651. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  99652. private constructor();
  99653. private _updateButtons;
  99654. /**
  99655. * Disposes of the object
  99656. */
  99657. dispose(): void;
  99658. }
  99659. }
  99660. declare module BABYLON {
  99661. /**
  99662. * Represents an XR input
  99663. */
  99664. export class WebXRController {
  99665. /**
  99666. * 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
  99667. */
  99668. grip?: AbstractMesh;
  99669. /**
  99670. * Pointer which can be used to select objects or attach a visible laser to
  99671. */
  99672. pointer: AbstractMesh;
  99673. /**
  99674. * Creates the controller
  99675. * @see https://doc.babylonjs.com/how_to/webxr
  99676. * @param scene the scene which the controller should be associated to
  99677. */
  99678. constructor(scene: Scene);
  99679. /**
  99680. * Disposes of the object
  99681. */
  99682. dispose(): void;
  99683. }
  99684. /**
  99685. * XR input used to track XR inputs such as controllers/rays
  99686. */
  99687. export class WebXRInput implements IDisposable {
  99688. private helper;
  99689. /**
  99690. * XR controllers being tracked
  99691. */
  99692. controllers: Array<WebXRController>;
  99693. private _tmpMatrix;
  99694. private _frameObserver;
  99695. /**
  99696. * Initializes the WebXRInput
  99697. * @param helper experience helper which the input should be created for
  99698. */
  99699. constructor(helper: WebXRExperienceHelper);
  99700. /**
  99701. * Disposes of the object
  99702. */
  99703. dispose(): void;
  99704. }
  99705. }
  99706. declare module BABYLON {
  99707. /**
  99708. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  99709. */
  99710. export class WebXRManagedOutputCanvas implements IDisposable {
  99711. private _canvas;
  99712. /**
  99713. * xrpresent context of the canvas which can be used to display/mirror xr content
  99714. */
  99715. canvasContext: Nullable<WebGLRenderingContext>;
  99716. /**
  99717. * Initializes the canvas to be added/removed upon entering/exiting xr
  99718. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  99719. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  99720. */
  99721. constructor(helper: WebXRExperienceHelper, canvas?: HTMLCanvasElement);
  99722. /**
  99723. * Disposes of the object
  99724. */
  99725. dispose(): void;
  99726. private _setManagedOutputCanvas;
  99727. private _addCanvas;
  99728. private _removeCanvas;
  99729. }
  99730. }
  99731. declare module BABYLON {
  99732. /**
  99733. * Contains an array of blocks representing the octree
  99734. */
  99735. export interface IOctreeContainer<T> {
  99736. /**
  99737. * Blocks within the octree
  99738. */
  99739. blocks: Array<OctreeBlock<T>>;
  99740. }
  99741. /**
  99742. * Class used to store a cell in an octree
  99743. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99744. */
  99745. export class OctreeBlock<T> {
  99746. /**
  99747. * Gets the content of the current block
  99748. */
  99749. entries: T[];
  99750. /**
  99751. * Gets the list of block children
  99752. */
  99753. blocks: Array<OctreeBlock<T>>;
  99754. private _depth;
  99755. private _maxDepth;
  99756. private _capacity;
  99757. private _minPoint;
  99758. private _maxPoint;
  99759. private _boundingVectors;
  99760. private _creationFunc;
  99761. /**
  99762. * Creates a new block
  99763. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  99764. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  99765. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99766. * @param depth defines the current depth of this block in the octree
  99767. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  99768. * @param creationFunc defines a callback to call when an element is added to the block
  99769. */
  99770. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  99771. /**
  99772. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  99773. */
  99774. readonly capacity: number;
  99775. /**
  99776. * Gets the minimum vector (in world space) of the block's bounding box
  99777. */
  99778. readonly minPoint: Vector3;
  99779. /**
  99780. * Gets the maximum vector (in world space) of the block's bounding box
  99781. */
  99782. readonly maxPoint: Vector3;
  99783. /**
  99784. * Add a new element to this block
  99785. * @param entry defines the element to add
  99786. */
  99787. addEntry(entry: T): void;
  99788. /**
  99789. * Remove an element from this block
  99790. * @param entry defines the element to remove
  99791. */
  99792. removeEntry(entry: T): void;
  99793. /**
  99794. * Add an array of elements to this block
  99795. * @param entries defines the array of elements to add
  99796. */
  99797. addEntries(entries: T[]): void;
  99798. /**
  99799. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  99800. * @param frustumPlanes defines the frustum planes to test
  99801. * @param selection defines the array to store current content if selection is positive
  99802. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99803. */
  99804. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99805. /**
  99806. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  99807. * @param sphereCenter defines the bounding sphere center
  99808. * @param sphereRadius defines the bounding sphere radius
  99809. * @param selection defines the array to store current content if selection is positive
  99810. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99811. */
  99812. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  99813. /**
  99814. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  99815. * @param ray defines the ray to test with
  99816. * @param selection defines the array to store current content if selection is positive
  99817. */
  99818. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  99819. /**
  99820. * Subdivide the content into child blocks (this block will then be empty)
  99821. */
  99822. createInnerBlocks(): void;
  99823. /**
  99824. * @hidden
  99825. */
  99826. 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;
  99827. }
  99828. }
  99829. declare module BABYLON {
  99830. /**
  99831. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  99832. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99833. */
  99834. export class Octree<T> {
  99835. /** 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.) */
  99836. maxDepth: number;
  99837. /**
  99838. * Blocks within the octree containing objects
  99839. */
  99840. blocks: Array<OctreeBlock<T>>;
  99841. /**
  99842. * Content stored in the octree
  99843. */
  99844. dynamicContent: T[];
  99845. private _maxBlockCapacity;
  99846. private _selectionContent;
  99847. private _creationFunc;
  99848. /**
  99849. * Creates a octree
  99850. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99851. * @param creationFunc function to be used to instatiate the octree
  99852. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  99853. * @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.)
  99854. */
  99855. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  99856. /** 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.) */
  99857. maxDepth?: number);
  99858. /**
  99859. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  99860. * @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);
  99861. * @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);
  99862. * @param entries meshes to be added to the octree blocks
  99863. */
  99864. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  99865. /**
  99866. * Adds a mesh to the octree
  99867. * @param entry Mesh to add to the octree
  99868. */
  99869. addMesh(entry: T): void;
  99870. /**
  99871. * Remove an element from the octree
  99872. * @param entry defines the element to remove
  99873. */
  99874. removeMesh(entry: T): void;
  99875. /**
  99876. * Selects an array of meshes within the frustum
  99877. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  99878. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  99879. * @returns array of meshes within the frustum
  99880. */
  99881. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  99882. /**
  99883. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  99884. * @param sphereCenter defines the bounding sphere center
  99885. * @param sphereRadius defines the bounding sphere radius
  99886. * @param allowDuplicate defines if the selection array can contains duplicated entries
  99887. * @returns an array of objects that intersect the sphere
  99888. */
  99889. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  99890. /**
  99891. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  99892. * @param ray defines the ray to test with
  99893. * @returns array of intersected objects
  99894. */
  99895. intersectsRay(ray: Ray): SmartArray<T>;
  99896. /**
  99897. * Adds a mesh into the octree block if it intersects the block
  99898. */
  99899. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  99900. /**
  99901. * Adds a submesh into the octree block if it intersects the block
  99902. */
  99903. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  99904. }
  99905. }
  99906. declare module BABYLON {
  99907. interface Scene {
  99908. /**
  99909. * @hidden
  99910. * Backing Filed
  99911. */
  99912. _selectionOctree: Octree<AbstractMesh>;
  99913. /**
  99914. * Gets the octree used to boost mesh selection (picking)
  99915. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99916. */
  99917. selectionOctree: Octree<AbstractMesh>;
  99918. /**
  99919. * Creates or updates the octree used to boost selection (picking)
  99920. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99921. * @param maxCapacity defines the maximum capacity per leaf
  99922. * @param maxDepth defines the maximum depth of the octree
  99923. * @returns an octree of AbstractMesh
  99924. */
  99925. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  99926. }
  99927. interface AbstractMesh {
  99928. /**
  99929. * @hidden
  99930. * Backing Field
  99931. */
  99932. _submeshesOctree: Octree<SubMesh>;
  99933. /**
  99934. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  99935. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  99936. * @param maxCapacity defines the maximum size of each block (64 by default)
  99937. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  99938. * @returns the new octree
  99939. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  99940. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  99941. */
  99942. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  99943. }
  99944. /**
  99945. * Defines the octree scene component responsible to manage any octrees
  99946. * in a given scene.
  99947. */
  99948. export class OctreeSceneComponent {
  99949. /**
  99950. * The component name helpfull to identify the component in the list of scene components.
  99951. */
  99952. readonly name: string;
  99953. /**
  99954. * The scene the component belongs to.
  99955. */
  99956. scene: Scene;
  99957. /**
  99958. * Indicates if the meshes have been checked to make sure they are isEnabled()
  99959. */
  99960. readonly checksIsEnabled: boolean;
  99961. /**
  99962. * Creates a new instance of the component for the given scene
  99963. * @param scene Defines the scene to register the component in
  99964. */
  99965. constructor(scene: Scene);
  99966. /**
  99967. * Registers the component in a given scene
  99968. */
  99969. register(): void;
  99970. /**
  99971. * Return the list of active meshes
  99972. * @returns the list of active meshes
  99973. */
  99974. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  99975. /**
  99976. * Return the list of active sub meshes
  99977. * @param mesh The mesh to get the candidates sub meshes from
  99978. * @returns the list of active sub meshes
  99979. */
  99980. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  99981. private _tempRay;
  99982. /**
  99983. * Return the list of sub meshes intersecting with a given local ray
  99984. * @param mesh defines the mesh to find the submesh for
  99985. * @param localRay defines the ray in local space
  99986. * @returns the list of intersecting sub meshes
  99987. */
  99988. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  99989. /**
  99990. * Return the list of sub meshes colliding with a collider
  99991. * @param mesh defines the mesh to find the submesh for
  99992. * @param collider defines the collider to evaluate the collision against
  99993. * @returns the list of colliding sub meshes
  99994. */
  99995. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  99996. /**
  99997. * Rebuilds the elements related to this component in case of
  99998. * context lost for instance.
  99999. */
  100000. rebuild(): void;
  100001. /**
  100002. * Disposes the component and the associated ressources.
  100003. */
  100004. dispose(): void;
  100005. }
  100006. }
  100007. declare module BABYLON {
  100008. /**
  100009. * Renders a layer on top of an existing scene
  100010. */
  100011. export class UtilityLayerRenderer implements IDisposable {
  100012. /** the original scene that will be rendered on top of */
  100013. originalScene: Scene;
  100014. private _pointerCaptures;
  100015. private _lastPointerEvents;
  100016. private static _DefaultUtilityLayer;
  100017. private static _DefaultKeepDepthUtilityLayer;
  100018. private _sharedGizmoLight;
  100019. /**
  100020. * @hidden
  100021. * Light which used by gizmos to get light shading
  100022. */
  100023. _getSharedGizmoLight(): HemisphericLight;
  100024. /**
  100025. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  100026. */
  100027. pickUtilitySceneFirst: boolean;
  100028. /**
  100029. * 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)
  100030. */
  100031. static readonly DefaultUtilityLayer: UtilityLayerRenderer;
  100032. /**
  100033. * 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)
  100034. */
  100035. static readonly DefaultKeepDepthUtilityLayer: UtilityLayerRenderer;
  100036. /**
  100037. * The scene that is rendered on top of the original scene
  100038. */
  100039. utilityLayerScene: Scene;
  100040. /**
  100041. * If the utility layer should automatically be rendered on top of existing scene
  100042. */
  100043. shouldRender: boolean;
  100044. /**
  100045. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  100046. */
  100047. onlyCheckPointerDownEvents: boolean;
  100048. /**
  100049. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  100050. */
  100051. processAllEvents: boolean;
  100052. /**
  100053. * Observable raised when the pointer move from the utility layer scene to the main scene
  100054. */
  100055. onPointerOutObservable: Observable<number>;
  100056. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  100057. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  100058. private _afterRenderObserver;
  100059. private _sceneDisposeObserver;
  100060. private _originalPointerObserver;
  100061. /**
  100062. * Instantiates a UtilityLayerRenderer
  100063. * @param originalScene the original scene that will be rendered on top of
  100064. * @param handleEvents boolean indicating if the utility layer should handle events
  100065. */
  100066. constructor(
  100067. /** the original scene that will be rendered on top of */
  100068. originalScene: Scene, handleEvents?: boolean);
  100069. private _notifyObservers;
  100070. /**
  100071. * Renders the utility layers scene on top of the original scene
  100072. */
  100073. render(): void;
  100074. /**
  100075. * Disposes of the renderer
  100076. */
  100077. dispose(): void;
  100078. private _updateCamera;
  100079. }
  100080. }
  100081. declare module BABYLON {
  100082. /**
  100083. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  100084. */
  100085. export class Gizmo implements IDisposable {
  100086. /** The utility layer the gizmo will be added to */
  100087. gizmoLayer: UtilityLayerRenderer;
  100088. /**
  100089. * The root mesh of the gizmo
  100090. */
  100091. _rootMesh: Mesh;
  100092. private _attachedMesh;
  100093. /**
  100094. * Ratio for the scale of the gizmo (Default: 1)
  100095. */
  100096. scaleRatio: number;
  100097. /**
  100098. * If a custom mesh has been set (Default: false)
  100099. */
  100100. protected _customMeshSet: boolean;
  100101. /**
  100102. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  100103. * * When set, interactions will be enabled
  100104. */
  100105. attachedMesh: Nullable<AbstractMesh>;
  100106. /**
  100107. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  100108. * @param mesh The mesh to replace the default mesh of the gizmo
  100109. */
  100110. setCustomMesh(mesh: Mesh): void;
  100111. /**
  100112. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  100113. */
  100114. updateGizmoRotationToMatchAttachedMesh: boolean;
  100115. /**
  100116. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  100117. */
  100118. updateGizmoPositionToMatchAttachedMesh: boolean;
  100119. /**
  100120. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  100121. */
  100122. protected _updateScale: boolean;
  100123. protected _interactionsEnabled: boolean;
  100124. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100125. private _beforeRenderObserver;
  100126. private _tempVector;
  100127. /**
  100128. * Creates a gizmo
  100129. * @param gizmoLayer The utility layer the gizmo will be added to
  100130. */
  100131. constructor(
  100132. /** The utility layer the gizmo will be added to */
  100133. gizmoLayer?: UtilityLayerRenderer);
  100134. /**
  100135. * Updates the gizmo to match the attached mesh's position/rotation
  100136. */
  100137. protected _update(): void;
  100138. /**
  100139. * Disposes of the gizmo
  100140. */
  100141. dispose(): void;
  100142. }
  100143. }
  100144. declare module BABYLON {
  100145. /**
  100146. * Single axis drag gizmo
  100147. */
  100148. export class AxisDragGizmo extends Gizmo {
  100149. /**
  100150. * Drag behavior responsible for the gizmos dragging interactions
  100151. */
  100152. dragBehavior: PointerDragBehavior;
  100153. private _pointerObserver;
  100154. /**
  100155. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  100156. */
  100157. snapDistance: number;
  100158. /**
  100159. * Event that fires each time the gizmo snaps to a new location.
  100160. * * snapDistance is the the change in distance
  100161. */
  100162. onSnapObservable: Observable<{
  100163. snapDistance: number;
  100164. }>;
  100165. /** @hidden */
  100166. static _CreateArrow(scene: Scene, material: StandardMaterial): TransformNode;
  100167. /** @hidden */
  100168. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  100169. /**
  100170. * Creates an AxisDragGizmo
  100171. * @param gizmoLayer The utility layer the gizmo will be added to
  100172. * @param dragAxis The axis which the gizmo will be able to drag on
  100173. * @param color The color of the gizmo
  100174. */
  100175. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  100176. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  100177. /**
  100178. * Disposes of the gizmo
  100179. */
  100180. dispose(): void;
  100181. }
  100182. }
  100183. declare module BABYLON.Debug {
  100184. /**
  100185. * The Axes viewer will show 3 axes in a specific point in space
  100186. */
  100187. export class AxesViewer {
  100188. private _xAxis;
  100189. private _yAxis;
  100190. private _zAxis;
  100191. private _scaleLinesFactor;
  100192. private _instanced;
  100193. /**
  100194. * Gets the hosting scene
  100195. */
  100196. scene: Scene;
  100197. /**
  100198. * Gets or sets a number used to scale line length
  100199. */
  100200. scaleLines: number;
  100201. /** Gets the node hierarchy used to render x-axis */
  100202. readonly xAxis: TransformNode;
  100203. /** Gets the node hierarchy used to render y-axis */
  100204. readonly yAxis: TransformNode;
  100205. /** Gets the node hierarchy used to render z-axis */
  100206. readonly zAxis: TransformNode;
  100207. /**
  100208. * Creates a new AxesViewer
  100209. * @param scene defines the hosting scene
  100210. * @param scaleLines defines a number used to scale line length (1 by default)
  100211. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  100212. * @param xAxis defines the node hierarchy used to render the x-axis
  100213. * @param yAxis defines the node hierarchy used to render the y-axis
  100214. * @param zAxis defines the node hierarchy used to render the z-axis
  100215. */
  100216. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  100217. /**
  100218. * Force the viewer to update
  100219. * @param position defines the position of the viewer
  100220. * @param xaxis defines the x axis of the viewer
  100221. * @param yaxis defines the y axis of the viewer
  100222. * @param zaxis defines the z axis of the viewer
  100223. */
  100224. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  100225. /**
  100226. * Creates an instance of this axes viewer.
  100227. * @returns a new axes viewer with instanced meshes
  100228. */
  100229. createInstance(): AxesViewer;
  100230. /** Releases resources */
  100231. dispose(): void;
  100232. private static _SetRenderingGroupId;
  100233. }
  100234. }
  100235. declare module BABYLON.Debug {
  100236. /**
  100237. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  100238. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  100239. */
  100240. export class BoneAxesViewer extends AxesViewer {
  100241. /**
  100242. * Gets or sets the target mesh where to display the axes viewer
  100243. */
  100244. mesh: Nullable<Mesh>;
  100245. /**
  100246. * Gets or sets the target bone where to display the axes viewer
  100247. */
  100248. bone: Nullable<Bone>;
  100249. /** Gets current position */
  100250. pos: Vector3;
  100251. /** Gets direction of X axis */
  100252. xaxis: Vector3;
  100253. /** Gets direction of Y axis */
  100254. yaxis: Vector3;
  100255. /** Gets direction of Z axis */
  100256. zaxis: Vector3;
  100257. /**
  100258. * Creates a new BoneAxesViewer
  100259. * @param scene defines the hosting scene
  100260. * @param bone defines the target bone
  100261. * @param mesh defines the target mesh
  100262. * @param scaleLines defines a scaling factor for line length (1 by default)
  100263. */
  100264. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  100265. /**
  100266. * Force the viewer to update
  100267. */
  100268. update(): void;
  100269. /** Releases resources */
  100270. dispose(): void;
  100271. }
  100272. }
  100273. declare module BABYLON {
  100274. /**
  100275. * Interface used to define scene explorer extensibility option
  100276. */
  100277. export interface IExplorerExtensibilityOption {
  100278. /**
  100279. * Define the option label
  100280. */
  100281. label: string;
  100282. /**
  100283. * Defines the action to execute on click
  100284. */
  100285. action: (entity: any) => void;
  100286. }
  100287. /**
  100288. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  100289. */
  100290. export interface IExplorerExtensibilityGroup {
  100291. /**
  100292. * Defines a predicate to test if a given type mut be extended
  100293. */
  100294. predicate: (entity: any) => boolean;
  100295. /**
  100296. * Gets the list of options added to a type
  100297. */
  100298. entries: IExplorerExtensibilityOption[];
  100299. }
  100300. /**
  100301. * Interface used to define the options to use to create the Inspector
  100302. */
  100303. export interface IInspectorOptions {
  100304. /**
  100305. * Display in overlay mode (default: false)
  100306. */
  100307. overlay?: boolean;
  100308. /**
  100309. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  100310. */
  100311. globalRoot?: HTMLElement;
  100312. /**
  100313. * Display the Scene explorer
  100314. */
  100315. showExplorer?: boolean;
  100316. /**
  100317. * Display the property inspector
  100318. */
  100319. showInspector?: boolean;
  100320. /**
  100321. * Display in embed mode (both panes on the right)
  100322. */
  100323. embedMode?: boolean;
  100324. /**
  100325. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  100326. */
  100327. handleResize?: boolean;
  100328. /**
  100329. * Allow the panes to popup (default: true)
  100330. */
  100331. enablePopup?: boolean;
  100332. /**
  100333. * Allow the panes to be closed by users (default: true)
  100334. */
  100335. enableClose?: boolean;
  100336. /**
  100337. * Optional list of extensibility entries
  100338. */
  100339. explorerExtensibility?: IExplorerExtensibilityGroup[];
  100340. /**
  100341. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  100342. */
  100343. inspectorURL?: string;
  100344. }
  100345. interface Scene {
  100346. /**
  100347. * @hidden
  100348. * Backing field
  100349. */
  100350. _debugLayer: DebugLayer;
  100351. /**
  100352. * Gets the debug layer (aka Inspector) associated with the scene
  100353. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100354. */
  100355. debugLayer: DebugLayer;
  100356. }
  100357. /**
  100358. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100359. * what is happening in your scene
  100360. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100361. */
  100362. export class DebugLayer {
  100363. /**
  100364. * Define the url to get the inspector script from.
  100365. * By default it uses the babylonjs CDN.
  100366. * @ignoreNaming
  100367. */
  100368. static InspectorURL: string;
  100369. private _scene;
  100370. private BJSINSPECTOR;
  100371. /**
  100372. * Observable triggered when a property is changed through the inspector.
  100373. */
  100374. onPropertyChangedObservable: Observable<{
  100375. object: any;
  100376. property: string;
  100377. value: any;
  100378. initialValue: any;
  100379. }>;
  100380. /**
  100381. * Instantiates a new debug layer.
  100382. * The debug layer (aka Inspector) is the go to tool in order to better understand
  100383. * what is happening in your scene
  100384. * @see http://doc.babylonjs.com/features/playground_debuglayer
  100385. * @param scene Defines the scene to inspect
  100386. */
  100387. constructor(scene: Scene);
  100388. /** Creates the inspector window. */
  100389. private _createInspector;
  100390. /**
  100391. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  100392. * @param entity defines the entity to select
  100393. * @param lineContainerTitle defines the specific block to highlight
  100394. */
  100395. select(entity: any, lineContainerTitle?: string): void;
  100396. /** Get the inspector from bundle or global */
  100397. private _getGlobalInspector;
  100398. /**
  100399. * Get if the inspector is visible or not.
  100400. * @returns true if visible otherwise, false
  100401. */
  100402. isVisible(): boolean;
  100403. /**
  100404. * Hide the inspector and close its window.
  100405. */
  100406. hide(): void;
  100407. /**
  100408. * Launch the debugLayer.
  100409. * @param config Define the configuration of the inspector
  100410. * @return a promise fulfilled when the debug layer is visible
  100411. */
  100412. show(config?: IInspectorOptions): Promise<DebugLayer>;
  100413. }
  100414. }
  100415. declare module BABYLON {
  100416. /**
  100417. * Class containing static functions to help procedurally build meshes
  100418. */
  100419. export class BoxBuilder {
  100420. /**
  100421. * Creates a box mesh
  100422. * * The parameter `size` sets the size (float) of each box side (default 1)
  100423. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  100424. * * 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)
  100425. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  100426. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100427. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100428. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100429. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  100430. * @param name defines the name of the mesh
  100431. * @param options defines the options used to create the mesh
  100432. * @param scene defines the hosting scene
  100433. * @returns the box mesh
  100434. */
  100435. static CreateBox(name: string, options: {
  100436. size?: number;
  100437. width?: number;
  100438. height?: number;
  100439. depth?: number;
  100440. faceUV?: Vector4[];
  100441. faceColors?: Color4[];
  100442. sideOrientation?: number;
  100443. frontUVs?: Vector4;
  100444. backUVs?: Vector4;
  100445. wrap?: boolean;
  100446. topBaseAt?: number;
  100447. bottomBaseAt?: number;
  100448. updatable?: boolean;
  100449. }, scene?: Nullable<Scene>): Mesh;
  100450. }
  100451. }
  100452. declare module BABYLON {
  100453. /**
  100454. * Class containing static functions to help procedurally build meshes
  100455. */
  100456. export class SphereBuilder {
  100457. /**
  100458. * Creates a sphere mesh
  100459. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  100460. * * 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`)
  100461. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  100462. * * 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
  100463. * * 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)
  100464. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  100465. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  100466. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100467. * @param name defines the name of the mesh
  100468. * @param options defines the options used to create the mesh
  100469. * @param scene defines the hosting scene
  100470. * @returns the sphere mesh
  100471. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  100472. */
  100473. static CreateSphere(name: string, options: {
  100474. segments?: number;
  100475. diameter?: number;
  100476. diameterX?: number;
  100477. diameterY?: number;
  100478. diameterZ?: number;
  100479. arc?: number;
  100480. slice?: number;
  100481. sideOrientation?: number;
  100482. frontUVs?: Vector4;
  100483. backUVs?: Vector4;
  100484. updatable?: boolean;
  100485. }, scene: any): Mesh;
  100486. }
  100487. }
  100488. declare module BABYLON.Debug {
  100489. /**
  100490. * Used to show the physics impostor around the specific mesh
  100491. */
  100492. export class PhysicsViewer {
  100493. /** @hidden */
  100494. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  100495. /** @hidden */
  100496. protected _meshes: Array<Nullable<AbstractMesh>>;
  100497. /** @hidden */
  100498. protected _scene: Nullable<Scene>;
  100499. /** @hidden */
  100500. protected _numMeshes: number;
  100501. /** @hidden */
  100502. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  100503. private _renderFunction;
  100504. private _utilityLayer;
  100505. private _debugBoxMesh;
  100506. private _debugSphereMesh;
  100507. private _debugCylinderMesh;
  100508. private _debugMaterial;
  100509. private _debugMeshMeshes;
  100510. /**
  100511. * Creates a new PhysicsViewer
  100512. * @param scene defines the hosting scene
  100513. */
  100514. constructor(scene: Scene);
  100515. /** @hidden */
  100516. protected _updateDebugMeshes(): void;
  100517. /**
  100518. * Renders a specified physic impostor
  100519. * @param impostor defines the impostor to render
  100520. * @param targetMesh defines the mesh represented by the impostor
  100521. * @returns the new debug mesh used to render the impostor
  100522. */
  100523. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  100524. /**
  100525. * Hides a specified physic impostor
  100526. * @param impostor defines the impostor to hide
  100527. */
  100528. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  100529. private _getDebugMaterial;
  100530. private _getDebugBoxMesh;
  100531. private _getDebugSphereMesh;
  100532. private _getDebugCylinderMesh;
  100533. private _getDebugMeshMesh;
  100534. private _getDebugMesh;
  100535. /** Releases all resources */
  100536. dispose(): void;
  100537. }
  100538. }
  100539. declare module BABYLON {
  100540. /**
  100541. * Class containing static functions to help procedurally build meshes
  100542. */
  100543. export class LinesBuilder {
  100544. /**
  100545. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  100546. * * 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
  100547. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  100548. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  100549. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  100550. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  100551. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  100552. * * 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
  100553. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  100554. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100555. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  100556. * @param name defines the name of the new line system
  100557. * @param options defines the options used to create the line system
  100558. * @param scene defines the hosting scene
  100559. * @returns a new line system mesh
  100560. */
  100561. static CreateLineSystem(name: string, options: {
  100562. lines: Vector3[][];
  100563. updatable?: boolean;
  100564. instance?: Nullable<LinesMesh>;
  100565. colors?: Nullable<Color4[][]>;
  100566. useVertexAlpha?: boolean;
  100567. }, scene: Nullable<Scene>): LinesMesh;
  100568. /**
  100569. * Creates a line mesh
  100570. * 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
  100571. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100572. * * The parameter `points` is an array successive Vector3
  100573. * * 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
  100574. * * The optional parameter `colors` is an array of successive Color4, one per line point
  100575. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  100576. * * When updating an instance, remember that only point positions can change, not the number of points
  100577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100578. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  100579. * @param name defines the name of the new line system
  100580. * @param options defines the options used to create the line system
  100581. * @param scene defines the hosting scene
  100582. * @returns a new line mesh
  100583. */
  100584. static CreateLines(name: string, options: {
  100585. points: Vector3[];
  100586. updatable?: boolean;
  100587. instance?: Nullable<LinesMesh>;
  100588. colors?: Color4[];
  100589. useVertexAlpha?: boolean;
  100590. }, scene?: Nullable<Scene>): LinesMesh;
  100591. /**
  100592. * Creates a dashed line mesh
  100593. * * 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
  100594. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  100595. * * The parameter `points` is an array successive Vector3
  100596. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  100597. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  100598. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  100599. * * 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
  100600. * * When updating an instance, remember that only point positions can change, not the number of points
  100601. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  100602. * @param name defines the name of the mesh
  100603. * @param options defines the options used to create the mesh
  100604. * @param scene defines the hosting scene
  100605. * @returns the dashed line mesh
  100606. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  100607. */
  100608. static CreateDashedLines(name: string, options: {
  100609. points: Vector3[];
  100610. dashSize?: number;
  100611. gapSize?: number;
  100612. dashNb?: number;
  100613. updatable?: boolean;
  100614. instance?: LinesMesh;
  100615. }, scene?: Nullable<Scene>): LinesMesh;
  100616. }
  100617. }
  100618. declare module BABYLON {
  100619. /**
  100620. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100621. * in order to better appreciate the issue one might have.
  100622. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100623. */
  100624. export class RayHelper {
  100625. /**
  100626. * Defines the ray we are currently tryin to visualize.
  100627. */
  100628. ray: Nullable<Ray>;
  100629. private _renderPoints;
  100630. private _renderLine;
  100631. private _renderFunction;
  100632. private _scene;
  100633. private _updateToMeshFunction;
  100634. private _attachedToMesh;
  100635. private _meshSpaceDirection;
  100636. private _meshSpaceOrigin;
  100637. /**
  100638. * Helper function to create a colored helper in a scene in one line.
  100639. * @param ray Defines the ray we are currently tryin to visualize
  100640. * @param scene Defines the scene the ray is used in
  100641. * @param color Defines the color we want to see the ray in
  100642. * @returns The newly created ray helper.
  100643. */
  100644. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  100645. /**
  100646. * Instantiate a new ray helper.
  100647. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  100648. * in order to better appreciate the issue one might have.
  100649. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  100650. * @param ray Defines the ray we are currently tryin to visualize
  100651. */
  100652. constructor(ray: Ray);
  100653. /**
  100654. * Shows the ray we are willing to debug.
  100655. * @param scene Defines the scene the ray needs to be rendered in
  100656. * @param color Defines the color the ray needs to be rendered in
  100657. */
  100658. show(scene: Scene, color?: Color3): void;
  100659. /**
  100660. * Hides the ray we are debugging.
  100661. */
  100662. hide(): void;
  100663. private _render;
  100664. /**
  100665. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  100666. * @param mesh Defines the mesh we want the helper attached to
  100667. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  100668. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  100669. * @param length Defines the length of the ray
  100670. */
  100671. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  100672. /**
  100673. * Detach the ray helper from the mesh it has previously been attached to.
  100674. */
  100675. detachFromMesh(): void;
  100676. private _updateToMesh;
  100677. /**
  100678. * Dispose the helper and release its associated resources.
  100679. */
  100680. dispose(): void;
  100681. }
  100682. }
  100683. declare module BABYLON.Debug {
  100684. /**
  100685. * Class used to render a debug view of a given skeleton
  100686. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  100687. */
  100688. export class SkeletonViewer {
  100689. /** defines the skeleton to render */
  100690. skeleton: Skeleton;
  100691. /** defines the mesh attached to the skeleton */
  100692. mesh: AbstractMesh;
  100693. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100694. autoUpdateBonesMatrices: boolean;
  100695. /** defines the rendering group id to use with the viewer */
  100696. renderingGroupId: number;
  100697. /** Gets or sets the color used to render the skeleton */
  100698. color: Color3;
  100699. private _scene;
  100700. private _debugLines;
  100701. private _debugMesh;
  100702. private _isEnabled;
  100703. private _renderFunction;
  100704. private _utilityLayer;
  100705. /**
  100706. * Returns the mesh used to render the bones
  100707. */
  100708. readonly debugMesh: Nullable<LinesMesh>;
  100709. /**
  100710. * Creates a new SkeletonViewer
  100711. * @param skeleton defines the skeleton to render
  100712. * @param mesh defines the mesh attached to the skeleton
  100713. * @param scene defines the hosting scene
  100714. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  100715. * @param renderingGroupId defines the rendering group id to use with the viewer
  100716. */
  100717. constructor(
  100718. /** defines the skeleton to render */
  100719. skeleton: Skeleton,
  100720. /** defines the mesh attached to the skeleton */
  100721. mesh: AbstractMesh, scene: Scene,
  100722. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  100723. autoUpdateBonesMatrices?: boolean,
  100724. /** defines the rendering group id to use with the viewer */
  100725. renderingGroupId?: number);
  100726. /** Gets or sets a boolean indicating if the viewer is enabled */
  100727. isEnabled: boolean;
  100728. private _getBonePosition;
  100729. private _getLinesForBonesWithLength;
  100730. private _getLinesForBonesNoLength;
  100731. /** Update the viewer to sync with current skeleton state */
  100732. update(): void;
  100733. /** Release associated resources */
  100734. dispose(): void;
  100735. }
  100736. }
  100737. declare module BABYLON {
  100738. /**
  100739. * Options to create the null engine
  100740. */
  100741. export class NullEngineOptions {
  100742. /**
  100743. * Render width (Default: 512)
  100744. */
  100745. renderWidth: number;
  100746. /**
  100747. * Render height (Default: 256)
  100748. */
  100749. renderHeight: number;
  100750. /**
  100751. * Texture size (Default: 512)
  100752. */
  100753. textureSize: number;
  100754. /**
  100755. * If delta time between frames should be constant
  100756. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100757. */
  100758. deterministicLockstep: boolean;
  100759. /**
  100760. * Maximum about of steps between frames (Default: 4)
  100761. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100762. */
  100763. lockstepMaxSteps: number;
  100764. }
  100765. /**
  100766. * The null engine class provides support for headless version of babylon.js.
  100767. * This can be used in server side scenario or for testing purposes
  100768. */
  100769. export class NullEngine extends Engine {
  100770. private _options;
  100771. /**
  100772. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  100773. */
  100774. isDeterministicLockStep(): boolean;
  100775. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  100776. getLockstepMaxSteps(): number;
  100777. /**
  100778. * Sets hardware scaling, used to save performance if needed
  100779. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  100780. */
  100781. getHardwareScalingLevel(): number;
  100782. constructor(options?: NullEngineOptions);
  100783. createVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100784. createIndexBuffer(indices: IndicesArray): WebGLBuffer;
  100785. clear(color: Color4, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  100786. getRenderWidth(useScreen?: boolean): number;
  100787. getRenderHeight(useScreen?: boolean): number;
  100788. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  100789. createShaderProgram(vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  100790. getUniforms(shaderProgram: WebGLProgram, uniformsNames: string[]): WebGLUniformLocation[];
  100791. getAttributes(shaderProgram: WebGLProgram, attributesNames: string[]): number[];
  100792. bindSamplers(effect: Effect): void;
  100793. enableEffect(effect: Effect): void;
  100794. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  100795. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): void;
  100796. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): void;
  100797. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): void;
  100798. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): void;
  100799. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): void;
  100800. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): void;
  100801. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): void;
  100802. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): void;
  100803. setArray(uniform: WebGLUniformLocation, array: number[]): void;
  100804. setArray2(uniform: WebGLUniformLocation, array: number[]): void;
  100805. setArray3(uniform: WebGLUniformLocation, array: number[]): void;
  100806. setArray4(uniform: WebGLUniformLocation, array: number[]): void;
  100807. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): void;
  100808. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  100809. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100810. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): void;
  100811. setFloat(uniform: WebGLUniformLocation, value: number): void;
  100812. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): void;
  100813. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): void;
  100814. setBool(uniform: WebGLUniformLocation, bool: number): void;
  100815. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): void;
  100816. setColor3(uniform: WebGLUniformLocation, color3: Color3): void;
  100817. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): void;
  100818. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  100819. bindBuffers(vertexBuffers: {
  100820. [key: string]: VertexBuffer;
  100821. }, indexBuffer: WebGLBuffer, effect: Effect): void;
  100822. wipeCaches(bruteForce?: boolean): void;
  100823. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  100824. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  100825. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  100826. /** @hidden */
  100827. _createTexture(): WebGLTexture;
  100828. /** @hidden */
  100829. _releaseTexture(texture: InternalTexture): void;
  100830. 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;
  100831. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  100832. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  100833. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  100834. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  100835. createDynamicVertexBuffer(vertices: FloatArray): WebGLBuffer;
  100836. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  100837. areAllEffectsReady(): boolean;
  100838. /**
  100839. * @hidden
  100840. * Get the current error code of the webGL context
  100841. * @returns the error code
  100842. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  100843. */
  100844. getError(): number;
  100845. /** @hidden */
  100846. _getUnpackAlignement(): number;
  100847. /** @hidden */
  100848. _unpackFlipY(value: boolean): void;
  100849. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  100850. /**
  100851. * Updates a dynamic vertex buffer.
  100852. * @param vertexBuffer the vertex buffer to update
  100853. * @param data the data used to update the vertex buffer
  100854. * @param byteOffset the byte offset of the data (optional)
  100855. * @param byteLength the byte length of the data (optional)
  100856. */
  100857. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  100858. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  100859. /** @hidden */
  100860. _bindTexture(channel: number, texture: InternalTexture): void;
  100861. /** @hidden */
  100862. _releaseBuffer(buffer: WebGLBuffer): boolean;
  100863. releaseEffects(): void;
  100864. displayLoadingUI(): void;
  100865. hideLoadingUI(): void;
  100866. /** @hidden */
  100867. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100868. /** @hidden */
  100869. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100870. /** @hidden */
  100871. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  100872. /** @hidden */
  100873. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  100874. }
  100875. }
  100876. declare module BABYLON {
  100877. /** @hidden */
  100878. export class _OcclusionDataStorage {
  100879. /** @hidden */
  100880. occlusionInternalRetryCounter: number;
  100881. /** @hidden */
  100882. isOcclusionQueryInProgress: boolean;
  100883. /** @hidden */
  100884. isOccluded: boolean;
  100885. /** @hidden */
  100886. occlusionRetryCount: number;
  100887. /** @hidden */
  100888. occlusionType: number;
  100889. /** @hidden */
  100890. occlusionQueryAlgorithmType: number;
  100891. }
  100892. interface Engine {
  100893. /**
  100894. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  100895. * @return the new query
  100896. */
  100897. createQuery(): WebGLQuery;
  100898. /**
  100899. * Delete and release a webGL query
  100900. * @param query defines the query to delete
  100901. * @return the current engine
  100902. */
  100903. deleteQuery(query: WebGLQuery): Engine;
  100904. /**
  100905. * Check if a given query has resolved and got its value
  100906. * @param query defines the query to check
  100907. * @returns true if the query got its value
  100908. */
  100909. isQueryResultAvailable(query: WebGLQuery): boolean;
  100910. /**
  100911. * Gets the value of a given query
  100912. * @param query defines the query to check
  100913. * @returns the value of the query
  100914. */
  100915. getQueryResult(query: WebGLQuery): number;
  100916. /**
  100917. * Initiates an occlusion query
  100918. * @param algorithmType defines the algorithm to use
  100919. * @param query defines the query to use
  100920. * @returns the current engine
  100921. * @see http://doc.babylonjs.com/features/occlusionquery
  100922. */
  100923. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  100924. /**
  100925. * Ends an occlusion query
  100926. * @see http://doc.babylonjs.com/features/occlusionquery
  100927. * @param algorithmType defines the algorithm to use
  100928. * @returns the current engine
  100929. */
  100930. endOcclusionQuery(algorithmType: number): Engine;
  100931. /**
  100932. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  100933. * Please note that only one query can be issued at a time
  100934. * @returns a time token used to track the time span
  100935. */
  100936. startTimeQuery(): Nullable<_TimeToken>;
  100937. /**
  100938. * Ends a time query
  100939. * @param token defines the token used to measure the time span
  100940. * @returns the time spent (in ns)
  100941. */
  100942. endTimeQuery(token: _TimeToken): int;
  100943. /** @hidden */
  100944. _currentNonTimestampToken: Nullable<_TimeToken>;
  100945. /** @hidden */
  100946. _createTimeQuery(): WebGLQuery;
  100947. /** @hidden */
  100948. _deleteTimeQuery(query: WebGLQuery): void;
  100949. /** @hidden */
  100950. _getGlAlgorithmType(algorithmType: number): number;
  100951. /** @hidden */
  100952. _getTimeQueryResult(query: WebGLQuery): any;
  100953. /** @hidden */
  100954. _getTimeQueryAvailability(query: WebGLQuery): any;
  100955. }
  100956. interface AbstractMesh {
  100957. /**
  100958. * Backing filed
  100959. * @hidden
  100960. */
  100961. __occlusionDataStorage: _OcclusionDataStorage;
  100962. /**
  100963. * Access property
  100964. * @hidden
  100965. */
  100966. _occlusionDataStorage: _OcclusionDataStorage;
  100967. /**
  100968. * 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.
  100969. * The default value is -1 which means don't break the query and wait till the result
  100970. * @see http://doc.babylonjs.com/features/occlusionquery
  100971. */
  100972. occlusionRetryCount: number;
  100973. /**
  100974. * 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:
  100975. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  100976. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  100977. * * 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.
  100978. * @see http://doc.babylonjs.com/features/occlusionquery
  100979. */
  100980. occlusionType: number;
  100981. /**
  100982. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  100983. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  100984. * * 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.
  100985. * @see http://doc.babylonjs.com/features/occlusionquery
  100986. */
  100987. occlusionQueryAlgorithmType: number;
  100988. /**
  100989. * 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
  100990. * @see http://doc.babylonjs.com/features/occlusionquery
  100991. */
  100992. isOccluded: boolean;
  100993. /**
  100994. * Flag to check the progress status of the query
  100995. * @see http://doc.babylonjs.com/features/occlusionquery
  100996. */
  100997. isOcclusionQueryInProgress: boolean;
  100998. }
  100999. }
  101000. declare module BABYLON {
  101001. /** @hidden */
  101002. export var _forceTransformFeedbackToBundle: boolean;
  101003. interface Engine {
  101004. /**
  101005. * Creates a webGL transform feedback object
  101006. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  101007. * @returns the webGL transform feedback object
  101008. */
  101009. createTransformFeedback(): WebGLTransformFeedback;
  101010. /**
  101011. * Delete a webGL transform feedback object
  101012. * @param value defines the webGL transform feedback object to delete
  101013. */
  101014. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  101015. /**
  101016. * Bind a webGL transform feedback object to the webgl context
  101017. * @param value defines the webGL transform feedback object to bind
  101018. */
  101019. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  101020. /**
  101021. * Begins a transform feedback operation
  101022. * @param usePoints defines if points or triangles must be used
  101023. */
  101024. beginTransformFeedback(usePoints: boolean): void;
  101025. /**
  101026. * Ends a transform feedback operation
  101027. */
  101028. endTransformFeedback(): void;
  101029. /**
  101030. * Specify the varyings to use with transform feedback
  101031. * @param program defines the associated webGL program
  101032. * @param value defines the list of strings representing the varying names
  101033. */
  101034. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  101035. /**
  101036. * Bind a webGL buffer for a transform feedback operation
  101037. * @param value defines the webGL buffer to bind
  101038. */
  101039. bindTransformFeedbackBuffer(value: Nullable<WebGLBuffer>): void;
  101040. }
  101041. }
  101042. declare module BABYLON {
  101043. /**
  101044. * Gather the list of clipboard event types as constants.
  101045. */
  101046. export class ClipboardEventTypes {
  101047. /**
  101048. * The clipboard event is fired when a copy command is active (pressed).
  101049. */
  101050. static readonly COPY: number;
  101051. /**
  101052. * The clipboard event is fired when a cut command is active (pressed).
  101053. */
  101054. static readonly CUT: number;
  101055. /**
  101056. * The clipboard event is fired when a paste command is active (pressed).
  101057. */
  101058. static readonly PASTE: number;
  101059. }
  101060. /**
  101061. * This class is used to store clipboard related info for the onClipboardObservable event.
  101062. */
  101063. export class ClipboardInfo {
  101064. /**
  101065. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101066. */
  101067. type: number;
  101068. /**
  101069. * Defines the related dom event
  101070. */
  101071. event: ClipboardEvent;
  101072. /**
  101073. *Creates an instance of ClipboardInfo.
  101074. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  101075. * @param event Defines the related dom event
  101076. */
  101077. constructor(
  101078. /**
  101079. * Defines the type of event (BABYLON.ClipboardEventTypes)
  101080. */
  101081. type: number,
  101082. /**
  101083. * Defines the related dom event
  101084. */
  101085. event: ClipboardEvent);
  101086. /**
  101087. * Get the clipboard event's type from the keycode.
  101088. * @param keyCode Defines the keyCode for the current keyboard event.
  101089. * @return {number}
  101090. */
  101091. static GetTypeFromCharacter(keyCode: number): number;
  101092. }
  101093. }
  101094. declare module BABYLON {
  101095. /**
  101096. * Class used to represent data loading progression
  101097. */
  101098. export class SceneLoaderProgressEvent {
  101099. /** defines if data length to load can be evaluated */
  101100. readonly lengthComputable: boolean;
  101101. /** defines the loaded data length */
  101102. readonly loaded: number;
  101103. /** defines the data length to load */
  101104. readonly total: number;
  101105. /**
  101106. * Create a new progress event
  101107. * @param lengthComputable defines if data length to load can be evaluated
  101108. * @param loaded defines the loaded data length
  101109. * @param total defines the data length to load
  101110. */
  101111. constructor(
  101112. /** defines if data length to load can be evaluated */
  101113. lengthComputable: boolean,
  101114. /** defines the loaded data length */
  101115. loaded: number,
  101116. /** defines the data length to load */
  101117. total: number);
  101118. /**
  101119. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  101120. * @param event defines the source event
  101121. * @returns a new SceneLoaderProgressEvent
  101122. */
  101123. static FromProgressEvent(event: ProgressEvent): SceneLoaderProgressEvent;
  101124. }
  101125. /**
  101126. * Interface used by SceneLoader plugins to define supported file extensions
  101127. */
  101128. export interface ISceneLoaderPluginExtensions {
  101129. /**
  101130. * Defines the list of supported extensions
  101131. */
  101132. [extension: string]: {
  101133. isBinary: boolean;
  101134. };
  101135. }
  101136. /**
  101137. * Interface used by SceneLoader plugin factory
  101138. */
  101139. export interface ISceneLoaderPluginFactory {
  101140. /**
  101141. * Defines the name of the factory
  101142. */
  101143. name: string;
  101144. /**
  101145. * Function called to create a new plugin
  101146. * @return the new plugin
  101147. */
  101148. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  101149. /**
  101150. * Boolean indicating if the plugin can direct load specific data
  101151. */
  101152. canDirectLoad?: (data: string) => boolean;
  101153. }
  101154. /**
  101155. * Interface used to define a SceneLoader plugin
  101156. */
  101157. export interface ISceneLoaderPlugin {
  101158. /**
  101159. * The friendly name of this plugin.
  101160. */
  101161. name: string;
  101162. /**
  101163. * The file extensions supported by this plugin.
  101164. */
  101165. extensions: string | ISceneLoaderPluginExtensions;
  101166. /**
  101167. * Import meshes into a scene.
  101168. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101169. * @param scene The scene to import into
  101170. * @param data The data to import
  101171. * @param rootUrl The root url for scene and resources
  101172. * @param meshes The meshes array to import into
  101173. * @param particleSystems The particle systems array to import into
  101174. * @param skeletons The skeletons array to import into
  101175. * @param onError The callback when import fails
  101176. * @returns True if successful or false otherwise
  101177. */
  101178. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  101179. /**
  101180. * Load into a scene.
  101181. * @param scene The scene to load into
  101182. * @param data The data to import
  101183. * @param rootUrl The root url for scene and resources
  101184. * @param onError The callback when import fails
  101185. * @returns true if successful or false otherwise
  101186. */
  101187. load(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  101188. /**
  101189. * The callback that returns true if the data can be directly loaded.
  101190. */
  101191. canDirectLoad?: (data: string) => boolean;
  101192. /**
  101193. * The callback that allows custom handling of the root url based on the response url.
  101194. */
  101195. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101196. /**
  101197. * Load into an asset container.
  101198. * @param scene The scene to load into
  101199. * @param data The data to import
  101200. * @param rootUrl The root url for scene and resources
  101201. * @param onError The callback when import fails
  101202. * @returns The loaded asset container
  101203. */
  101204. loadAssetContainer(scene: Scene, data: string, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  101205. }
  101206. /**
  101207. * Interface used to define an async SceneLoader plugin
  101208. */
  101209. export interface ISceneLoaderPluginAsync {
  101210. /**
  101211. * The friendly name of this plugin.
  101212. */
  101213. name: string;
  101214. /**
  101215. * The file extensions supported by this plugin.
  101216. */
  101217. extensions: string | ISceneLoaderPluginExtensions;
  101218. /**
  101219. * Import meshes into a scene.
  101220. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101221. * @param scene The scene to import into
  101222. * @param data The data to import
  101223. * @param rootUrl The root url for scene and resources
  101224. * @param onProgress The callback when the load progresses
  101225. * @param fileName Defines the name of the file to load
  101226. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  101227. */
  101228. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  101229. meshes: AbstractMesh[];
  101230. particleSystems: IParticleSystem[];
  101231. skeletons: Skeleton[];
  101232. animationGroups: AnimationGroup[];
  101233. }>;
  101234. /**
  101235. * Load into a scene.
  101236. * @param scene The scene to load into
  101237. * @param data The data to import
  101238. * @param rootUrl The root url for scene and resources
  101239. * @param onProgress The callback when the load progresses
  101240. * @param fileName Defines the name of the file to load
  101241. * @returns Nothing
  101242. */
  101243. loadAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  101244. /**
  101245. * The callback that returns true if the data can be directly loaded.
  101246. */
  101247. canDirectLoad?: (data: string) => boolean;
  101248. /**
  101249. * The callback that allows custom handling of the root url based on the response url.
  101250. */
  101251. rewriteRootURL?: (rootUrl: string, responseURL?: string) => string;
  101252. /**
  101253. * Load into an asset container.
  101254. * @param scene The scene to load into
  101255. * @param data The data to import
  101256. * @param rootUrl The root url for scene and resources
  101257. * @param onProgress The callback when the load progresses
  101258. * @param fileName Defines the name of the file to load
  101259. * @returns The loaded asset container
  101260. */
  101261. loadAssetContainerAsync(scene: Scene, data: string, rootUrl: string, onProgress?: (event: SceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  101262. }
  101263. /**
  101264. * Class used to load scene from various file formats using registered plugins
  101265. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  101266. */
  101267. export class SceneLoader {
  101268. /**
  101269. * No logging while loading
  101270. */
  101271. static readonly NO_LOGGING: number;
  101272. /**
  101273. * Minimal logging while loading
  101274. */
  101275. static readonly MINIMAL_LOGGING: number;
  101276. /**
  101277. * Summary logging while loading
  101278. */
  101279. static readonly SUMMARY_LOGGING: number;
  101280. /**
  101281. * Detailled logging while loading
  101282. */
  101283. static readonly DETAILED_LOGGING: number;
  101284. /**
  101285. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  101286. */
  101287. static ForceFullSceneLoadingForIncremental: boolean;
  101288. /**
  101289. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  101290. */
  101291. static ShowLoadingScreen: boolean;
  101292. /**
  101293. * Defines the current logging level (while loading the scene)
  101294. * @ignorenaming
  101295. */
  101296. static loggingLevel: number;
  101297. /**
  101298. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  101299. */
  101300. static CleanBoneMatrixWeights: boolean;
  101301. /**
  101302. * Event raised when a plugin is used to load a scene
  101303. */
  101304. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  101305. private static _registeredPlugins;
  101306. private static _getDefaultPlugin;
  101307. private static _getPluginForExtension;
  101308. private static _getPluginForDirectLoad;
  101309. private static _getPluginForFilename;
  101310. private static _getDirectLoad;
  101311. private static _loadData;
  101312. private static _getFileInfo;
  101313. /**
  101314. * Gets a plugin that can load the given extension
  101315. * @param extension defines the extension to load
  101316. * @returns a plugin or null if none works
  101317. */
  101318. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  101319. /**
  101320. * Gets a boolean indicating that the given extension can be loaded
  101321. * @param extension defines the extension to load
  101322. * @returns true if the extension is supported
  101323. */
  101324. static IsPluginForExtensionAvailable(extension: string): boolean;
  101325. /**
  101326. * Adds a new plugin to the list of registered plugins
  101327. * @param plugin defines the plugin to add
  101328. */
  101329. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  101330. /**
  101331. * Import meshes into a scene
  101332. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101333. * @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)
  101334. * @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)
  101335. * @param scene the instance of BABYLON.Scene to append to
  101336. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  101337. * @param onProgress a callback with a progress event for each file being loaded
  101338. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101339. * @param pluginExtension the extension used to determine the plugin
  101340. * @returns The loaded plugin
  101341. */
  101342. 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>;
  101343. /**
  101344. * Import meshes into a scene
  101345. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  101346. * @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)
  101347. * @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)
  101348. * @param scene the instance of BABYLON.Scene to append to
  101349. * @param onProgress a callback with a progress event for each file being loaded
  101350. * @param pluginExtension the extension used to determine the plugin
  101351. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  101352. */
  101353. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  101354. meshes: AbstractMesh[];
  101355. particleSystems: IParticleSystem[];
  101356. skeletons: Skeleton[];
  101357. animationGroups: AnimationGroup[];
  101358. }>;
  101359. /**
  101360. * Load a scene
  101361. * @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)
  101362. * @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)
  101363. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101364. * @param onSuccess a callback with the scene when import succeeds
  101365. * @param onProgress a callback with a progress event for each file being loaded
  101366. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101367. * @param pluginExtension the extension used to determine the plugin
  101368. * @returns The loaded plugin
  101369. */
  101370. 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>;
  101371. /**
  101372. * Load a scene
  101373. * @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)
  101374. * @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)
  101375. * @param engine is the instance of BABYLON.Engine to use to create the scene
  101376. * @param onProgress a callback with a progress event for each file being loaded
  101377. * @param pluginExtension the extension used to determine the plugin
  101378. * @returns The loaded scene
  101379. */
  101380. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101381. /**
  101382. * Append a scene
  101383. * @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)
  101384. * @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)
  101385. * @param scene is the instance of BABYLON.Scene to append to
  101386. * @param onSuccess a callback with the scene when import succeeds
  101387. * @param onProgress a callback with a progress event for each file being loaded
  101388. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101389. * @param pluginExtension the extension used to determine the plugin
  101390. * @returns The loaded plugin
  101391. */
  101392. 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>;
  101393. /**
  101394. * Append a scene
  101395. * @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)
  101396. * @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)
  101397. * @param scene is the instance of BABYLON.Scene to append to
  101398. * @param onProgress a callback with a progress event for each file being loaded
  101399. * @param pluginExtension the extension used to determine the plugin
  101400. * @returns The given scene
  101401. */
  101402. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  101403. /**
  101404. * Load a scene into an asset container
  101405. * @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)
  101406. * @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)
  101407. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  101408. * @param onSuccess a callback with the scene when import succeeds
  101409. * @param onProgress a callback with a progress event for each file being loaded
  101410. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  101411. * @param pluginExtension the extension used to determine the plugin
  101412. * @returns The loaded plugin
  101413. */
  101414. 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>;
  101415. /**
  101416. * Load a scene into an asset container
  101417. * @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)
  101418. * @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)
  101419. * @param scene is the instance of Scene to append to
  101420. * @param onProgress a callback with a progress event for each file being loaded
  101421. * @param pluginExtension the extension used to determine the plugin
  101422. * @returns The loaded asset container
  101423. */
  101424. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: SceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  101425. }
  101426. }
  101427. declare module BABYLON {
  101428. /**
  101429. * Google Daydream controller
  101430. */
  101431. export class DaydreamController extends WebVRController {
  101432. /**
  101433. * Base Url for the controller model.
  101434. */
  101435. static MODEL_BASE_URL: string;
  101436. /**
  101437. * File name for the controller model.
  101438. */
  101439. static MODEL_FILENAME: string;
  101440. /**
  101441. * Gamepad Id prefix used to identify Daydream Controller.
  101442. */
  101443. static readonly GAMEPAD_ID_PREFIX: string;
  101444. /**
  101445. * Creates a new DaydreamController from a gamepad
  101446. * @param vrGamepad the gamepad that the controller should be created from
  101447. */
  101448. constructor(vrGamepad: any);
  101449. /**
  101450. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101451. * @param scene scene in which to add meshes
  101452. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101453. */
  101454. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101455. /**
  101456. * Called once for each button that changed state since the last frame
  101457. * @param buttonIdx Which button index changed
  101458. * @param state New state of the button
  101459. * @param changes Which properties on the state changed since last frame
  101460. */
  101461. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101462. }
  101463. }
  101464. declare module BABYLON {
  101465. /**
  101466. * Gear VR Controller
  101467. */
  101468. export class GearVRController extends WebVRController {
  101469. /**
  101470. * Base Url for the controller model.
  101471. */
  101472. static MODEL_BASE_URL: string;
  101473. /**
  101474. * File name for the controller model.
  101475. */
  101476. static MODEL_FILENAME: string;
  101477. /**
  101478. * Gamepad Id prefix used to identify this controller.
  101479. */
  101480. static readonly GAMEPAD_ID_PREFIX: string;
  101481. private readonly _buttonIndexToObservableNameMap;
  101482. /**
  101483. * Creates a new GearVRController from a gamepad
  101484. * @param vrGamepad the gamepad that the controller should be created from
  101485. */
  101486. constructor(vrGamepad: any);
  101487. /**
  101488. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101489. * @param scene scene in which to add meshes
  101490. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101491. */
  101492. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101493. /**
  101494. * Called once for each button that changed state since the last frame
  101495. * @param buttonIdx Which button index changed
  101496. * @param state New state of the button
  101497. * @param changes Which properties on the state changed since last frame
  101498. */
  101499. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101500. }
  101501. }
  101502. declare module BABYLON {
  101503. /**
  101504. * Generic Controller
  101505. */
  101506. export class GenericController extends WebVRController {
  101507. /**
  101508. * Base Url for the controller model.
  101509. */
  101510. static readonly MODEL_BASE_URL: string;
  101511. /**
  101512. * File name for the controller model.
  101513. */
  101514. static readonly MODEL_FILENAME: string;
  101515. /**
  101516. * Creates a new GenericController from a gamepad
  101517. * @param vrGamepad the gamepad that the controller should be created from
  101518. */
  101519. constructor(vrGamepad: any);
  101520. /**
  101521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101522. * @param scene scene in which to add meshes
  101523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101524. */
  101525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101526. /**
  101527. * Called once for each button that changed state since the last frame
  101528. * @param buttonIdx Which button index changed
  101529. * @param state New state of the button
  101530. * @param changes Which properties on the state changed since last frame
  101531. */
  101532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101533. }
  101534. }
  101535. declare module BABYLON {
  101536. /**
  101537. * Oculus Touch Controller
  101538. */
  101539. export class OculusTouchController extends WebVRController {
  101540. /**
  101541. * Base Url for the controller model.
  101542. */
  101543. static MODEL_BASE_URL: string;
  101544. /**
  101545. * File name for the left controller model.
  101546. */
  101547. static MODEL_LEFT_FILENAME: string;
  101548. /**
  101549. * File name for the right controller model.
  101550. */
  101551. static MODEL_RIGHT_FILENAME: string;
  101552. /**
  101553. * Fired when the secondary trigger on this controller is modified
  101554. */
  101555. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  101556. /**
  101557. * Fired when the thumb rest on this controller is modified
  101558. */
  101559. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  101560. /**
  101561. * Creates a new OculusTouchController from a gamepad
  101562. * @param vrGamepad the gamepad that the controller should be created from
  101563. */
  101564. constructor(vrGamepad: any);
  101565. /**
  101566. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101567. * @param scene scene in which to add meshes
  101568. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101569. */
  101570. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101571. /**
  101572. * Fired when the A button on this controller is modified
  101573. */
  101574. readonly onAButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101575. /**
  101576. * Fired when the B button on this controller is modified
  101577. */
  101578. readonly onBButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101579. /**
  101580. * Fired when the X button on this controller is modified
  101581. */
  101582. readonly onXButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101583. /**
  101584. * Fired when the Y button on this controller is modified
  101585. */
  101586. readonly onYButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101587. /**
  101588. * Called once for each button that changed state since the last frame
  101589. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  101590. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  101591. * 2) secondary trigger (same)
  101592. * 3) A (right) X (left), touch, pressed = value
  101593. * 4) B / Y
  101594. * 5) thumb rest
  101595. * @param buttonIdx Which button index changed
  101596. * @param state New state of the button
  101597. * @param changes Which properties on the state changed since last frame
  101598. */
  101599. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101600. }
  101601. }
  101602. declare module BABYLON {
  101603. /**
  101604. * Vive Controller
  101605. */
  101606. export class ViveController extends WebVRController {
  101607. /**
  101608. * Base Url for the controller model.
  101609. */
  101610. static MODEL_BASE_URL: string;
  101611. /**
  101612. * File name for the controller model.
  101613. */
  101614. static MODEL_FILENAME: string;
  101615. /**
  101616. * Creates a new ViveController from a gamepad
  101617. * @param vrGamepad the gamepad that the controller should be created from
  101618. */
  101619. constructor(vrGamepad: any);
  101620. /**
  101621. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101622. * @param scene scene in which to add meshes
  101623. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101624. */
  101625. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  101626. /**
  101627. * Fired when the left button on this controller is modified
  101628. */
  101629. readonly onLeftButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101630. /**
  101631. * Fired when the right button on this controller is modified
  101632. */
  101633. readonly onRightButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101634. /**
  101635. * Fired when the menu button on this controller is modified
  101636. */
  101637. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101638. /**
  101639. * Called once for each button that changed state since the last frame
  101640. * Vive mapping:
  101641. * 0: touchpad
  101642. * 1: trigger
  101643. * 2: left AND right buttons
  101644. * 3: menu button
  101645. * @param buttonIdx Which button index changed
  101646. * @param state New state of the button
  101647. * @param changes Which properties on the state changed since last frame
  101648. */
  101649. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101650. }
  101651. }
  101652. declare module BABYLON {
  101653. /**
  101654. * Defines the WindowsMotionController object that the state of the windows motion controller
  101655. */
  101656. export class WindowsMotionController extends WebVRController {
  101657. /**
  101658. * The base url used to load the left and right controller models
  101659. */
  101660. static MODEL_BASE_URL: string;
  101661. /**
  101662. * The name of the left controller model file
  101663. */
  101664. static MODEL_LEFT_FILENAME: string;
  101665. /**
  101666. * The name of the right controller model file
  101667. */
  101668. static MODEL_RIGHT_FILENAME: string;
  101669. /**
  101670. * The controller name prefix for this controller type
  101671. */
  101672. static readonly GAMEPAD_ID_PREFIX: string;
  101673. /**
  101674. * The controller id pattern for this controller type
  101675. */
  101676. private static readonly GAMEPAD_ID_PATTERN;
  101677. private _loadedMeshInfo;
  101678. private readonly _mapping;
  101679. /**
  101680. * Fired when the trackpad on this controller is clicked
  101681. */
  101682. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  101683. /**
  101684. * Fired when the trackpad on this controller is modified
  101685. */
  101686. onTrackpadValuesChangedObservable: Observable<StickValues>;
  101687. /**
  101688. * The current x and y values of this controller's trackpad
  101689. */
  101690. trackpad: StickValues;
  101691. /**
  101692. * Creates a new WindowsMotionController from a gamepad
  101693. * @param vrGamepad the gamepad that the controller should be created from
  101694. */
  101695. constructor(vrGamepad: any);
  101696. /**
  101697. * Fired when the trigger on this controller is modified
  101698. */
  101699. readonly onTriggerButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101700. /**
  101701. * Fired when the menu button on this controller is modified
  101702. */
  101703. readonly onMenuButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101704. /**
  101705. * Fired when the grip button on this controller is modified
  101706. */
  101707. readonly onGripButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101708. /**
  101709. * Fired when the thumbstick button on this controller is modified
  101710. */
  101711. readonly onThumbstickButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101712. /**
  101713. * Fired when the touchpad button on this controller is modified
  101714. */
  101715. readonly onTouchpadButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  101716. /**
  101717. * Fired when the touchpad values on this controller are modified
  101718. */
  101719. readonly onTouchpadValuesChangedObservable: Observable<StickValues>;
  101720. private _updateTrackpad;
  101721. /**
  101722. * Called once per frame by the engine.
  101723. */
  101724. update(): void;
  101725. /**
  101726. * Called once for each button that changed state since the last frame
  101727. * @param buttonIdx Which button index changed
  101728. * @param state New state of the button
  101729. * @param changes Which properties on the state changed since last frame
  101730. */
  101731. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  101732. /**
  101733. * Moves the buttons on the controller mesh based on their current state
  101734. * @param buttonName the name of the button to move
  101735. * @param buttonValue the value of the button which determines the buttons new position
  101736. */
  101737. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  101738. /**
  101739. * Moves the axis on the controller mesh based on its current state
  101740. * @param axis the index of the axis
  101741. * @param axisValue the value of the axis which determines the meshes new position
  101742. * @hidden
  101743. */
  101744. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  101745. /**
  101746. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  101747. * @param scene scene in which to add meshes
  101748. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  101749. */
  101750. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  101751. /**
  101752. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  101753. * can be transformed by button presses and axes values, based on this._mapping.
  101754. *
  101755. * @param scene scene in which the meshes exist
  101756. * @param meshes list of meshes that make up the controller model to process
  101757. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  101758. */
  101759. private processModel;
  101760. private createMeshInfo;
  101761. /**
  101762. * Gets the ray of the controller in the direction the controller is pointing
  101763. * @param length the length the resulting ray should be
  101764. * @returns a ray in the direction the controller is pointing
  101765. */
  101766. getForwardRay(length?: number): Ray;
  101767. /**
  101768. * Disposes of the controller
  101769. */
  101770. dispose(): void;
  101771. }
  101772. }
  101773. declare module BABYLON {
  101774. /**
  101775. * Single axis scale gizmo
  101776. */
  101777. export class AxisScaleGizmo extends Gizmo {
  101778. private _coloredMaterial;
  101779. /**
  101780. * Drag behavior responsible for the gizmos dragging interactions
  101781. */
  101782. dragBehavior: PointerDragBehavior;
  101783. private _pointerObserver;
  101784. /**
  101785. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  101786. */
  101787. snapDistance: number;
  101788. /**
  101789. * Event that fires each time the gizmo snaps to a new location.
  101790. * * snapDistance is the the change in distance
  101791. */
  101792. onSnapObservable: Observable<{
  101793. snapDistance: number;
  101794. }>;
  101795. /**
  101796. * If the scaling operation should be done on all axis (default: false)
  101797. */
  101798. uniformScaling: boolean;
  101799. /**
  101800. * Creates an AxisScaleGizmo
  101801. * @param gizmoLayer The utility layer the gizmo will be added to
  101802. * @param dragAxis The axis which the gizmo will be able to scale on
  101803. * @param color The color of the gizmo
  101804. */
  101805. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101806. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101807. /**
  101808. * Disposes of the gizmo
  101809. */
  101810. dispose(): void;
  101811. /**
  101812. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  101813. * @param mesh The mesh to replace the default mesh of the gizmo
  101814. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  101815. */
  101816. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  101817. }
  101818. }
  101819. declare module BABYLON {
  101820. /**
  101821. * Bounding box gizmo
  101822. */
  101823. export class BoundingBoxGizmo extends Gizmo {
  101824. private _lineBoundingBox;
  101825. private _rotateSpheresParent;
  101826. private _scaleBoxesParent;
  101827. private _boundingDimensions;
  101828. private _renderObserver;
  101829. private _pointerObserver;
  101830. private _scaleDragSpeed;
  101831. private _tmpQuaternion;
  101832. private _tmpVector;
  101833. private _tmpRotationMatrix;
  101834. /**
  101835. * 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)
  101836. */
  101837. ignoreChildren: boolean;
  101838. /**
  101839. * 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)
  101840. */
  101841. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  101842. /**
  101843. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  101844. */
  101845. rotationSphereSize: number;
  101846. /**
  101847. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  101848. */
  101849. scaleBoxSize: number;
  101850. /**
  101851. * 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)
  101852. */
  101853. fixedDragMeshScreenSize: boolean;
  101854. /**
  101855. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  101856. */
  101857. fixedDragMeshScreenSizeDistanceFactor: number;
  101858. /**
  101859. * Fired when a rotation sphere or scale box is dragged
  101860. */
  101861. onDragStartObservable: Observable<{}>;
  101862. /**
  101863. * Fired when a scale box is dragged
  101864. */
  101865. onScaleBoxDragObservable: Observable<{}>;
  101866. /**
  101867. * Fired when a scale box drag is ended
  101868. */
  101869. onScaleBoxDragEndObservable: Observable<{}>;
  101870. /**
  101871. * Fired when a rotation sphere is dragged
  101872. */
  101873. onRotationSphereDragObservable: Observable<{}>;
  101874. /**
  101875. * Fired when a rotation sphere drag is ended
  101876. */
  101877. onRotationSphereDragEndObservable: Observable<{}>;
  101878. /**
  101879. * 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)
  101880. */
  101881. scalePivot: Nullable<Vector3>;
  101882. /**
  101883. * Mesh used as a pivot to rotate the attached mesh
  101884. */
  101885. private _anchorMesh;
  101886. private _existingMeshScale;
  101887. private _dragMesh;
  101888. private pointerDragBehavior;
  101889. private coloredMaterial;
  101890. private hoverColoredMaterial;
  101891. /**
  101892. * Sets the color of the bounding box gizmo
  101893. * @param color the color to set
  101894. */
  101895. setColor(color: Color3): void;
  101896. /**
  101897. * Creates an BoundingBoxGizmo
  101898. * @param gizmoLayer The utility layer the gizmo will be added to
  101899. * @param color The color of the gizmo
  101900. */
  101901. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  101902. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101903. private _selectNode;
  101904. /**
  101905. * Updates the bounding box information for the Gizmo
  101906. */
  101907. updateBoundingBox(): void;
  101908. private _updateRotationSpheres;
  101909. private _updateScaleBoxes;
  101910. /**
  101911. * Enables rotation on the specified axis and disables rotation on the others
  101912. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  101913. */
  101914. setEnabledRotationAxis(axis: string): void;
  101915. /**
  101916. * Enables/disables scaling
  101917. * @param enable if scaling should be enabled
  101918. */
  101919. setEnabledScaling(enable: boolean): void;
  101920. private _updateDummy;
  101921. /**
  101922. * Enables a pointer drag behavior on the bounding box of the gizmo
  101923. */
  101924. enableDragBehavior(): void;
  101925. /**
  101926. * Disposes of the gizmo
  101927. */
  101928. dispose(): void;
  101929. /**
  101930. * 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)
  101931. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  101932. * @returns the bounding box mesh with the passed in mesh as a child
  101933. */
  101934. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  101935. /**
  101936. * CustomMeshes are not supported by this gizmo
  101937. * @param mesh The mesh to replace the default mesh of the gizmo
  101938. */
  101939. setCustomMesh(mesh: Mesh): void;
  101940. }
  101941. }
  101942. declare module BABYLON {
  101943. /**
  101944. * Single plane rotation gizmo
  101945. */
  101946. export class PlaneRotationGizmo extends Gizmo {
  101947. /**
  101948. * Drag behavior responsible for the gizmos dragging interactions
  101949. */
  101950. dragBehavior: PointerDragBehavior;
  101951. private _pointerObserver;
  101952. /**
  101953. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  101954. */
  101955. snapDistance: number;
  101956. /**
  101957. * Event that fires each time the gizmo snaps to a new location.
  101958. * * snapDistance is the the change in distance
  101959. */
  101960. onSnapObservable: Observable<{
  101961. snapDistance: number;
  101962. }>;
  101963. /**
  101964. * Creates a PlaneRotationGizmo
  101965. * @param gizmoLayer The utility layer the gizmo will be added to
  101966. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  101967. * @param color The color of the gizmo
  101968. * @param tessellation Amount of tessellation to be used when creating rotation circles
  101969. */
  101970. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  101971. protected _attachedMeshChanged(value: Nullable<AbstractMesh>): void;
  101972. /**
  101973. * Disposes of the gizmo
  101974. */
  101975. dispose(): void;
  101976. }
  101977. }
  101978. declare module BABYLON {
  101979. /**
  101980. * Gizmo that enables rotating a mesh along 3 axis
  101981. */
  101982. export class RotationGizmo extends Gizmo {
  101983. /**
  101984. * Internal gizmo used for interactions on the x axis
  101985. */
  101986. xGizmo: PlaneRotationGizmo;
  101987. /**
  101988. * Internal gizmo used for interactions on the y axis
  101989. */
  101990. yGizmo: PlaneRotationGizmo;
  101991. /**
  101992. * Internal gizmo used for interactions on the z axis
  101993. */
  101994. zGizmo: PlaneRotationGizmo;
  101995. /** Fires an event when any of it's sub gizmos are dragged */
  101996. onDragStartObservable: Observable<{}>;
  101997. /** Fires an event when any of it's sub gizmos are released from dragging */
  101998. onDragEndObservable: Observable<{}>;
  101999. attachedMesh: Nullable<AbstractMesh>;
  102000. /**
  102001. * Creates a RotationGizmo
  102002. * @param gizmoLayer The utility layer the gizmo will be added to
  102003. * @param tessellation Amount of tessellation to be used when creating rotation circles
  102004. */
  102005. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number);
  102006. updateGizmoRotationToMatchAttachedMesh: boolean;
  102007. /**
  102008. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102009. */
  102010. snapDistance: number;
  102011. /**
  102012. * Ratio for the scale of the gizmo (Default: 1)
  102013. */
  102014. scaleRatio: number;
  102015. /**
  102016. * Disposes of the gizmo
  102017. */
  102018. dispose(): void;
  102019. /**
  102020. * CustomMeshes are not supported by this gizmo
  102021. * @param mesh The mesh to replace the default mesh of the gizmo
  102022. */
  102023. setCustomMesh(mesh: Mesh): void;
  102024. }
  102025. }
  102026. declare module BABYLON {
  102027. /**
  102028. * Gizmo that enables dragging a mesh along 3 axis
  102029. */
  102030. export class PositionGizmo extends Gizmo {
  102031. /**
  102032. * Internal gizmo used for interactions on the x axis
  102033. */
  102034. xGizmo: AxisDragGizmo;
  102035. /**
  102036. * Internal gizmo used for interactions on the y axis
  102037. */
  102038. yGizmo: AxisDragGizmo;
  102039. /**
  102040. * Internal gizmo used for interactions on the z axis
  102041. */
  102042. zGizmo: AxisDragGizmo;
  102043. /** Fires an event when any of it's sub gizmos are dragged */
  102044. onDragStartObservable: Observable<{}>;
  102045. /** Fires an event when any of it's sub gizmos are released from dragging */
  102046. onDragEndObservable: Observable<{}>;
  102047. attachedMesh: Nullable<AbstractMesh>;
  102048. /**
  102049. * Creates a PositionGizmo
  102050. * @param gizmoLayer The utility layer the gizmo will be added to
  102051. */
  102052. constructor(gizmoLayer?: UtilityLayerRenderer);
  102053. updateGizmoRotationToMatchAttachedMesh: boolean;
  102054. /**
  102055. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102056. */
  102057. snapDistance: number;
  102058. /**
  102059. * Ratio for the scale of the gizmo (Default: 1)
  102060. */
  102061. scaleRatio: number;
  102062. /**
  102063. * Disposes of the gizmo
  102064. */
  102065. dispose(): void;
  102066. /**
  102067. * CustomMeshes are not supported by this gizmo
  102068. * @param mesh The mesh to replace the default mesh of the gizmo
  102069. */
  102070. setCustomMesh(mesh: Mesh): void;
  102071. }
  102072. }
  102073. declare module BABYLON {
  102074. /**
  102075. * Class containing static functions to help procedurally build meshes
  102076. */
  102077. export class PolyhedronBuilder {
  102078. /**
  102079. * Creates a polyhedron mesh
  102080. * * 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
  102081. * * The parameter `size` (positive float, default 1) sets the polygon size
  102082. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  102083. * * 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`
  102084. * * 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
  102085. * * 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)`)
  102086. * * 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
  102087. * * 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
  102088. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  102089. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  102090. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  102091. * @param name defines the name of the mesh
  102092. * @param options defines the options used to create the mesh
  102093. * @param scene defines the hosting scene
  102094. * @returns the polyhedron mesh
  102095. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  102096. */
  102097. static CreatePolyhedron(name: string, options: {
  102098. type?: number;
  102099. size?: number;
  102100. sizeX?: number;
  102101. sizeY?: number;
  102102. sizeZ?: number;
  102103. custom?: any;
  102104. faceUV?: Vector4[];
  102105. faceColors?: Color4[];
  102106. flat?: boolean;
  102107. updatable?: boolean;
  102108. sideOrientation?: number;
  102109. frontUVs?: Vector4;
  102110. backUVs?: Vector4;
  102111. }, scene?: Nullable<Scene>): Mesh;
  102112. }
  102113. }
  102114. declare module BABYLON {
  102115. /**
  102116. * Gizmo that enables scaling a mesh along 3 axis
  102117. */
  102118. export class ScaleGizmo extends Gizmo {
  102119. /**
  102120. * Internal gizmo used for interactions on the x axis
  102121. */
  102122. xGizmo: AxisScaleGizmo;
  102123. /**
  102124. * Internal gizmo used for interactions on the y axis
  102125. */
  102126. yGizmo: AxisScaleGizmo;
  102127. /**
  102128. * Internal gizmo used for interactions on the z axis
  102129. */
  102130. zGizmo: AxisScaleGizmo;
  102131. /**
  102132. * Internal gizmo used to scale all axis equally
  102133. */
  102134. uniformScaleGizmo: AxisScaleGizmo;
  102135. /** Fires an event when any of it's sub gizmos are dragged */
  102136. onDragStartObservable: Observable<{}>;
  102137. /** Fires an event when any of it's sub gizmos are released from dragging */
  102138. onDragEndObservable: Observable<{}>;
  102139. attachedMesh: Nullable<AbstractMesh>;
  102140. /**
  102141. * Creates a ScaleGizmo
  102142. * @param gizmoLayer The utility layer the gizmo will be added to
  102143. */
  102144. constructor(gizmoLayer?: UtilityLayerRenderer);
  102145. updateGizmoRotationToMatchAttachedMesh: boolean;
  102146. /**
  102147. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  102148. */
  102149. snapDistance: number;
  102150. /**
  102151. * Ratio for the scale of the gizmo (Default: 1)
  102152. */
  102153. scaleRatio: number;
  102154. /**
  102155. * Disposes of the gizmo
  102156. */
  102157. dispose(): void;
  102158. }
  102159. }
  102160. declare module BABYLON {
  102161. /**
  102162. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  102163. */
  102164. export class GizmoManager implements IDisposable {
  102165. private scene;
  102166. /**
  102167. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  102168. */
  102169. gizmos: {
  102170. positionGizmo: Nullable<PositionGizmo>;
  102171. rotationGizmo: Nullable<RotationGizmo>;
  102172. scaleGizmo: Nullable<ScaleGizmo>;
  102173. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  102174. };
  102175. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  102176. clearGizmoOnEmptyPointerEvent: boolean;
  102177. /** Fires an event when the manager is attached to a mesh */
  102178. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  102179. private _gizmosEnabled;
  102180. private _pointerObserver;
  102181. private _attachedMesh;
  102182. private _boundingBoxColor;
  102183. private _defaultUtilityLayer;
  102184. private _defaultKeepDepthUtilityLayer;
  102185. /**
  102186. * When bounding box gizmo is enabled, this can be used to track drag/end events
  102187. */
  102188. boundingBoxDragBehavior: SixDofDragBehavior;
  102189. /**
  102190. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  102191. */
  102192. attachableMeshes: Nullable<Array<AbstractMesh>>;
  102193. /**
  102194. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  102195. */
  102196. usePointerToAttachGizmos: boolean;
  102197. /**
  102198. * Instatiates a gizmo manager
  102199. * @param scene the scene to overlay the gizmos on top of
  102200. */
  102201. constructor(scene: Scene);
  102202. /**
  102203. * Attaches a set of gizmos to the specified mesh
  102204. * @param mesh The mesh the gizmo's should be attached to
  102205. */
  102206. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  102207. /**
  102208. * If the position gizmo is enabled
  102209. */
  102210. positionGizmoEnabled: boolean;
  102211. /**
  102212. * If the rotation gizmo is enabled
  102213. */
  102214. rotationGizmoEnabled: boolean;
  102215. /**
  102216. * If the scale gizmo is enabled
  102217. */
  102218. scaleGizmoEnabled: boolean;
  102219. /**
  102220. * If the boundingBox gizmo is enabled
  102221. */
  102222. boundingBoxGizmoEnabled: boolean;
  102223. /**
  102224. * Disposes of the gizmo manager
  102225. */
  102226. dispose(): void;
  102227. }
  102228. }
  102229. declare module BABYLON {
  102230. /**
  102231. * A directional light is defined by a direction (what a surprise!).
  102232. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  102233. * 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.
  102234. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102235. */
  102236. export class DirectionalLight extends ShadowLight {
  102237. private _shadowFrustumSize;
  102238. /**
  102239. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  102240. */
  102241. /**
  102242. * Specifies a fix frustum size for the shadow generation.
  102243. */
  102244. shadowFrustumSize: number;
  102245. private _shadowOrthoScale;
  102246. /**
  102247. * Gets the shadow projection scale against the optimal computed one.
  102248. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102249. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102250. */
  102251. /**
  102252. * Sets the shadow projection scale against the optimal computed one.
  102253. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  102254. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  102255. */
  102256. shadowOrthoScale: number;
  102257. /**
  102258. * Automatically compute the projection matrix to best fit (including all the casters)
  102259. * on each frame.
  102260. */
  102261. autoUpdateExtends: boolean;
  102262. private _orthoLeft;
  102263. private _orthoRight;
  102264. private _orthoTop;
  102265. private _orthoBottom;
  102266. /**
  102267. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  102268. * The directional light is emitted from everywhere in the given direction.
  102269. * It can cast shadows.
  102270. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102271. * @param name The friendly name of the light
  102272. * @param direction The direction of the light
  102273. * @param scene The scene the light belongs to
  102274. */
  102275. constructor(name: string, direction: Vector3, scene: Scene);
  102276. /**
  102277. * Returns the string "DirectionalLight".
  102278. * @return The class name
  102279. */
  102280. getClassName(): string;
  102281. /**
  102282. * Returns the integer 1.
  102283. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102284. */
  102285. getTypeID(): number;
  102286. /**
  102287. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  102288. * Returns the DirectionalLight Shadow projection matrix.
  102289. */
  102290. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102291. /**
  102292. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  102293. * Returns the DirectionalLight Shadow projection matrix.
  102294. */
  102295. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  102296. /**
  102297. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  102298. * Returns the DirectionalLight Shadow projection matrix.
  102299. */
  102300. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102301. protected _buildUniformLayout(): void;
  102302. /**
  102303. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  102304. * @param effect The effect to update
  102305. * @param lightIndex The index of the light in the effect to update
  102306. * @returns The directional light
  102307. */
  102308. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  102309. /**
  102310. * Gets the minZ used for shadow according to both the scene and the light.
  102311. *
  102312. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102313. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102314. * @param activeCamera The camera we are returning the min for
  102315. * @returns the depth min z
  102316. */
  102317. getDepthMinZ(activeCamera: Camera): number;
  102318. /**
  102319. * Gets the maxZ used for shadow according to both the scene and the light.
  102320. *
  102321. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  102322. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  102323. * @param activeCamera The camera we are returning the max for
  102324. * @returns the depth max z
  102325. */
  102326. getDepthMaxZ(activeCamera: Camera): number;
  102327. /**
  102328. * Prepares the list of defines specific to the light type.
  102329. * @param defines the list of defines
  102330. * @param lightIndex defines the index of the light for the effect
  102331. */
  102332. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102333. }
  102334. }
  102335. declare module BABYLON {
  102336. /**
  102337. * Class containing static functions to help procedurally build meshes
  102338. */
  102339. export class HemisphereBuilder {
  102340. /**
  102341. * Creates a hemisphere mesh
  102342. * @param name defines the name of the mesh
  102343. * @param options defines the options used to create the mesh
  102344. * @param scene defines the hosting scene
  102345. * @returns the hemisphere mesh
  102346. */
  102347. static CreateHemisphere(name: string, options: {
  102348. segments?: number;
  102349. diameter?: number;
  102350. sideOrientation?: number;
  102351. }, scene: any): Mesh;
  102352. }
  102353. }
  102354. declare module BABYLON {
  102355. /**
  102356. * A spot light is defined by a position, a direction, an angle, and an exponent.
  102357. * These values define a cone of light starting from the position, emitting toward the direction.
  102358. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  102359. * and the exponent defines the speed of the decay of the light with distance (reach).
  102360. * Documentation: https://doc.babylonjs.com/babylon101/lights
  102361. */
  102362. export class SpotLight extends ShadowLight {
  102363. private _angle;
  102364. private _innerAngle;
  102365. private _cosHalfAngle;
  102366. private _lightAngleScale;
  102367. private _lightAngleOffset;
  102368. /**
  102369. * Gets the cone angle of the spot light in Radians.
  102370. */
  102371. /**
  102372. * Sets the cone angle of the spot light in Radians.
  102373. */
  102374. angle: number;
  102375. /**
  102376. * Only used in gltf falloff mode, this defines the angle where
  102377. * the directional falloff will start before cutting at angle which could be seen
  102378. * as outer angle.
  102379. */
  102380. /**
  102381. * Only used in gltf falloff mode, this defines the angle where
  102382. * the directional falloff will start before cutting at angle which could be seen
  102383. * as outer angle.
  102384. */
  102385. innerAngle: number;
  102386. private _shadowAngleScale;
  102387. /**
  102388. * Allows scaling the angle of the light for shadow generation only.
  102389. */
  102390. /**
  102391. * Allows scaling the angle of the light for shadow generation only.
  102392. */
  102393. shadowAngleScale: number;
  102394. /**
  102395. * The light decay speed with the distance from the emission spot.
  102396. */
  102397. exponent: number;
  102398. private _projectionTextureMatrix;
  102399. /**
  102400. * Allows reading the projecton texture
  102401. */
  102402. readonly projectionTextureMatrix: Matrix;
  102403. protected _projectionTextureLightNear: number;
  102404. /**
  102405. * Gets the near clip of the Spotlight for texture projection.
  102406. */
  102407. /**
  102408. * Sets the near clip of the Spotlight for texture projection.
  102409. */
  102410. projectionTextureLightNear: number;
  102411. protected _projectionTextureLightFar: number;
  102412. /**
  102413. * Gets the far clip of the Spotlight for texture projection.
  102414. */
  102415. /**
  102416. * Sets the far clip of the Spotlight for texture projection.
  102417. */
  102418. projectionTextureLightFar: number;
  102419. protected _projectionTextureUpDirection: Vector3;
  102420. /**
  102421. * Gets the Up vector of the Spotlight for texture projection.
  102422. */
  102423. /**
  102424. * Sets the Up vector of the Spotlight for texture projection.
  102425. */
  102426. projectionTextureUpDirection: Vector3;
  102427. private _projectionTexture;
  102428. /**
  102429. * Gets the projection texture of the light.
  102430. */
  102431. /**
  102432. * Sets the projection texture of the light.
  102433. */
  102434. projectionTexture: Nullable<BaseTexture>;
  102435. private _projectionTextureViewLightDirty;
  102436. private _projectionTextureProjectionLightDirty;
  102437. private _projectionTextureDirty;
  102438. private _projectionTextureViewTargetVector;
  102439. private _projectionTextureViewLightMatrix;
  102440. private _projectionTextureProjectionLightMatrix;
  102441. private _projectionTextureScalingMatrix;
  102442. /**
  102443. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  102444. * It can cast shadows.
  102445. * Documentation : https://doc.babylonjs.com/babylon101/lights
  102446. * @param name The light friendly name
  102447. * @param position The position of the spot light in the scene
  102448. * @param direction The direction of the light in the scene
  102449. * @param angle The cone angle of the light in Radians
  102450. * @param exponent The light decay speed with the distance from the emission spot
  102451. * @param scene The scene the lights belongs to
  102452. */
  102453. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  102454. /**
  102455. * Returns the string "SpotLight".
  102456. * @returns the class name
  102457. */
  102458. getClassName(): string;
  102459. /**
  102460. * Returns the integer 2.
  102461. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  102462. */
  102463. getTypeID(): number;
  102464. /**
  102465. * Overrides the direction setter to recompute the projection texture view light Matrix.
  102466. */
  102467. protected _setDirection(value: Vector3): void;
  102468. /**
  102469. * Overrides the position setter to recompute the projection texture view light Matrix.
  102470. */
  102471. protected _setPosition(value: Vector3): void;
  102472. /**
  102473. * 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.
  102474. * Returns the SpotLight.
  102475. */
  102476. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  102477. protected _computeProjectionTextureViewLightMatrix(): void;
  102478. protected _computeProjectionTextureProjectionLightMatrix(): void;
  102479. /**
  102480. * Main function for light texture projection matrix computing.
  102481. */
  102482. protected _computeProjectionTextureMatrix(): void;
  102483. protected _buildUniformLayout(): void;
  102484. private _computeAngleValues;
  102485. /**
  102486. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  102487. * @param effect The effect to update
  102488. * @param lightIndex The index of the light in the effect to update
  102489. * @returns The spot light
  102490. */
  102491. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  102492. /**
  102493. * Disposes the light and the associated resources.
  102494. */
  102495. dispose(): void;
  102496. /**
  102497. * Prepares the list of defines specific to the light type.
  102498. * @param defines the list of defines
  102499. * @param lightIndex defines the index of the light for the effect
  102500. */
  102501. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  102502. }
  102503. }
  102504. declare module BABYLON {
  102505. /**
  102506. * Gizmo that enables viewing a light
  102507. */
  102508. export class LightGizmo extends Gizmo {
  102509. private _lightMesh;
  102510. private _material;
  102511. /**
  102512. * Creates a LightGizmo
  102513. * @param gizmoLayer The utility layer the gizmo will be added to
  102514. */
  102515. constructor(gizmoLayer?: UtilityLayerRenderer);
  102516. private _light;
  102517. /**
  102518. * The light that the gizmo is attached to
  102519. */
  102520. light: Nullable<Light>;
  102521. /**
  102522. * @hidden
  102523. * Updates the gizmo to match the attached mesh's position/rotation
  102524. */
  102525. protected _update(): void;
  102526. private static _Scale;
  102527. /**
  102528. * Creates the lines for a light mesh
  102529. */
  102530. private static _createLightLines;
  102531. private static _CreateHemisphericLightMesh;
  102532. private static _CreatePointLightMesh;
  102533. private static _CreateSpotLightMesh;
  102534. private static _CreateDirectionalLightMesh;
  102535. }
  102536. }
  102537. declare module BABYLON {
  102538. /** @hidden */
  102539. export var backgroundFragmentDeclaration: {
  102540. name: string;
  102541. shader: string;
  102542. };
  102543. }
  102544. declare module BABYLON {
  102545. /** @hidden */
  102546. export var backgroundUboDeclaration: {
  102547. name: string;
  102548. shader: string;
  102549. };
  102550. }
  102551. declare module BABYLON {
  102552. /** @hidden */
  102553. export var backgroundPixelShader: {
  102554. name: string;
  102555. shader: string;
  102556. };
  102557. }
  102558. declare module BABYLON {
  102559. /** @hidden */
  102560. export var backgroundVertexDeclaration: {
  102561. name: string;
  102562. shader: string;
  102563. };
  102564. }
  102565. declare module BABYLON {
  102566. /** @hidden */
  102567. export var backgroundVertexShader: {
  102568. name: string;
  102569. shader: string;
  102570. };
  102571. }
  102572. declare module BABYLON {
  102573. /**
  102574. * Background material used to create an efficient environement around your scene.
  102575. */
  102576. export class BackgroundMaterial extends PushMaterial {
  102577. /**
  102578. * Standard reflectance value at parallel view angle.
  102579. */
  102580. static StandardReflectance0: number;
  102581. /**
  102582. * Standard reflectance value at grazing angle.
  102583. */
  102584. static StandardReflectance90: number;
  102585. protected _primaryColor: Color3;
  102586. /**
  102587. * Key light Color (multiply against the environement texture)
  102588. */
  102589. primaryColor: Color3;
  102590. protected __perceptualColor: Nullable<Color3>;
  102591. /**
  102592. * Experimental Internal Use Only.
  102593. *
  102594. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  102595. * This acts as a helper to set the primary color to a more "human friendly" value.
  102596. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  102597. * output color as close as possible from the chosen value.
  102598. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  102599. * part of lighting setup.)
  102600. */
  102601. _perceptualColor: Nullable<Color3>;
  102602. protected _primaryColorShadowLevel: float;
  102603. /**
  102604. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  102605. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  102606. */
  102607. primaryColorShadowLevel: float;
  102608. protected _primaryColorHighlightLevel: float;
  102609. /**
  102610. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  102611. * The primary color is used at the level chosen to define what the white area would look.
  102612. */
  102613. primaryColorHighlightLevel: float;
  102614. protected _reflectionTexture: Nullable<BaseTexture>;
  102615. /**
  102616. * Reflection Texture used in the material.
  102617. * Should be author in a specific way for the best result (refer to the documentation).
  102618. */
  102619. reflectionTexture: Nullable<BaseTexture>;
  102620. protected _reflectionBlur: float;
  102621. /**
  102622. * Reflection Texture level of blur.
  102623. *
  102624. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  102625. * texture twice.
  102626. */
  102627. reflectionBlur: float;
  102628. protected _diffuseTexture: Nullable<BaseTexture>;
  102629. /**
  102630. * Diffuse Texture used in the material.
  102631. * Should be author in a specific way for the best result (refer to the documentation).
  102632. */
  102633. diffuseTexture: Nullable<BaseTexture>;
  102634. protected _shadowLights: Nullable<IShadowLight[]>;
  102635. /**
  102636. * Specify the list of lights casting shadow on the material.
  102637. * All scene shadow lights will be included if null.
  102638. */
  102639. shadowLights: Nullable<IShadowLight[]>;
  102640. protected _shadowLevel: float;
  102641. /**
  102642. * Helps adjusting the shadow to a softer level if required.
  102643. * 0 means black shadows and 1 means no shadows.
  102644. */
  102645. shadowLevel: float;
  102646. protected _sceneCenter: Vector3;
  102647. /**
  102648. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  102649. * It is usually zero but might be interesting to modify according to your setup.
  102650. */
  102651. sceneCenter: Vector3;
  102652. protected _opacityFresnel: boolean;
  102653. /**
  102654. * This helps specifying that the material is falling off to the sky box at grazing angle.
  102655. * This helps ensuring a nice transition when the camera goes under the ground.
  102656. */
  102657. opacityFresnel: boolean;
  102658. protected _reflectionFresnel: boolean;
  102659. /**
  102660. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  102661. * This helps adding a mirror texture on the ground.
  102662. */
  102663. reflectionFresnel: boolean;
  102664. protected _reflectionFalloffDistance: number;
  102665. /**
  102666. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  102667. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  102668. */
  102669. reflectionFalloffDistance: number;
  102670. protected _reflectionAmount: number;
  102671. /**
  102672. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  102673. */
  102674. reflectionAmount: number;
  102675. protected _reflectionReflectance0: number;
  102676. /**
  102677. * This specifies the weight of the reflection at grazing angle.
  102678. */
  102679. reflectionReflectance0: number;
  102680. protected _reflectionReflectance90: number;
  102681. /**
  102682. * This specifies the weight of the reflection at a perpendicular point of view.
  102683. */
  102684. reflectionReflectance90: number;
  102685. /**
  102686. * Sets the reflection reflectance fresnel values according to the default standard
  102687. * empirically know to work well :-)
  102688. */
  102689. reflectionStandardFresnelWeight: number;
  102690. protected _useRGBColor: boolean;
  102691. /**
  102692. * Helps to directly use the maps channels instead of their level.
  102693. */
  102694. useRGBColor: boolean;
  102695. protected _enableNoise: boolean;
  102696. /**
  102697. * This helps reducing the banding effect that could occur on the background.
  102698. */
  102699. enableNoise: boolean;
  102700. /**
  102701. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  102702. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  102703. * Recommended to be keep at 1.0 except for special cases.
  102704. */
  102705. fovMultiplier: number;
  102706. private _fovMultiplier;
  102707. /**
  102708. * Enable the FOV adjustment feature controlled by fovMultiplier.
  102709. */
  102710. useEquirectangularFOV: boolean;
  102711. private _maxSimultaneousLights;
  102712. /**
  102713. * Number of Simultaneous lights allowed on the material.
  102714. */
  102715. maxSimultaneousLights: int;
  102716. /**
  102717. * Default configuration related to image processing available in the Background Material.
  102718. */
  102719. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  102720. /**
  102721. * Keep track of the image processing observer to allow dispose and replace.
  102722. */
  102723. private _imageProcessingObserver;
  102724. /**
  102725. * Attaches a new image processing configuration to the PBR Material.
  102726. * @param configuration (if null the scene configuration will be use)
  102727. */
  102728. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  102729. /**
  102730. * Gets the image processing configuration used either in this material.
  102731. */
  102732. /**
  102733. * Sets the Default image processing configuration used either in the this material.
  102734. *
  102735. * If sets to null, the scene one is in use.
  102736. */
  102737. imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  102738. /**
  102739. * Gets wether the color curves effect is enabled.
  102740. */
  102741. /**
  102742. * Sets wether the color curves effect is enabled.
  102743. */
  102744. cameraColorCurvesEnabled: boolean;
  102745. /**
  102746. * Gets wether the color grading effect is enabled.
  102747. */
  102748. /**
  102749. * Gets wether the color grading effect is enabled.
  102750. */
  102751. cameraColorGradingEnabled: boolean;
  102752. /**
  102753. * Gets wether tonemapping is enabled or not.
  102754. */
  102755. /**
  102756. * Sets wether tonemapping is enabled or not
  102757. */
  102758. cameraToneMappingEnabled: boolean;
  102759. /**
  102760. * The camera exposure used on this material.
  102761. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102762. * This corresponds to a photographic exposure.
  102763. */
  102764. /**
  102765. * The camera exposure used on this material.
  102766. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  102767. * This corresponds to a photographic exposure.
  102768. */
  102769. cameraExposure: float;
  102770. /**
  102771. * Gets The camera contrast used on this material.
  102772. */
  102773. /**
  102774. * Sets The camera contrast used on this material.
  102775. */
  102776. cameraContrast: float;
  102777. /**
  102778. * Gets the Color Grading 2D Lookup Texture.
  102779. */
  102780. /**
  102781. * Sets the Color Grading 2D Lookup Texture.
  102782. */
  102783. cameraColorGradingTexture: Nullable<BaseTexture>;
  102784. /**
  102785. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102786. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102787. * 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;
  102788. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102789. */
  102790. /**
  102791. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  102792. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  102793. * 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;
  102794. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  102795. */
  102796. cameraColorCurves: Nullable<ColorCurves>;
  102797. /**
  102798. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  102799. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  102800. */
  102801. switchToBGR: boolean;
  102802. private _renderTargets;
  102803. private _reflectionControls;
  102804. private _white;
  102805. private _primaryShadowColor;
  102806. private _primaryHighlightColor;
  102807. /**
  102808. * Instantiates a Background Material in the given scene
  102809. * @param name The friendly name of the material
  102810. * @param scene The scene to add the material to
  102811. */
  102812. constructor(name: string, scene: Scene);
  102813. /**
  102814. * Gets a boolean indicating that current material needs to register RTT
  102815. */
  102816. readonly hasRenderTargetTextures: boolean;
  102817. /**
  102818. * The entire material has been created in order to prevent overdraw.
  102819. * @returns false
  102820. */
  102821. needAlphaTesting(): boolean;
  102822. /**
  102823. * The entire material has been created in order to prevent overdraw.
  102824. * @returns true if blending is enable
  102825. */
  102826. needAlphaBlending(): boolean;
  102827. /**
  102828. * Checks wether the material is ready to be rendered for a given mesh.
  102829. * @param mesh The mesh to render
  102830. * @param subMesh The submesh to check against
  102831. * @param useInstances Specify wether or not the material is used with instances
  102832. * @returns true if all the dependencies are ready (Textures, Effects...)
  102833. */
  102834. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  102835. /**
  102836. * Compute the primary color according to the chosen perceptual color.
  102837. */
  102838. private _computePrimaryColorFromPerceptualColor;
  102839. /**
  102840. * Compute the highlights and shadow colors according to their chosen levels.
  102841. */
  102842. private _computePrimaryColors;
  102843. /**
  102844. * Build the uniform buffer used in the material.
  102845. */
  102846. buildUniformLayout(): void;
  102847. /**
  102848. * Unbind the material.
  102849. */
  102850. unbind(): void;
  102851. /**
  102852. * Bind only the world matrix to the material.
  102853. * @param world The world matrix to bind.
  102854. */
  102855. bindOnlyWorldMatrix(world: Matrix): void;
  102856. /**
  102857. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  102858. * @param world The world matrix to bind.
  102859. * @param subMesh The submesh to bind for.
  102860. */
  102861. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  102862. /**
  102863. * Dispose the material.
  102864. * @param forceDisposeEffect Force disposal of the associated effect.
  102865. * @param forceDisposeTextures Force disposal of the associated textures.
  102866. */
  102867. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  102868. /**
  102869. * Clones the material.
  102870. * @param name The cloned name.
  102871. * @returns The cloned material.
  102872. */
  102873. clone(name: string): BackgroundMaterial;
  102874. /**
  102875. * Serializes the current material to its JSON representation.
  102876. * @returns The JSON representation.
  102877. */
  102878. serialize(): any;
  102879. /**
  102880. * Gets the class name of the material
  102881. * @returns "BackgroundMaterial"
  102882. */
  102883. getClassName(): string;
  102884. /**
  102885. * Parse a JSON input to create back a background material.
  102886. * @param source The JSON data to parse
  102887. * @param scene The scene to create the parsed material in
  102888. * @param rootUrl The root url of the assets the material depends upon
  102889. * @returns the instantiated BackgroundMaterial.
  102890. */
  102891. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  102892. }
  102893. }
  102894. declare module BABYLON {
  102895. /**
  102896. * Represents the different options available during the creation of
  102897. * a Environment helper.
  102898. *
  102899. * This can control the default ground, skybox and image processing setup of your scene.
  102900. */
  102901. export interface IEnvironmentHelperOptions {
  102902. /**
  102903. * Specifies wether or not to create a ground.
  102904. * True by default.
  102905. */
  102906. createGround: boolean;
  102907. /**
  102908. * Specifies the ground size.
  102909. * 15 by default.
  102910. */
  102911. groundSize: number;
  102912. /**
  102913. * The texture used on the ground for the main color.
  102914. * Comes from the BabylonJS CDN by default.
  102915. *
  102916. * Remarks: Can be either a texture or a url.
  102917. */
  102918. groundTexture: string | BaseTexture;
  102919. /**
  102920. * The color mixed in the ground texture by default.
  102921. * BabylonJS clearColor by default.
  102922. */
  102923. groundColor: Color3;
  102924. /**
  102925. * Specifies the ground opacity.
  102926. * 1 by default.
  102927. */
  102928. groundOpacity: number;
  102929. /**
  102930. * Enables the ground to receive shadows.
  102931. * True by default.
  102932. */
  102933. enableGroundShadow: boolean;
  102934. /**
  102935. * Helps preventing the shadow to be fully black on the ground.
  102936. * 0.5 by default.
  102937. */
  102938. groundShadowLevel: number;
  102939. /**
  102940. * Creates a mirror texture attach to the ground.
  102941. * false by default.
  102942. */
  102943. enableGroundMirror: boolean;
  102944. /**
  102945. * Specifies the ground mirror size ratio.
  102946. * 0.3 by default as the default kernel is 64.
  102947. */
  102948. groundMirrorSizeRatio: number;
  102949. /**
  102950. * Specifies the ground mirror blur kernel size.
  102951. * 64 by default.
  102952. */
  102953. groundMirrorBlurKernel: number;
  102954. /**
  102955. * Specifies the ground mirror visibility amount.
  102956. * 1 by default
  102957. */
  102958. groundMirrorAmount: number;
  102959. /**
  102960. * Specifies the ground mirror reflectance weight.
  102961. * This uses the standard weight of the background material to setup the fresnel effect
  102962. * of the mirror.
  102963. * 1 by default.
  102964. */
  102965. groundMirrorFresnelWeight: number;
  102966. /**
  102967. * Specifies the ground mirror Falloff distance.
  102968. * This can helps reducing the size of the reflection.
  102969. * 0 by Default.
  102970. */
  102971. groundMirrorFallOffDistance: number;
  102972. /**
  102973. * Specifies the ground mirror texture type.
  102974. * Unsigned Int by Default.
  102975. */
  102976. groundMirrorTextureType: number;
  102977. /**
  102978. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  102979. * the shown objects.
  102980. */
  102981. groundYBias: number;
  102982. /**
  102983. * Specifies wether or not to create a skybox.
  102984. * True by default.
  102985. */
  102986. createSkybox: boolean;
  102987. /**
  102988. * Specifies the skybox size.
  102989. * 20 by default.
  102990. */
  102991. skyboxSize: number;
  102992. /**
  102993. * The texture used on the skybox for the main color.
  102994. * Comes from the BabylonJS CDN by default.
  102995. *
  102996. * Remarks: Can be either a texture or a url.
  102997. */
  102998. skyboxTexture: string | BaseTexture;
  102999. /**
  103000. * The color mixed in the skybox texture by default.
  103001. * BabylonJS clearColor by default.
  103002. */
  103003. skyboxColor: Color3;
  103004. /**
  103005. * The background rotation around the Y axis of the scene.
  103006. * This helps aligning the key lights of your scene with the background.
  103007. * 0 by default.
  103008. */
  103009. backgroundYRotation: number;
  103010. /**
  103011. * Compute automatically the size of the elements to best fit with the scene.
  103012. */
  103013. sizeAuto: boolean;
  103014. /**
  103015. * Default position of the rootMesh if autoSize is not true.
  103016. */
  103017. rootPosition: Vector3;
  103018. /**
  103019. * Sets up the image processing in the scene.
  103020. * true by default.
  103021. */
  103022. setupImageProcessing: boolean;
  103023. /**
  103024. * The texture used as your environment texture in the scene.
  103025. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  103026. *
  103027. * Remarks: Can be either a texture or a url.
  103028. */
  103029. environmentTexture: string | BaseTexture;
  103030. /**
  103031. * The value of the exposure to apply to the scene.
  103032. * 0.6 by default if setupImageProcessing is true.
  103033. */
  103034. cameraExposure: number;
  103035. /**
  103036. * The value of the contrast to apply to the scene.
  103037. * 1.6 by default if setupImageProcessing is true.
  103038. */
  103039. cameraContrast: number;
  103040. /**
  103041. * Specifies wether or not tonemapping should be enabled in the scene.
  103042. * true by default if setupImageProcessing is true.
  103043. */
  103044. toneMappingEnabled: boolean;
  103045. }
  103046. /**
  103047. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  103048. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  103049. * It also helps with the default setup of your imageProcessing configuration.
  103050. */
  103051. export class EnvironmentHelper {
  103052. /**
  103053. * Default ground texture URL.
  103054. */
  103055. private static _groundTextureCDNUrl;
  103056. /**
  103057. * Default skybox texture URL.
  103058. */
  103059. private static _skyboxTextureCDNUrl;
  103060. /**
  103061. * Default environment texture URL.
  103062. */
  103063. private static _environmentTextureCDNUrl;
  103064. /**
  103065. * Creates the default options for the helper.
  103066. */
  103067. private static _getDefaultOptions;
  103068. private _rootMesh;
  103069. /**
  103070. * Gets the root mesh created by the helper.
  103071. */
  103072. readonly rootMesh: Mesh;
  103073. private _skybox;
  103074. /**
  103075. * Gets the skybox created by the helper.
  103076. */
  103077. readonly skybox: Nullable<Mesh>;
  103078. private _skyboxTexture;
  103079. /**
  103080. * Gets the skybox texture created by the helper.
  103081. */
  103082. readonly skyboxTexture: Nullable<BaseTexture>;
  103083. private _skyboxMaterial;
  103084. /**
  103085. * Gets the skybox material created by the helper.
  103086. */
  103087. readonly skyboxMaterial: Nullable<BackgroundMaterial>;
  103088. private _ground;
  103089. /**
  103090. * Gets the ground mesh created by the helper.
  103091. */
  103092. readonly ground: Nullable<Mesh>;
  103093. private _groundTexture;
  103094. /**
  103095. * Gets the ground texture created by the helper.
  103096. */
  103097. readonly groundTexture: Nullable<BaseTexture>;
  103098. private _groundMirror;
  103099. /**
  103100. * Gets the ground mirror created by the helper.
  103101. */
  103102. readonly groundMirror: Nullable<MirrorTexture>;
  103103. /**
  103104. * Gets the ground mirror render list to helps pushing the meshes
  103105. * you wish in the ground reflection.
  103106. */
  103107. readonly groundMirrorRenderList: Nullable<AbstractMesh[]>;
  103108. private _groundMaterial;
  103109. /**
  103110. * Gets the ground material created by the helper.
  103111. */
  103112. readonly groundMaterial: Nullable<BackgroundMaterial>;
  103113. /**
  103114. * Stores the creation options.
  103115. */
  103116. private readonly _scene;
  103117. private _options;
  103118. /**
  103119. * This observable will be notified with any error during the creation of the environment,
  103120. * mainly texture creation errors.
  103121. */
  103122. onErrorObservable: Observable<{
  103123. message?: string;
  103124. exception?: any;
  103125. }>;
  103126. /**
  103127. * constructor
  103128. * @param options Defines the options we want to customize the helper
  103129. * @param scene The scene to add the material to
  103130. */
  103131. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  103132. /**
  103133. * Updates the background according to the new options
  103134. * @param options
  103135. */
  103136. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  103137. /**
  103138. * Sets the primary color of all the available elements.
  103139. * @param color the main color to affect to the ground and the background
  103140. */
  103141. setMainColor(color: Color3): void;
  103142. /**
  103143. * Setup the image processing according to the specified options.
  103144. */
  103145. private _setupImageProcessing;
  103146. /**
  103147. * Setup the environment texture according to the specified options.
  103148. */
  103149. private _setupEnvironmentTexture;
  103150. /**
  103151. * Setup the background according to the specified options.
  103152. */
  103153. private _setupBackground;
  103154. /**
  103155. * Get the scene sizes according to the setup.
  103156. */
  103157. private _getSceneSize;
  103158. /**
  103159. * Setup the ground according to the specified options.
  103160. */
  103161. private _setupGround;
  103162. /**
  103163. * Setup the ground material according to the specified options.
  103164. */
  103165. private _setupGroundMaterial;
  103166. /**
  103167. * Setup the ground diffuse texture according to the specified options.
  103168. */
  103169. private _setupGroundDiffuseTexture;
  103170. /**
  103171. * Setup the ground mirror texture according to the specified options.
  103172. */
  103173. private _setupGroundMirrorTexture;
  103174. /**
  103175. * Setup the ground to receive the mirror texture.
  103176. */
  103177. private _setupMirrorInGroundMaterial;
  103178. /**
  103179. * Setup the skybox according to the specified options.
  103180. */
  103181. private _setupSkybox;
  103182. /**
  103183. * Setup the skybox material according to the specified options.
  103184. */
  103185. private _setupSkyboxMaterial;
  103186. /**
  103187. * Setup the skybox reflection texture according to the specified options.
  103188. */
  103189. private _setupSkyboxReflectionTexture;
  103190. private _errorHandler;
  103191. /**
  103192. * Dispose all the elements created by the Helper.
  103193. */
  103194. dispose(): void;
  103195. }
  103196. }
  103197. declare module BABYLON {
  103198. /**
  103199. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  103200. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  103201. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  103202. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  103203. */
  103204. export class PhotoDome extends TransformNode {
  103205. private _useDirectMapping;
  103206. /**
  103207. * The texture being displayed on the sphere
  103208. */
  103209. protected _photoTexture: Texture;
  103210. /**
  103211. * Gets or sets the texture being displayed on the sphere
  103212. */
  103213. photoTexture: Texture;
  103214. /**
  103215. * Observable raised when an error occured while loading the 360 image
  103216. */
  103217. onLoadErrorObservable: Observable<string>;
  103218. /**
  103219. * The skybox material
  103220. */
  103221. protected _material: BackgroundMaterial;
  103222. /**
  103223. * The surface used for the skybox
  103224. */
  103225. protected _mesh: Mesh;
  103226. /**
  103227. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  103228. * Also see the options.resolution property.
  103229. */
  103230. fovMultiplier: number;
  103231. /**
  103232. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  103233. * @param name Element's name, child elements will append suffixes for their own names.
  103234. * @param urlsOfPhoto defines the url of the photo to display
  103235. * @param options defines an object containing optional or exposed sub element properties
  103236. * @param onError defines a callback called when an error occured while loading the texture
  103237. */
  103238. constructor(name: string, urlOfPhoto: string, options: {
  103239. resolution?: number;
  103240. size?: number;
  103241. useDirectMapping?: boolean;
  103242. faceForward?: boolean;
  103243. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  103244. /**
  103245. * Releases resources associated with this node.
  103246. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  103247. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  103248. */
  103249. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  103250. }
  103251. }
  103252. declare module BABYLON {
  103253. /** @hidden */
  103254. export var rgbdDecodePixelShader: {
  103255. name: string;
  103256. shader: string;
  103257. };
  103258. }
  103259. declare module BABYLON {
  103260. /**
  103261. * Class used to host texture specific utilities
  103262. */
  103263. export class BRDFTextureTools {
  103264. /**
  103265. * Expand the BRDF Texture from RGBD to Half Float if necessary.
  103266. * @param texture the texture to expand.
  103267. */
  103268. private static _ExpandDefaultBRDFTexture;
  103269. /**
  103270. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  103271. * @param scene defines the hosting scene
  103272. * @returns the environment BRDF texture
  103273. */
  103274. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  103275. private static _environmentBRDFBase64Texture;
  103276. }
  103277. }
  103278. declare module BABYLON {
  103279. /**
  103280. * @hidden
  103281. */
  103282. export interface IMaterialClearCoatDefines {
  103283. CLEARCOAT: boolean;
  103284. CLEARCOAT_DEFAULTIOR: boolean;
  103285. CLEARCOAT_TEXTURE: boolean;
  103286. CLEARCOAT_TEXTUREDIRECTUV: number;
  103287. CLEARCOAT_BUMP: boolean;
  103288. CLEARCOAT_BUMPDIRECTUV: number;
  103289. CLEARCOAT_TINT: boolean;
  103290. CLEARCOAT_TINT_TEXTURE: boolean;
  103291. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  103292. /** @hidden */
  103293. _areTexturesDirty: boolean;
  103294. }
  103295. /**
  103296. * Define the code related to the clear coat parameters of the pbr material.
  103297. */
  103298. export class PBRClearCoatConfiguration {
  103299. /**
  103300. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103301. * The default fits with a polyurethane material.
  103302. */
  103303. private static readonly _DefaultIndiceOfRefraction;
  103304. private _isEnabled;
  103305. /**
  103306. * Defines if the clear coat is enabled in the material.
  103307. */
  103308. isEnabled: boolean;
  103309. /**
  103310. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  103311. */
  103312. intensity: number;
  103313. /**
  103314. * Defines the clear coat layer roughness.
  103315. */
  103316. roughness: number;
  103317. private _indiceOfRefraction;
  103318. /**
  103319. * Defines the indice of refraction of the clear coat.
  103320. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  103321. * The default fits with a polyurethane material.
  103322. * Changing the default value is more performance intensive.
  103323. */
  103324. indiceOfRefraction: number;
  103325. private _texture;
  103326. /**
  103327. * Stores the clear coat values in a texture.
  103328. */
  103329. texture: Nullable<BaseTexture>;
  103330. private _bumpTexture;
  103331. /**
  103332. * Define the clear coat specific bump texture.
  103333. */
  103334. bumpTexture: Nullable<BaseTexture>;
  103335. private _isTintEnabled;
  103336. /**
  103337. * Defines if the clear coat tint is enabled in the material.
  103338. */
  103339. isTintEnabled: boolean;
  103340. /**
  103341. * Defines the clear coat tint of the material.
  103342. * This is only use if tint is enabled
  103343. */
  103344. tintColor: Color3;
  103345. /**
  103346. * Defines the distance at which the tint color should be found in the
  103347. * clear coat media.
  103348. * This is only use if tint is enabled
  103349. */
  103350. tintColorAtDistance: number;
  103351. /**
  103352. * Defines the clear coat layer thickness.
  103353. * This is only use if tint is enabled
  103354. */
  103355. tintThickness: number;
  103356. private _tintTexture;
  103357. /**
  103358. * Stores the clear tint values in a texture.
  103359. * rgb is tint
  103360. * a is a thickness factor
  103361. */
  103362. tintTexture: Nullable<BaseTexture>;
  103363. /** @hidden */
  103364. private _internalMarkAllSubMeshesAsTexturesDirty;
  103365. /** @hidden */
  103366. _markAllSubMeshesAsTexturesDirty(): void;
  103367. /**
  103368. * Instantiate a new istance of clear coat configuration.
  103369. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103370. */
  103371. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103372. /**
  103373. * Gets wehter the submesh is ready to be used or not.
  103374. * @param defines the list of "defines" to update.
  103375. * @param scene defines the scene the material belongs to.
  103376. * @param engine defines the engine the material belongs to.
  103377. * @param disableBumpMap defines wether the material disables bump or not.
  103378. * @returns - boolean indicating that the submesh is ready or not.
  103379. */
  103380. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  103381. /**
  103382. * Checks to see if a texture is used in the material.
  103383. * @param defines the list of "defines" to update.
  103384. * @param scene defines the scene to the material belongs to.
  103385. */
  103386. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  103387. /**
  103388. * Binds the material data.
  103389. * @param uniformBuffer defines the Uniform buffer to fill in.
  103390. * @param scene defines the scene the material belongs to.
  103391. * @param engine defines the engine the material belongs to.
  103392. * @param disableBumpMap defines wether the material disables bump or not.
  103393. * @param isFrozen defines wether the material is frozen or not.
  103394. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  103395. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  103396. */
  103397. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  103398. /**
  103399. * Checks to see if a texture is used in the material.
  103400. * @param texture - Base texture to use.
  103401. * @returns - Boolean specifying if a texture is used in the material.
  103402. */
  103403. hasTexture(texture: BaseTexture): boolean;
  103404. /**
  103405. * Returns an array of the actively used textures.
  103406. * @param activeTextures Array of BaseTextures
  103407. */
  103408. getActiveTextures(activeTextures: BaseTexture[]): void;
  103409. /**
  103410. * Returns the animatable textures.
  103411. * @param animatables Array of animatable textures.
  103412. */
  103413. getAnimatables(animatables: IAnimatable[]): void;
  103414. /**
  103415. * Disposes the resources of the material.
  103416. * @param forceDisposeTextures - Forces the disposal of all textures.
  103417. */
  103418. dispose(forceDisposeTextures?: boolean): void;
  103419. /**
  103420. * Get the current class name of the texture useful for serialization or dynamic coding.
  103421. * @returns "PBRClearCoatConfiguration"
  103422. */
  103423. getClassName(): string;
  103424. /**
  103425. * Add fallbacks to the effect fallbacks list.
  103426. * @param defines defines the Base texture to use.
  103427. * @param fallbacks defines the current fallback list.
  103428. * @param currentRank defines the current fallback rank.
  103429. * @returns the new fallback rank.
  103430. */
  103431. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103432. /**
  103433. * Add the required uniforms to the current list.
  103434. * @param uniforms defines the current uniform list.
  103435. */
  103436. static AddUniforms(uniforms: string[]): void;
  103437. /**
  103438. * Add the required samplers to the current list.
  103439. * @param samplers defines the current sampler list.
  103440. */
  103441. static AddSamplers(samplers: string[]): void;
  103442. /**
  103443. * Add the required uniforms to the current buffer.
  103444. * @param uniformBuffer defines the current uniform buffer.
  103445. */
  103446. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103447. /**
  103448. * Makes a duplicate of the current configuration into another one.
  103449. * @param clearCoatConfiguration define the config where to copy the info
  103450. */
  103451. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  103452. /**
  103453. * Serializes this clear coat configuration.
  103454. * @returns - An object with the serialized config.
  103455. */
  103456. serialize(): any;
  103457. /**
  103458. * Parses a Clear Coat Configuration from a serialized object.
  103459. * @param source - Serialized object.
  103460. */
  103461. parse(source: any): void;
  103462. }
  103463. }
  103464. declare module BABYLON {
  103465. /**
  103466. * @hidden
  103467. */
  103468. export interface IMaterialAnisotropicDefines {
  103469. ANISOTROPIC: boolean;
  103470. ANISOTROPIC_TEXTURE: boolean;
  103471. ANISOTROPIC_TEXTUREDIRECTUV: number;
  103472. MAINUV1: boolean;
  103473. _areTexturesDirty: boolean;
  103474. _needUVs: boolean;
  103475. }
  103476. /**
  103477. * Define the code related to the anisotropic parameters of the pbr material.
  103478. */
  103479. export class PBRAnisotropicConfiguration {
  103480. private _isEnabled;
  103481. /**
  103482. * Defines if the anisotropy is enabled in the material.
  103483. */
  103484. isEnabled: boolean;
  103485. /**
  103486. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  103487. */
  103488. intensity: number;
  103489. /**
  103490. * Defines if the effect is along the tangents, bitangents or in between.
  103491. * By default, the effect is "strectching" the highlights along the tangents.
  103492. */
  103493. direction: Vector2;
  103494. private _texture;
  103495. /**
  103496. * Stores the anisotropy values in a texture.
  103497. * rg is direction (like normal from -1 to 1)
  103498. * b is a intensity
  103499. */
  103500. texture: Nullable<BaseTexture>;
  103501. /** @hidden */
  103502. private _internalMarkAllSubMeshesAsTexturesDirty;
  103503. /** @hidden */
  103504. _markAllSubMeshesAsTexturesDirty(): void;
  103505. /**
  103506. * Instantiate a new istance of anisotropy configuration.
  103507. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103508. */
  103509. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103510. /**
  103511. * Specifies that the submesh is ready to be used.
  103512. * @param defines the list of "defines" to update.
  103513. * @param scene defines the scene the material belongs to.
  103514. * @returns - boolean indicating that the submesh is ready or not.
  103515. */
  103516. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  103517. /**
  103518. * Checks to see if a texture is used in the material.
  103519. * @param defines the list of "defines" to update.
  103520. * @param mesh the mesh we are preparing the defines for.
  103521. * @param scene defines the scene the material belongs to.
  103522. */
  103523. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  103524. /**
  103525. * Binds the material data.
  103526. * @param uniformBuffer defines the Uniform buffer to fill in.
  103527. * @param scene defines the scene the material belongs to.
  103528. * @param isFrozen defines wether the material is frozen or not.
  103529. */
  103530. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103531. /**
  103532. * Checks to see if a texture is used in the material.
  103533. * @param texture - Base texture to use.
  103534. * @returns - Boolean specifying if a texture is used in the material.
  103535. */
  103536. hasTexture(texture: BaseTexture): boolean;
  103537. /**
  103538. * Returns an array of the actively used textures.
  103539. * @param activeTextures Array of BaseTextures
  103540. */
  103541. getActiveTextures(activeTextures: BaseTexture[]): void;
  103542. /**
  103543. * Returns the animatable textures.
  103544. * @param animatables Array of animatable textures.
  103545. */
  103546. getAnimatables(animatables: IAnimatable[]): void;
  103547. /**
  103548. * Disposes the resources of the material.
  103549. * @param forceDisposeTextures - Forces the disposal of all textures.
  103550. */
  103551. dispose(forceDisposeTextures?: boolean): void;
  103552. /**
  103553. * Get the current class name of the texture useful for serialization or dynamic coding.
  103554. * @returns "PBRAnisotropicConfiguration"
  103555. */
  103556. getClassName(): string;
  103557. /**
  103558. * Add fallbacks to the effect fallbacks list.
  103559. * @param defines defines the Base texture to use.
  103560. * @param fallbacks defines the current fallback list.
  103561. * @param currentRank defines the current fallback rank.
  103562. * @returns the new fallback rank.
  103563. */
  103564. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103565. /**
  103566. * Add the required uniforms to the current list.
  103567. * @param uniforms defines the current uniform list.
  103568. */
  103569. static AddUniforms(uniforms: string[]): void;
  103570. /**
  103571. * Add the required uniforms to the current buffer.
  103572. * @param uniformBuffer defines the current uniform buffer.
  103573. */
  103574. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103575. /**
  103576. * Add the required samplers to the current list.
  103577. * @param samplers defines the current sampler list.
  103578. */
  103579. static AddSamplers(samplers: string[]): void;
  103580. /**
  103581. * Makes a duplicate of the current configuration into another one.
  103582. * @param anisotropicConfiguration define the config where to copy the info
  103583. */
  103584. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  103585. /**
  103586. * Serializes this anisotropy configuration.
  103587. * @returns - An object with the serialized config.
  103588. */
  103589. serialize(): any;
  103590. /**
  103591. * Parses a anisotropy Configuration from a serialized object.
  103592. * @param source - Serialized object.
  103593. */
  103594. parse(source: any): void;
  103595. }
  103596. }
  103597. declare module BABYLON {
  103598. /**
  103599. * @hidden
  103600. */
  103601. export interface IMaterialBRDFDefines {
  103602. BRDF_V_HEIGHT_CORRELATED: boolean;
  103603. MS_BRDF_ENERGY_CONSERVATION: boolean;
  103604. /** @hidden */
  103605. _areMiscDirty: boolean;
  103606. }
  103607. /**
  103608. * Define the code related to the BRDF parameters of the pbr material.
  103609. */
  103610. export class PBRBRDFConfiguration {
  103611. /**
  103612. * Default value used for the energy conservation.
  103613. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103614. */
  103615. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  103616. /**
  103617. * Default value used for the Smith Visibility Height Correlated mode.
  103618. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  103619. */
  103620. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  103621. private _useEnergyConservation;
  103622. /**
  103623. * Defines if the material uses energy conservation.
  103624. */
  103625. useEnergyConservation: boolean;
  103626. private _useSmithVisibilityHeightCorrelated;
  103627. /**
  103628. * LEGACY Mode set to false
  103629. * Defines if the material uses height smith correlated visibility term.
  103630. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  103631. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  103632. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  103633. * Not relying on height correlated will also disable energy conservation.
  103634. */
  103635. useSmithVisibilityHeightCorrelated: boolean;
  103636. /** @hidden */
  103637. private _internalMarkAllSubMeshesAsMiscDirty;
  103638. /** @hidden */
  103639. _markAllSubMeshesAsMiscDirty(): void;
  103640. /**
  103641. * Instantiate a new istance of clear coat configuration.
  103642. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  103643. */
  103644. constructor(markAllSubMeshesAsMiscDirty: () => void);
  103645. /**
  103646. * Checks to see if a texture is used in the material.
  103647. * @param defines the list of "defines" to update.
  103648. */
  103649. prepareDefines(defines: IMaterialBRDFDefines): void;
  103650. /**
  103651. * Get the current class name of the texture useful for serialization or dynamic coding.
  103652. * @returns "PBRClearCoatConfiguration"
  103653. */
  103654. getClassName(): string;
  103655. /**
  103656. * Makes a duplicate of the current configuration into another one.
  103657. * @param brdfConfiguration define the config where to copy the info
  103658. */
  103659. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  103660. /**
  103661. * Serializes this BRDF configuration.
  103662. * @returns - An object with the serialized config.
  103663. */
  103664. serialize(): any;
  103665. /**
  103666. * Parses a BRDF Configuration from a serialized object.
  103667. * @param source - Serialized object.
  103668. */
  103669. parse(source: any): void;
  103670. }
  103671. }
  103672. declare module BABYLON {
  103673. /**
  103674. * @hidden
  103675. */
  103676. export interface IMaterialSheenDefines {
  103677. SHEEN: boolean;
  103678. SHEEN_TEXTURE: boolean;
  103679. SHEEN_TEXTUREDIRECTUV: number;
  103680. SHEEN_LINKWITHALBEDO: boolean;
  103681. /** @hidden */
  103682. _areTexturesDirty: boolean;
  103683. }
  103684. /**
  103685. * Define the code related to the Sheen parameters of the pbr material.
  103686. */
  103687. export class PBRSheenConfiguration {
  103688. private _isEnabled;
  103689. /**
  103690. * Defines if the material uses sheen.
  103691. */
  103692. isEnabled: boolean;
  103693. private _linkSheenWithAlbedo;
  103694. /**
  103695. * Defines if the sheen is linked to the sheen color.
  103696. */
  103697. linkSheenWithAlbedo: boolean;
  103698. /**
  103699. * Defines the sheen intensity.
  103700. */
  103701. intensity: number;
  103702. /**
  103703. * Defines the sheen color.
  103704. */
  103705. color: Color3;
  103706. private _texture;
  103707. /**
  103708. * Stores the sheen tint values in a texture.
  103709. * rgb is tint
  103710. * a is a intensity
  103711. */
  103712. texture: Nullable<BaseTexture>;
  103713. /** @hidden */
  103714. private _internalMarkAllSubMeshesAsTexturesDirty;
  103715. /** @hidden */
  103716. _markAllSubMeshesAsTexturesDirty(): void;
  103717. /**
  103718. * Instantiate a new istance of clear coat configuration.
  103719. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103720. */
  103721. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103722. /**
  103723. * Specifies that the submesh is ready to be used.
  103724. * @param defines the list of "defines" to update.
  103725. * @param scene defines the scene the material belongs to.
  103726. * @returns - boolean indicating that the submesh is ready or not.
  103727. */
  103728. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  103729. /**
  103730. * Checks to see if a texture is used in the material.
  103731. * @param defines the list of "defines" to update.
  103732. * @param scene defines the scene the material belongs to.
  103733. */
  103734. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  103735. /**
  103736. * Binds the material data.
  103737. * @param uniformBuffer defines the Uniform buffer to fill in.
  103738. * @param scene defines the scene the material belongs to.
  103739. * @param isFrozen defines wether the material is frozen or not.
  103740. */
  103741. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  103742. /**
  103743. * Checks to see if a texture is used in the material.
  103744. * @param texture - Base texture to use.
  103745. * @returns - Boolean specifying if a texture is used in the material.
  103746. */
  103747. hasTexture(texture: BaseTexture): boolean;
  103748. /**
  103749. * Returns an array of the actively used textures.
  103750. * @param activeTextures Array of BaseTextures
  103751. */
  103752. getActiveTextures(activeTextures: BaseTexture[]): void;
  103753. /**
  103754. * Returns the animatable textures.
  103755. * @param animatables Array of animatable textures.
  103756. */
  103757. getAnimatables(animatables: IAnimatable[]): void;
  103758. /**
  103759. * Disposes the resources of the material.
  103760. * @param forceDisposeTextures - Forces the disposal of all textures.
  103761. */
  103762. dispose(forceDisposeTextures?: boolean): void;
  103763. /**
  103764. * Get the current class name of the texture useful for serialization or dynamic coding.
  103765. * @returns "PBRSheenConfiguration"
  103766. */
  103767. getClassName(): string;
  103768. /**
  103769. * Add fallbacks to the effect fallbacks list.
  103770. * @param defines defines the Base texture to use.
  103771. * @param fallbacks defines the current fallback list.
  103772. * @param currentRank defines the current fallback rank.
  103773. * @returns the new fallback rank.
  103774. */
  103775. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  103776. /**
  103777. * Add the required uniforms to the current list.
  103778. * @param uniforms defines the current uniform list.
  103779. */
  103780. static AddUniforms(uniforms: string[]): void;
  103781. /**
  103782. * Add the required uniforms to the current buffer.
  103783. * @param uniformBuffer defines the current uniform buffer.
  103784. */
  103785. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  103786. /**
  103787. * Add the required samplers to the current list.
  103788. * @param samplers defines the current sampler list.
  103789. */
  103790. static AddSamplers(samplers: string[]): void;
  103791. /**
  103792. * Makes a duplicate of the current configuration into another one.
  103793. * @param sheenConfiguration define the config where to copy the info
  103794. */
  103795. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  103796. /**
  103797. * Serializes this BRDF configuration.
  103798. * @returns - An object with the serialized config.
  103799. */
  103800. serialize(): any;
  103801. /**
  103802. * Parses a Sheen Configuration from a serialized object.
  103803. * @param source - Serialized object.
  103804. */
  103805. parse(source: any): void;
  103806. }
  103807. }
  103808. declare module BABYLON {
  103809. /**
  103810. * @hidden
  103811. */
  103812. export interface IMaterialSubSurfaceDefines {
  103813. SUBSURFACE: boolean;
  103814. SS_REFRACTION: boolean;
  103815. SS_TRANSLUCENCY: boolean;
  103816. SS_SCATERRING: boolean;
  103817. SS_THICKNESSANDMASK_TEXTURE: boolean;
  103818. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  103819. SS_REFRACTIONMAP_3D: boolean;
  103820. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  103821. SS_LODINREFRACTIONALPHA: boolean;
  103822. SS_GAMMAREFRACTION: boolean;
  103823. SS_RGBDREFRACTION: boolean;
  103824. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  103825. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  103826. /** @hidden */
  103827. _areTexturesDirty: boolean;
  103828. }
  103829. /**
  103830. * Define the code related to the sub surface parameters of the pbr material.
  103831. */
  103832. export class PBRSubSurfaceConfiguration {
  103833. private _isRefractionEnabled;
  103834. /**
  103835. * Defines if the refraction is enabled in the material.
  103836. */
  103837. isRefractionEnabled: boolean;
  103838. private _isTranslucencyEnabled;
  103839. /**
  103840. * Defines if the translucency is enabled in the material.
  103841. */
  103842. isTranslucencyEnabled: boolean;
  103843. private _isScatteringEnabled;
  103844. /**
  103845. * Defines the refraction intensity of the material.
  103846. * The refraction when enabled replaces the Diffuse part of the material.
  103847. * The intensity helps transitionning between diffuse and refraction.
  103848. */
  103849. refractionIntensity: number;
  103850. /**
  103851. * Defines the translucency intensity of the material.
  103852. * When translucency has been enabled, this defines how much of the "translucency"
  103853. * is addded to the diffuse part of the material.
  103854. */
  103855. translucencyIntensity: number;
  103856. /**
  103857. * Defines the scattering intensity of the material.
  103858. * When scattering has been enabled, this defines how much of the "scattered light"
  103859. * is addded to the diffuse part of the material.
  103860. */
  103861. scatteringIntensity: number;
  103862. private _thicknessTexture;
  103863. /**
  103864. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  103865. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  103866. * 0 would mean minimumThickness
  103867. * 1 would mean maximumThickness
  103868. * The other channels might be use as a mask to vary the different effects intensity.
  103869. */
  103870. thicknessTexture: Nullable<BaseTexture>;
  103871. private _refractionTexture;
  103872. /**
  103873. * Defines the texture to use for refraction.
  103874. */
  103875. refractionTexture: Nullable<BaseTexture>;
  103876. private _indexOfRefraction;
  103877. /**
  103878. * Defines the indice of refraction used in the material.
  103879. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  103880. */
  103881. indexOfRefraction: number;
  103882. private _invertRefractionY;
  103883. /**
  103884. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  103885. */
  103886. invertRefractionY: boolean;
  103887. private _linkRefractionWithTransparency;
  103888. /**
  103889. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  103890. * Materials half opaque for instance using refraction could benefit from this control.
  103891. */
  103892. linkRefractionWithTransparency: boolean;
  103893. /**
  103894. * Defines the minimum thickness stored in the thickness map.
  103895. * If no thickness map is defined, this value will be used to simulate thickness.
  103896. */
  103897. minimumThickness: number;
  103898. /**
  103899. * Defines the maximum thickness stored in the thickness map.
  103900. */
  103901. maximumThickness: number;
  103902. /**
  103903. * Defines the volume tint of the material.
  103904. * This is used for both translucency and scattering.
  103905. */
  103906. tintColor: Color3;
  103907. /**
  103908. * Defines the distance at which the tint color should be found in the media.
  103909. * This is used for refraction only.
  103910. */
  103911. tintColorAtDistance: number;
  103912. /**
  103913. * Defines how far each channel transmit through the media.
  103914. * It is defined as a color to simplify it selection.
  103915. */
  103916. diffusionDistance: Color3;
  103917. private _useMaskFromThicknessTexture;
  103918. /**
  103919. * Stores the intensity of the different subsurface effects in the thickness texture.
  103920. * * the green channel is the translucency intensity.
  103921. * * the blue channel is the scattering intensity.
  103922. * * the alpha channel is the refraction intensity.
  103923. */
  103924. useMaskFromThicknessTexture: boolean;
  103925. /** @hidden */
  103926. private _internalMarkAllSubMeshesAsTexturesDirty;
  103927. /** @hidden */
  103928. _markAllSubMeshesAsTexturesDirty(): void;
  103929. /**
  103930. * Instantiate a new istance of sub surface configuration.
  103931. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  103932. */
  103933. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  103934. /**
  103935. * Gets wehter the submesh is ready to be used or not.
  103936. * @param defines the list of "defines" to update.
  103937. * @param scene defines the scene the material belongs to.
  103938. * @returns - boolean indicating that the submesh is ready or not.
  103939. */
  103940. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  103941. /**
  103942. * Checks to see if a texture is used in the material.
  103943. * @param defines the list of "defines" to update.
  103944. * @param scene defines the scene to the material belongs to.
  103945. */
  103946. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  103947. /**
  103948. * Binds the material data.
  103949. * @param uniformBuffer defines the Uniform buffer to fill in.
  103950. * @param scene defines the scene the material belongs to.
  103951. * @param engine defines the engine the material belongs to.
  103952. * @param isFrozen defines wether the material is frozen or not.
  103953. * @param lodBasedMicrosurface defines wether the material relies on lod based microsurface or not.
  103954. */
  103955. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean): void;
  103956. /**
  103957. * Unbinds the material from the mesh.
  103958. * @param activeEffect defines the effect that should be unbound from.
  103959. * @returns true if unbound, otherwise false
  103960. */
  103961. unbind(activeEffect: Effect): boolean;
  103962. /**
  103963. * Returns the texture used for refraction or null if none is used.
  103964. * @param scene defines the scene the material belongs to.
  103965. * @returns - Refraction texture if present. If no refraction texture and refraction
  103966. * is linked with transparency, returns environment texture. Otherwise, returns null.
  103967. */
  103968. private _getRefractionTexture;
  103969. /**
  103970. * Returns true if alpha blending should be disabled.
  103971. */
  103972. readonly disableAlphaBlending: boolean;
  103973. /**
  103974. * Fills the list of render target textures.
  103975. * @param renderTargets the list of render targets to update
  103976. */
  103977. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  103978. /**
  103979. * Checks to see if a texture is used in the material.
  103980. * @param texture - Base texture to use.
  103981. * @returns - Boolean specifying if a texture is used in the material.
  103982. */
  103983. hasTexture(texture: BaseTexture): boolean;
  103984. /**
  103985. * Gets a boolean indicating that current material needs to register RTT
  103986. * @returns true if this uses a render target otherwise false.
  103987. */
  103988. hasRenderTargetTextures(): boolean;
  103989. /**
  103990. * Returns an array of the actively used textures.
  103991. * @param activeTextures Array of BaseTextures
  103992. */
  103993. getActiveTextures(activeTextures: BaseTexture[]): void;
  103994. /**
  103995. * Returns the animatable textures.
  103996. * @param animatables Array of animatable textures.
  103997. */
  103998. getAnimatables(animatables: IAnimatable[]): void;
  103999. /**
  104000. * Disposes the resources of the material.
  104001. * @param forceDisposeTextures - Forces the disposal of all textures.
  104002. */
  104003. dispose(forceDisposeTextures?: boolean): void;
  104004. /**
  104005. * Get the current class name of the texture useful for serialization or dynamic coding.
  104006. * @returns "PBRSubSurfaceConfiguration"
  104007. */
  104008. getClassName(): string;
  104009. /**
  104010. * Add fallbacks to the effect fallbacks list.
  104011. * @param defines defines the Base texture to use.
  104012. * @param fallbacks defines the current fallback list.
  104013. * @param currentRank defines the current fallback rank.
  104014. * @returns the new fallback rank.
  104015. */
  104016. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  104017. /**
  104018. * Add the required uniforms to the current list.
  104019. * @param uniforms defines the current uniform list.
  104020. */
  104021. static AddUniforms(uniforms: string[]): void;
  104022. /**
  104023. * Add the required samplers to the current list.
  104024. * @param samplers defines the current sampler list.
  104025. */
  104026. static AddSamplers(samplers: string[]): void;
  104027. /**
  104028. * Add the required uniforms to the current buffer.
  104029. * @param uniformBuffer defines the current uniform buffer.
  104030. */
  104031. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  104032. /**
  104033. * Makes a duplicate of the current configuration into another one.
  104034. * @param configuration define the config where to copy the info
  104035. */
  104036. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  104037. /**
  104038. * Serializes this Sub Surface configuration.
  104039. * @returns - An object with the serialized config.
  104040. */
  104041. serialize(): any;
  104042. /**
  104043. * Parses a Sub Surface Configuration from a serialized object.
  104044. * @param source - Serialized object.
  104045. */
  104046. parse(source: any): void;
  104047. }
  104048. }
  104049. declare module BABYLON {
  104050. /** @hidden */
  104051. export var pbrFragmentDeclaration: {
  104052. name: string;
  104053. shader: string;
  104054. };
  104055. }
  104056. declare module BABYLON {
  104057. /** @hidden */
  104058. export var pbrUboDeclaration: {
  104059. name: string;
  104060. shader: string;
  104061. };
  104062. }
  104063. declare module BABYLON {
  104064. /** @hidden */
  104065. export var pbrFragmentExtraDeclaration: {
  104066. name: string;
  104067. shader: string;
  104068. };
  104069. }
  104070. declare module BABYLON {
  104071. /** @hidden */
  104072. export var pbrFragmentSamplersDeclaration: {
  104073. name: string;
  104074. shader: string;
  104075. };
  104076. }
  104077. declare module BABYLON {
  104078. /** @hidden */
  104079. export var pbrHelperFunctions: {
  104080. name: string;
  104081. shader: string;
  104082. };
  104083. }
  104084. declare module BABYLON {
  104085. /** @hidden */
  104086. export var harmonicsFunctions: {
  104087. name: string;
  104088. shader: string;
  104089. };
  104090. }
  104091. declare module BABYLON {
  104092. /** @hidden */
  104093. export var pbrDirectLightingSetupFunctions: {
  104094. name: string;
  104095. shader: string;
  104096. };
  104097. }
  104098. declare module BABYLON {
  104099. /** @hidden */
  104100. export var pbrDirectLightingFalloffFunctions: {
  104101. name: string;
  104102. shader: string;
  104103. };
  104104. }
  104105. declare module BABYLON {
  104106. /** @hidden */
  104107. export var pbrBRDFFunctions: {
  104108. name: string;
  104109. shader: string;
  104110. };
  104111. }
  104112. declare module BABYLON {
  104113. /** @hidden */
  104114. export var pbrDirectLightingFunctions: {
  104115. name: string;
  104116. shader: string;
  104117. };
  104118. }
  104119. declare module BABYLON {
  104120. /** @hidden */
  104121. export var pbrIBLFunctions: {
  104122. name: string;
  104123. shader: string;
  104124. };
  104125. }
  104126. declare module BABYLON {
  104127. /** @hidden */
  104128. export var pbrDebug: {
  104129. name: string;
  104130. shader: string;
  104131. };
  104132. }
  104133. declare module BABYLON {
  104134. /** @hidden */
  104135. export var pbrPixelShader: {
  104136. name: string;
  104137. shader: string;
  104138. };
  104139. }
  104140. declare module BABYLON {
  104141. /** @hidden */
  104142. export var pbrVertexDeclaration: {
  104143. name: string;
  104144. shader: string;
  104145. };
  104146. }
  104147. declare module BABYLON {
  104148. /** @hidden */
  104149. export var pbrVertexShader: {
  104150. name: string;
  104151. shader: string;
  104152. };
  104153. }
  104154. declare module BABYLON {
  104155. /**
  104156. * Manages the defines for the PBR Material.
  104157. * @hidden
  104158. */
  104159. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines {
  104160. PBR: boolean;
  104161. MAINUV1: boolean;
  104162. MAINUV2: boolean;
  104163. UV1: boolean;
  104164. UV2: boolean;
  104165. ALBEDO: boolean;
  104166. ALBEDODIRECTUV: number;
  104167. VERTEXCOLOR: boolean;
  104168. AMBIENT: boolean;
  104169. AMBIENTDIRECTUV: number;
  104170. AMBIENTINGRAYSCALE: boolean;
  104171. OPACITY: boolean;
  104172. VERTEXALPHA: boolean;
  104173. OPACITYDIRECTUV: number;
  104174. OPACITYRGB: boolean;
  104175. ALPHATEST: boolean;
  104176. DEPTHPREPASS: boolean;
  104177. ALPHABLEND: boolean;
  104178. ALPHAFROMALBEDO: boolean;
  104179. ALPHATESTVALUE: string;
  104180. SPECULAROVERALPHA: boolean;
  104181. RADIANCEOVERALPHA: boolean;
  104182. ALPHAFRESNEL: boolean;
  104183. LINEARALPHAFRESNEL: boolean;
  104184. PREMULTIPLYALPHA: boolean;
  104185. EMISSIVE: boolean;
  104186. EMISSIVEDIRECTUV: number;
  104187. REFLECTIVITY: boolean;
  104188. REFLECTIVITYDIRECTUV: number;
  104189. SPECULARTERM: boolean;
  104190. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  104191. MICROSURFACEAUTOMATIC: boolean;
  104192. LODBASEDMICROSFURACE: boolean;
  104193. MICROSURFACEMAP: boolean;
  104194. MICROSURFACEMAPDIRECTUV: number;
  104195. METALLICWORKFLOW: boolean;
  104196. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  104197. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  104198. METALLNESSSTOREINMETALMAPBLUE: boolean;
  104199. AOSTOREINMETALMAPRED: boolean;
  104200. ENVIRONMENTBRDF: boolean;
  104201. ENVIRONMENTBRDF_RGBD: boolean;
  104202. NORMAL: boolean;
  104203. TANGENT: boolean;
  104204. BUMP: boolean;
  104205. BUMPDIRECTUV: number;
  104206. OBJECTSPACE_NORMALMAP: boolean;
  104207. PARALLAX: boolean;
  104208. PARALLAXOCCLUSION: boolean;
  104209. NORMALXYSCALE: boolean;
  104210. LIGHTMAP: boolean;
  104211. LIGHTMAPDIRECTUV: number;
  104212. USELIGHTMAPASSHADOWMAP: boolean;
  104213. GAMMALIGHTMAP: boolean;
  104214. REFLECTION: boolean;
  104215. REFLECTIONMAP_3D: boolean;
  104216. REFLECTIONMAP_SPHERICAL: boolean;
  104217. REFLECTIONMAP_PLANAR: boolean;
  104218. REFLECTIONMAP_CUBIC: boolean;
  104219. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  104220. REFLECTIONMAP_PROJECTION: boolean;
  104221. REFLECTIONMAP_SKYBOX: boolean;
  104222. REFLECTIONMAP_SKYBOX_TRANSFORMED: boolean;
  104223. REFLECTIONMAP_EXPLICIT: boolean;
  104224. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  104225. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  104226. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  104227. INVERTCUBICMAP: boolean;
  104228. USESPHERICALFROMREFLECTIONMAP: boolean;
  104229. USESPHERICALINVERTEX: boolean;
  104230. REFLECTIONMAP_OPPOSITEZ: boolean;
  104231. LODINREFLECTIONALPHA: boolean;
  104232. GAMMAREFLECTION: boolean;
  104233. RGBDREFLECTION: boolean;
  104234. RADIANCEOCCLUSION: boolean;
  104235. HORIZONOCCLUSION: boolean;
  104236. INSTANCES: boolean;
  104237. NUM_BONE_INFLUENCERS: number;
  104238. BonesPerMesh: number;
  104239. BONETEXTURE: boolean;
  104240. NONUNIFORMSCALING: boolean;
  104241. MORPHTARGETS: boolean;
  104242. MORPHTARGETS_NORMAL: boolean;
  104243. MORPHTARGETS_TANGENT: boolean;
  104244. NUM_MORPH_INFLUENCERS: number;
  104245. IMAGEPROCESSING: boolean;
  104246. VIGNETTE: boolean;
  104247. VIGNETTEBLENDMODEMULTIPLY: boolean;
  104248. VIGNETTEBLENDMODEOPAQUE: boolean;
  104249. TONEMAPPING: boolean;
  104250. TONEMAPPING_ACES: boolean;
  104251. CONTRAST: boolean;
  104252. COLORCURVES: boolean;
  104253. COLORGRADING: boolean;
  104254. COLORGRADING3D: boolean;
  104255. SAMPLER3DGREENDEPTH: boolean;
  104256. SAMPLER3DBGRMAP: boolean;
  104257. IMAGEPROCESSINGPOSTPROCESS: boolean;
  104258. EXPOSURE: boolean;
  104259. MULTIVIEW: boolean;
  104260. USEPHYSICALLIGHTFALLOFF: boolean;
  104261. USEGLTFLIGHTFALLOFF: boolean;
  104262. TWOSIDEDLIGHTING: boolean;
  104263. SHADOWFLOAT: boolean;
  104264. CLIPPLANE: boolean;
  104265. CLIPPLANE2: boolean;
  104266. CLIPPLANE3: boolean;
  104267. CLIPPLANE4: boolean;
  104268. POINTSIZE: boolean;
  104269. FOG: boolean;
  104270. LOGARITHMICDEPTH: boolean;
  104271. FORCENORMALFORWARD: boolean;
  104272. SPECULARAA: boolean;
  104273. CLEARCOAT: boolean;
  104274. CLEARCOAT_DEFAULTIOR: boolean;
  104275. CLEARCOAT_TEXTURE: boolean;
  104276. CLEARCOAT_TEXTUREDIRECTUV: number;
  104277. CLEARCOAT_BUMP: boolean;
  104278. CLEARCOAT_BUMPDIRECTUV: number;
  104279. CLEARCOAT_TINT: boolean;
  104280. CLEARCOAT_TINT_TEXTURE: boolean;
  104281. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  104282. ANISOTROPIC: boolean;
  104283. ANISOTROPIC_TEXTURE: boolean;
  104284. ANISOTROPIC_TEXTUREDIRECTUV: number;
  104285. BRDF_V_HEIGHT_CORRELATED: boolean;
  104286. MS_BRDF_ENERGY_CONSERVATION: boolean;
  104287. SHEEN: boolean;
  104288. SHEEN_TEXTURE: boolean;
  104289. SHEEN_TEXTUREDIRECTUV: number;
  104290. SHEEN_LINKWITHALBEDO: boolean;
  104291. SUBSURFACE: boolean;
  104292. SS_REFRACTION: boolean;
  104293. SS_TRANSLUCENCY: boolean;
  104294. SS_SCATERRING: boolean;
  104295. SS_THICKNESSANDMASK_TEXTURE: boolean;
  104296. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  104297. SS_REFRACTIONMAP_3D: boolean;
  104298. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  104299. SS_LODINREFRACTIONALPHA: boolean;
  104300. SS_GAMMAREFRACTION: boolean;
  104301. SS_RGBDREFRACTION: boolean;
  104302. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  104303. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  104304. UNLIT: boolean;
  104305. DEBUGMODE: number;
  104306. /**
  104307. * Initializes the PBR Material defines.
  104308. */
  104309. constructor();
  104310. /**
  104311. * Resets the PBR Material defines.
  104312. */
  104313. reset(): void;
  104314. }
  104315. /**
  104316. * The Physically based material base class of BJS.
  104317. *
  104318. * This offers the main features of a standard PBR material.
  104319. * For more information, please refer to the documentation :
  104320. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104321. */
  104322. export abstract class PBRBaseMaterial extends PushMaterial {
  104323. /**
  104324. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104325. */
  104326. static readonly PBRMATERIAL_OPAQUE: number;
  104327. /**
  104328. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104329. */
  104330. static readonly PBRMATERIAL_ALPHATEST: number;
  104331. /**
  104332. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104333. */
  104334. static readonly PBRMATERIAL_ALPHABLEND: number;
  104335. /**
  104336. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104337. * They are also discarded below the alpha cutoff threshold to improve performances.
  104338. */
  104339. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104340. /**
  104341. * Defines the default value of how much AO map is occluding the analytical lights
  104342. * (point spot...).
  104343. */
  104344. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104345. /**
  104346. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  104347. */
  104348. static readonly LIGHTFALLOFF_PHYSICAL: number;
  104349. /**
  104350. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  104351. * to enhance interoperability with other engines.
  104352. */
  104353. static readonly LIGHTFALLOFF_GLTF: number;
  104354. /**
  104355. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  104356. * to enhance interoperability with other materials.
  104357. */
  104358. static readonly LIGHTFALLOFF_STANDARD: number;
  104359. /**
  104360. * Intensity of the direct lights e.g. the four lights available in your scene.
  104361. * This impacts both the direct diffuse and specular highlights.
  104362. */
  104363. protected _directIntensity: number;
  104364. /**
  104365. * Intensity of the emissive part of the material.
  104366. * This helps controlling the emissive effect without modifying the emissive color.
  104367. */
  104368. protected _emissiveIntensity: number;
  104369. /**
  104370. * Intensity of the environment e.g. how much the environment will light the object
  104371. * either through harmonics for rough material or through the refelction for shiny ones.
  104372. */
  104373. protected _environmentIntensity: number;
  104374. /**
  104375. * This is a special control allowing the reduction of the specular highlights coming from the
  104376. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104377. */
  104378. protected _specularIntensity: number;
  104379. /**
  104380. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  104381. */
  104382. private _lightingInfos;
  104383. /**
  104384. * Debug Control allowing disabling the bump map on this material.
  104385. */
  104386. protected _disableBumpMap: boolean;
  104387. /**
  104388. * AKA Diffuse Texture in standard nomenclature.
  104389. */
  104390. protected _albedoTexture: Nullable<BaseTexture>;
  104391. /**
  104392. * AKA Occlusion Texture in other nomenclature.
  104393. */
  104394. protected _ambientTexture: Nullable<BaseTexture>;
  104395. /**
  104396. * AKA Occlusion Texture Intensity in other nomenclature.
  104397. */
  104398. protected _ambientTextureStrength: number;
  104399. /**
  104400. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104401. * 1 means it completely occludes it
  104402. * 0 mean it has no impact
  104403. */
  104404. protected _ambientTextureImpactOnAnalyticalLights: number;
  104405. /**
  104406. * Stores the alpha values in a texture.
  104407. */
  104408. protected _opacityTexture: Nullable<BaseTexture>;
  104409. /**
  104410. * Stores the reflection values in a texture.
  104411. */
  104412. protected _reflectionTexture: Nullable<BaseTexture>;
  104413. /**
  104414. * Stores the emissive values in a texture.
  104415. */
  104416. protected _emissiveTexture: Nullable<BaseTexture>;
  104417. /**
  104418. * AKA Specular texture in other nomenclature.
  104419. */
  104420. protected _reflectivityTexture: Nullable<BaseTexture>;
  104421. /**
  104422. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104423. */
  104424. protected _metallicTexture: Nullable<BaseTexture>;
  104425. /**
  104426. * Specifies the metallic scalar of the metallic/roughness workflow.
  104427. * Can also be used to scale the metalness values of the metallic texture.
  104428. */
  104429. protected _metallic: Nullable<number>;
  104430. /**
  104431. * Specifies the roughness scalar of the metallic/roughness workflow.
  104432. * Can also be used to scale the roughness values of the metallic texture.
  104433. */
  104434. protected _roughness: Nullable<number>;
  104435. /**
  104436. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104437. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104438. */
  104439. protected _microSurfaceTexture: Nullable<BaseTexture>;
  104440. /**
  104441. * Stores surface normal data used to displace a mesh in a texture.
  104442. */
  104443. protected _bumpTexture: Nullable<BaseTexture>;
  104444. /**
  104445. * Stores the pre-calculated light information of a mesh in a texture.
  104446. */
  104447. protected _lightmapTexture: Nullable<BaseTexture>;
  104448. /**
  104449. * The color of a material in ambient lighting.
  104450. */
  104451. protected _ambientColor: Color3;
  104452. /**
  104453. * AKA Diffuse Color in other nomenclature.
  104454. */
  104455. protected _albedoColor: Color3;
  104456. /**
  104457. * AKA Specular Color in other nomenclature.
  104458. */
  104459. protected _reflectivityColor: Color3;
  104460. /**
  104461. * The color applied when light is reflected from a material.
  104462. */
  104463. protected _reflectionColor: Color3;
  104464. /**
  104465. * The color applied when light is emitted from a material.
  104466. */
  104467. protected _emissiveColor: Color3;
  104468. /**
  104469. * AKA Glossiness in other nomenclature.
  104470. */
  104471. protected _microSurface: number;
  104472. /**
  104473. * Specifies that the material will use the light map as a show map.
  104474. */
  104475. protected _useLightmapAsShadowmap: boolean;
  104476. /**
  104477. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  104478. * makes the reflect vector face the model (under horizon).
  104479. */
  104480. protected _useHorizonOcclusion: boolean;
  104481. /**
  104482. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  104483. * too much the area relying on ambient texture to define their ambient occlusion.
  104484. */
  104485. protected _useRadianceOcclusion: boolean;
  104486. /**
  104487. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104488. */
  104489. protected _useAlphaFromAlbedoTexture: boolean;
  104490. /**
  104491. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  104492. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104493. */
  104494. protected _useSpecularOverAlpha: boolean;
  104495. /**
  104496. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104497. */
  104498. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104499. /**
  104500. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  104501. */
  104502. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  104503. /**
  104504. * Specifies if the metallic texture contains the roughness information in its green channel.
  104505. */
  104506. protected _useRoughnessFromMetallicTextureGreen: boolean;
  104507. /**
  104508. * Specifies if the metallic texture contains the metallness information in its blue channel.
  104509. */
  104510. protected _useMetallnessFromMetallicTextureBlue: boolean;
  104511. /**
  104512. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  104513. */
  104514. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  104515. /**
  104516. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  104517. */
  104518. protected _useAmbientInGrayScale: boolean;
  104519. /**
  104520. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  104521. * The material will try to infer what glossiness each pixel should be.
  104522. */
  104523. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  104524. /**
  104525. * Defines the falloff type used in this material.
  104526. * It by default is Physical.
  104527. */
  104528. protected _lightFalloff: number;
  104529. /**
  104530. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  104531. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  104532. */
  104533. protected _useRadianceOverAlpha: boolean;
  104534. /**
  104535. * Allows using an object space normal map (instead of tangent space).
  104536. */
  104537. protected _useObjectSpaceNormalMap: boolean;
  104538. /**
  104539. * Allows using the bump map in parallax mode.
  104540. */
  104541. protected _useParallax: boolean;
  104542. /**
  104543. * Allows using the bump map in parallax occlusion mode.
  104544. */
  104545. protected _useParallaxOcclusion: boolean;
  104546. /**
  104547. * Controls the scale bias of the parallax mode.
  104548. */
  104549. protected _parallaxScaleBias: number;
  104550. /**
  104551. * If sets to true, disables all the lights affecting the material.
  104552. */
  104553. protected _disableLighting: boolean;
  104554. /**
  104555. * Number of Simultaneous lights allowed on the material.
  104556. */
  104557. protected _maxSimultaneousLights: number;
  104558. /**
  104559. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  104560. */
  104561. protected _invertNormalMapX: boolean;
  104562. /**
  104563. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  104564. */
  104565. protected _invertNormalMapY: boolean;
  104566. /**
  104567. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  104568. */
  104569. protected _twoSidedLighting: boolean;
  104570. /**
  104571. * Defines the alpha limits in alpha test mode.
  104572. */
  104573. protected _alphaCutOff: number;
  104574. /**
  104575. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104576. */
  104577. protected _forceAlphaTest: boolean;
  104578. /**
  104579. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104580. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  104581. */
  104582. protected _useAlphaFresnel: boolean;
  104583. /**
  104584. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  104585. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  104586. */
  104587. protected _useLinearAlphaFresnel: boolean;
  104588. /**
  104589. * The transparency mode of the material.
  104590. */
  104591. protected _transparencyMode: Nullable<number>;
  104592. /**
  104593. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  104594. * from cos thetav and roughness:
  104595. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  104596. */
  104597. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  104598. /**
  104599. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  104600. */
  104601. protected _forceIrradianceInFragment: boolean;
  104602. /**
  104603. * Force normal to face away from face.
  104604. */
  104605. protected _forceNormalForward: boolean;
  104606. /**
  104607. * Enables specular anti aliasing in the PBR shader.
  104608. * It will both interacts on the Geometry for analytical and IBL lighting.
  104609. * It also prefilter the roughness map based on the bump values.
  104610. */
  104611. protected _enableSpecularAntiAliasing: boolean;
  104612. /**
  104613. * Default configuration related to image processing available in the PBR Material.
  104614. */
  104615. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  104616. /**
  104617. * Keep track of the image processing observer to allow dispose and replace.
  104618. */
  104619. private _imageProcessingObserver;
  104620. /**
  104621. * Attaches a new image processing configuration to the PBR Material.
  104622. * @param configuration
  104623. */
  104624. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  104625. /**
  104626. * Stores the available render targets.
  104627. */
  104628. private _renderTargets;
  104629. /**
  104630. * Sets the global ambient color for the material used in lighting calculations.
  104631. */
  104632. private _globalAmbientColor;
  104633. /**
  104634. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  104635. */
  104636. private _useLogarithmicDepth;
  104637. /**
  104638. * If set to true, no lighting calculations will be applied.
  104639. */
  104640. private _unlit;
  104641. private _debugMode;
  104642. /**
  104643. * @hidden
  104644. * This is reserved for the inspector.
  104645. * Defines the material debug mode.
  104646. * It helps seeing only some components of the material while troubleshooting.
  104647. */
  104648. debugMode: number;
  104649. /**
  104650. * @hidden
  104651. * This is reserved for the inspector.
  104652. * Specify from where on screen the debug mode should start.
  104653. * The value goes from -1 (full screen) to 1 (not visible)
  104654. * It helps with side by side comparison against the final render
  104655. * This defaults to -1
  104656. */
  104657. private debugLimit;
  104658. /**
  104659. * @hidden
  104660. * This is reserved for the inspector.
  104661. * As the default viewing range might not be enough (if the ambient is really small for instance)
  104662. * You can use the factor to better multiply the final value.
  104663. */
  104664. private debugFactor;
  104665. /**
  104666. * Defines the clear coat layer parameters for the material.
  104667. */
  104668. readonly clearCoat: PBRClearCoatConfiguration;
  104669. /**
  104670. * Defines the anisotropic parameters for the material.
  104671. */
  104672. readonly anisotropy: PBRAnisotropicConfiguration;
  104673. /**
  104674. * Defines the BRDF parameters for the material.
  104675. */
  104676. readonly brdf: PBRBRDFConfiguration;
  104677. /**
  104678. * Defines the Sheen parameters for the material.
  104679. */
  104680. readonly sheen: PBRSheenConfiguration;
  104681. /**
  104682. * Defines the SubSurface parameters for the material.
  104683. */
  104684. readonly subSurface: PBRSubSurfaceConfiguration;
  104685. /**
  104686. * Custom callback helping to override the default shader used in the material.
  104687. */
  104688. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: PBRMaterialDefines) => string;
  104689. /**
  104690. * Instantiates a new PBRMaterial instance.
  104691. *
  104692. * @param name The material name
  104693. * @param scene The scene the material will be use in.
  104694. */
  104695. constructor(name: string, scene: Scene);
  104696. /**
  104697. * Gets a boolean indicating that current material needs to register RTT
  104698. */
  104699. readonly hasRenderTargetTextures: boolean;
  104700. /**
  104701. * Gets the name of the material class.
  104702. */
  104703. getClassName(): string;
  104704. /**
  104705. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104706. */
  104707. /**
  104708. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  104709. */
  104710. useLogarithmicDepth: boolean;
  104711. /**
  104712. * Gets the current transparency mode.
  104713. */
  104714. /**
  104715. * Sets the transparency mode of the material.
  104716. *
  104717. * | Value | Type | Description |
  104718. * | ----- | ----------------------------------- | ----------- |
  104719. * | 0 | OPAQUE | |
  104720. * | 1 | ALPHATEST | |
  104721. * | 2 | ALPHABLEND | |
  104722. * | 3 | ALPHATESTANDBLEND | |
  104723. *
  104724. */
  104725. transparencyMode: Nullable<number>;
  104726. /**
  104727. * Returns true if alpha blending should be disabled.
  104728. */
  104729. private readonly _disableAlphaBlending;
  104730. /**
  104731. * Specifies whether or not this material should be rendered in alpha blend mode.
  104732. */
  104733. needAlphaBlending(): boolean;
  104734. /**
  104735. * Specifies if the mesh will require alpha blending.
  104736. * @param mesh - BJS mesh.
  104737. */
  104738. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  104739. /**
  104740. * Specifies whether or not this material should be rendered in alpha test mode.
  104741. */
  104742. needAlphaTesting(): boolean;
  104743. /**
  104744. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  104745. */
  104746. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  104747. /**
  104748. * Gets the texture used for the alpha test.
  104749. */
  104750. getAlphaTestTexture(): Nullable<BaseTexture>;
  104751. /**
  104752. * Specifies that the submesh is ready to be used.
  104753. * @param mesh - BJS mesh.
  104754. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  104755. * @param useInstances - Specifies that instances should be used.
  104756. * @returns - boolean indicating that the submesh is ready or not.
  104757. */
  104758. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  104759. /**
  104760. * Specifies if the material uses metallic roughness workflow.
  104761. * @returns boolean specifiying if the material uses metallic roughness workflow.
  104762. */
  104763. isMetallicWorkflow(): boolean;
  104764. private _prepareEffect;
  104765. private _prepareDefines;
  104766. /**
  104767. * Force shader compilation
  104768. */
  104769. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<{
  104770. clipPlane: boolean;
  104771. }>): void;
  104772. /**
  104773. * Initializes the uniform buffer layout for the shader.
  104774. */
  104775. buildUniformLayout(): void;
  104776. /**
  104777. * Unbinds the material from the mesh
  104778. */
  104779. unbind(): void;
  104780. /**
  104781. * Binds the submesh data.
  104782. * @param world - The world matrix.
  104783. * @param mesh - The BJS mesh.
  104784. * @param subMesh - A submesh of the BJS mesh.
  104785. */
  104786. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  104787. /**
  104788. * Returns the animatable textures.
  104789. * @returns - Array of animatable textures.
  104790. */
  104791. getAnimatables(): IAnimatable[];
  104792. /**
  104793. * Returns the texture used for reflections.
  104794. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  104795. */
  104796. private _getReflectionTexture;
  104797. /**
  104798. * Returns an array of the actively used textures.
  104799. * @returns - Array of BaseTextures
  104800. */
  104801. getActiveTextures(): BaseTexture[];
  104802. /**
  104803. * Checks to see if a texture is used in the material.
  104804. * @param texture - Base texture to use.
  104805. * @returns - Boolean specifying if a texture is used in the material.
  104806. */
  104807. hasTexture(texture: BaseTexture): boolean;
  104808. /**
  104809. * Disposes the resources of the material.
  104810. * @param forceDisposeEffect - Forces the disposal of effects.
  104811. * @param forceDisposeTextures - Forces the disposal of all textures.
  104812. */
  104813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  104814. }
  104815. }
  104816. declare module BABYLON {
  104817. /**
  104818. * The Physically based material of BJS.
  104819. *
  104820. * This offers the main features of a standard PBR material.
  104821. * For more information, please refer to the documentation :
  104822. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  104823. */
  104824. export class PBRMaterial extends PBRBaseMaterial {
  104825. /**
  104826. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  104827. */
  104828. static readonly PBRMATERIAL_OPAQUE: number;
  104829. /**
  104830. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  104831. */
  104832. static readonly PBRMATERIAL_ALPHATEST: number;
  104833. /**
  104834. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104835. */
  104836. static readonly PBRMATERIAL_ALPHABLEND: number;
  104837. /**
  104838. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  104839. * They are also discarded below the alpha cutoff threshold to improve performances.
  104840. */
  104841. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  104842. /**
  104843. * Defines the default value of how much AO map is occluding the analytical lights
  104844. * (point spot...).
  104845. */
  104846. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  104847. /**
  104848. * Intensity of the direct lights e.g. the four lights available in your scene.
  104849. * This impacts both the direct diffuse and specular highlights.
  104850. */
  104851. directIntensity: number;
  104852. /**
  104853. * Intensity of the emissive part of the material.
  104854. * This helps controlling the emissive effect without modifying the emissive color.
  104855. */
  104856. emissiveIntensity: number;
  104857. /**
  104858. * Intensity of the environment e.g. how much the environment will light the object
  104859. * either through harmonics for rough material or through the refelction for shiny ones.
  104860. */
  104861. environmentIntensity: number;
  104862. /**
  104863. * This is a special control allowing the reduction of the specular highlights coming from the
  104864. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  104865. */
  104866. specularIntensity: number;
  104867. /**
  104868. * Debug Control allowing disabling the bump map on this material.
  104869. */
  104870. disableBumpMap: boolean;
  104871. /**
  104872. * AKA Diffuse Texture in standard nomenclature.
  104873. */
  104874. albedoTexture: BaseTexture;
  104875. /**
  104876. * AKA Occlusion Texture in other nomenclature.
  104877. */
  104878. ambientTexture: BaseTexture;
  104879. /**
  104880. * AKA Occlusion Texture Intensity in other nomenclature.
  104881. */
  104882. ambientTextureStrength: number;
  104883. /**
  104884. * Defines how much the AO map is occluding the analytical lights (point spot...).
  104885. * 1 means it completely occludes it
  104886. * 0 mean it has no impact
  104887. */
  104888. ambientTextureImpactOnAnalyticalLights: number;
  104889. /**
  104890. * Stores the alpha values in a texture.
  104891. */
  104892. opacityTexture: BaseTexture;
  104893. /**
  104894. * Stores the reflection values in a texture.
  104895. */
  104896. reflectionTexture: Nullable<BaseTexture>;
  104897. /**
  104898. * Stores the emissive values in a texture.
  104899. */
  104900. emissiveTexture: BaseTexture;
  104901. /**
  104902. * AKA Specular texture in other nomenclature.
  104903. */
  104904. reflectivityTexture: BaseTexture;
  104905. /**
  104906. * Used to switch from specular/glossiness to metallic/roughness workflow.
  104907. */
  104908. metallicTexture: BaseTexture;
  104909. /**
  104910. * Specifies the metallic scalar of the metallic/roughness workflow.
  104911. * Can also be used to scale the metalness values of the metallic texture.
  104912. */
  104913. metallic: Nullable<number>;
  104914. /**
  104915. * Specifies the roughness scalar of the metallic/roughness workflow.
  104916. * Can also be used to scale the roughness values of the metallic texture.
  104917. */
  104918. roughness: Nullable<number>;
  104919. /**
  104920. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  104921. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  104922. */
  104923. microSurfaceTexture: BaseTexture;
  104924. /**
  104925. * Stores surface normal data used to displace a mesh in a texture.
  104926. */
  104927. bumpTexture: BaseTexture;
  104928. /**
  104929. * Stores the pre-calculated light information of a mesh in a texture.
  104930. */
  104931. lightmapTexture: BaseTexture;
  104932. /**
  104933. * Stores the refracted light information in a texture.
  104934. */
  104935. refractionTexture: Nullable<BaseTexture>;
  104936. /**
  104937. * The color of a material in ambient lighting.
  104938. */
  104939. ambientColor: Color3;
  104940. /**
  104941. * AKA Diffuse Color in other nomenclature.
  104942. */
  104943. albedoColor: Color3;
  104944. /**
  104945. * AKA Specular Color in other nomenclature.
  104946. */
  104947. reflectivityColor: Color3;
  104948. /**
  104949. * The color reflected from the material.
  104950. */
  104951. reflectionColor: Color3;
  104952. /**
  104953. * The color emitted from the material.
  104954. */
  104955. emissiveColor: Color3;
  104956. /**
  104957. * AKA Glossiness in other nomenclature.
  104958. */
  104959. microSurface: number;
  104960. /**
  104961. * source material index of refraction (IOR)' / 'destination material IOR.
  104962. */
  104963. indexOfRefraction: number;
  104964. /**
  104965. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  104966. */
  104967. invertRefractionY: boolean;
  104968. /**
  104969. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  104970. * Materials half opaque for instance using refraction could benefit from this control.
  104971. */
  104972. linkRefractionWithTransparency: boolean;
  104973. /**
  104974. * If true, the light map contains occlusion information instead of lighting info.
  104975. */
  104976. useLightmapAsShadowmap: boolean;
  104977. /**
  104978. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  104979. */
  104980. useAlphaFromAlbedoTexture: boolean;
  104981. /**
  104982. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  104983. */
  104984. forceAlphaTest: boolean;
  104985. /**
  104986. * Defines the alpha limits in alpha test mode.
  104987. */
  104988. alphaCutOff: number;
  104989. /**
  104990. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  104991. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  104992. */
  104993. useSpecularOverAlpha: boolean;
  104994. /**
  104995. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  104996. */
  104997. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  104998. /**
  104999. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  105000. */
  105001. useRoughnessFromMetallicTextureAlpha: boolean;
  105002. /**
  105003. * Specifies if the metallic texture contains the roughness information in its green channel.
  105004. */
  105005. useRoughnessFromMetallicTextureGreen: boolean;
  105006. /**
  105007. * Specifies if the metallic texture contains the metallness information in its blue channel.
  105008. */
  105009. useMetallnessFromMetallicTextureBlue: boolean;
  105010. /**
  105011. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  105012. */
  105013. useAmbientOcclusionFromMetallicTextureRed: boolean;
  105014. /**
  105015. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  105016. */
  105017. useAmbientInGrayScale: boolean;
  105018. /**
  105019. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  105020. * The material will try to infer what glossiness each pixel should be.
  105021. */
  105022. useAutoMicroSurfaceFromReflectivityMap: boolean;
  105023. /**
  105024. * BJS is using an harcoded light falloff based on a manually sets up range.
  105025. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105026. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105027. */
  105028. /**
  105029. * BJS is using an harcoded light falloff based on a manually sets up range.
  105030. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  105031. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  105032. */
  105033. usePhysicalLightFalloff: boolean;
  105034. /**
  105035. * In order to support the falloff compatibility with gltf, a special mode has been added
  105036. * to reproduce the gltf light falloff.
  105037. */
  105038. /**
  105039. * In order to support the falloff compatibility with gltf, a special mode has been added
  105040. * to reproduce the gltf light falloff.
  105041. */
  105042. useGLTFLightFalloff: boolean;
  105043. /**
  105044. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  105045. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  105046. */
  105047. useRadianceOverAlpha: boolean;
  105048. /**
  105049. * Allows using an object space normal map (instead of tangent space).
  105050. */
  105051. useObjectSpaceNormalMap: boolean;
  105052. /**
  105053. * Allows using the bump map in parallax mode.
  105054. */
  105055. useParallax: boolean;
  105056. /**
  105057. * Allows using the bump map in parallax occlusion mode.
  105058. */
  105059. useParallaxOcclusion: boolean;
  105060. /**
  105061. * Controls the scale bias of the parallax mode.
  105062. */
  105063. parallaxScaleBias: number;
  105064. /**
  105065. * If sets to true, disables all the lights affecting the material.
  105066. */
  105067. disableLighting: boolean;
  105068. /**
  105069. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  105070. */
  105071. forceIrradianceInFragment: boolean;
  105072. /**
  105073. * Number of Simultaneous lights allowed on the material.
  105074. */
  105075. maxSimultaneousLights: number;
  105076. /**
  105077. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  105078. */
  105079. invertNormalMapX: boolean;
  105080. /**
  105081. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  105082. */
  105083. invertNormalMapY: boolean;
  105084. /**
  105085. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  105086. */
  105087. twoSidedLighting: boolean;
  105088. /**
  105089. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105090. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  105091. */
  105092. useAlphaFresnel: boolean;
  105093. /**
  105094. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  105095. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  105096. */
  105097. useLinearAlphaFresnel: boolean;
  105098. /**
  105099. * Let user defines the brdf lookup texture used for IBL.
  105100. * A default 8bit version is embedded but you could point at :
  105101. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.png
  105102. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  105103. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  105104. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  105105. */
  105106. environmentBRDFTexture: Nullable<BaseTexture>;
  105107. /**
  105108. * Force normal to face away from face.
  105109. */
  105110. forceNormalForward: boolean;
  105111. /**
  105112. * Enables specular anti aliasing in the PBR shader.
  105113. * It will both interacts on the Geometry for analytical and IBL lighting.
  105114. * It also prefilter the roughness map based on the bump values.
  105115. */
  105116. enableSpecularAntiAliasing: boolean;
  105117. /**
  105118. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  105119. * makes the reflect vector face the model (under horizon).
  105120. */
  105121. useHorizonOcclusion: boolean;
  105122. /**
  105123. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  105124. * too much the area relying on ambient texture to define their ambient occlusion.
  105125. */
  105126. useRadianceOcclusion: boolean;
  105127. /**
  105128. * If set to true, no lighting calculations will be applied.
  105129. */
  105130. unlit: boolean;
  105131. /**
  105132. * Gets the image processing configuration used either in this material.
  105133. */
  105134. /**
  105135. * Sets the Default image processing configuration used either in the this material.
  105136. *
  105137. * If sets to null, the scene one is in use.
  105138. */
  105139. imageProcessingConfiguration: ImageProcessingConfiguration;
  105140. /**
  105141. * Gets wether the color curves effect is enabled.
  105142. */
  105143. /**
  105144. * Sets wether the color curves effect is enabled.
  105145. */
  105146. cameraColorCurvesEnabled: boolean;
  105147. /**
  105148. * Gets wether the color grading effect is enabled.
  105149. */
  105150. /**
  105151. * Gets wether the color grading effect is enabled.
  105152. */
  105153. cameraColorGradingEnabled: boolean;
  105154. /**
  105155. * Gets wether tonemapping is enabled or not.
  105156. */
  105157. /**
  105158. * Sets wether tonemapping is enabled or not
  105159. */
  105160. cameraToneMappingEnabled: boolean;
  105161. /**
  105162. * The camera exposure used on this material.
  105163. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105164. * This corresponds to a photographic exposure.
  105165. */
  105166. /**
  105167. * The camera exposure used on this material.
  105168. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  105169. * This corresponds to a photographic exposure.
  105170. */
  105171. cameraExposure: number;
  105172. /**
  105173. * Gets The camera contrast used on this material.
  105174. */
  105175. /**
  105176. * Sets The camera contrast used on this material.
  105177. */
  105178. cameraContrast: number;
  105179. /**
  105180. * Gets the Color Grading 2D Lookup Texture.
  105181. */
  105182. /**
  105183. * Sets the Color Grading 2D Lookup Texture.
  105184. */
  105185. cameraColorGradingTexture: Nullable<BaseTexture>;
  105186. /**
  105187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105189. * 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;
  105190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105191. */
  105192. /**
  105193. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  105194. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  105195. * 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;
  105196. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  105197. */
  105198. cameraColorCurves: Nullable<ColorCurves>;
  105199. /**
  105200. * Instantiates a new PBRMaterial instance.
  105201. *
  105202. * @param name The material name
  105203. * @param scene The scene the material will be use in.
  105204. */
  105205. constructor(name: string, scene: Scene);
  105206. /**
  105207. * Returns the name of this material class.
  105208. */
  105209. getClassName(): string;
  105210. /**
  105211. * Makes a duplicate of the current material.
  105212. * @param name - name to use for the new material.
  105213. */
  105214. clone(name: string): PBRMaterial;
  105215. /**
  105216. * Serializes this PBR Material.
  105217. * @returns - An object with the serialized material.
  105218. */
  105219. serialize(): any;
  105220. /**
  105221. * Parses a PBR Material from a serialized object.
  105222. * @param source - Serialized object.
  105223. * @param scene - BJS scene instance.
  105224. * @param rootUrl - url for the scene object
  105225. * @returns - PBRMaterial
  105226. */
  105227. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  105228. }
  105229. }
  105230. declare module BABYLON {
  105231. /**
  105232. * Direct draw surface info
  105233. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  105234. */
  105235. export interface DDSInfo {
  105236. /**
  105237. * Width of the texture
  105238. */
  105239. width: number;
  105240. /**
  105241. * Width of the texture
  105242. */
  105243. height: number;
  105244. /**
  105245. * Number of Mipmaps for the texture
  105246. * @see https://en.wikipedia.org/wiki/Mipmap
  105247. */
  105248. mipmapCount: number;
  105249. /**
  105250. * If the textures format is a known fourCC format
  105251. * @see https://www.fourcc.org/
  105252. */
  105253. isFourCC: boolean;
  105254. /**
  105255. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  105256. */
  105257. isRGB: boolean;
  105258. /**
  105259. * If the texture is a lumincance format
  105260. */
  105261. isLuminance: boolean;
  105262. /**
  105263. * If this is a cube texture
  105264. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  105265. */
  105266. isCube: boolean;
  105267. /**
  105268. * If the texture is a compressed format eg. FOURCC_DXT1
  105269. */
  105270. isCompressed: boolean;
  105271. /**
  105272. * The dxgiFormat of the texture
  105273. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  105274. */
  105275. dxgiFormat: number;
  105276. /**
  105277. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  105278. */
  105279. textureType: number;
  105280. /**
  105281. * Sphericle polynomial created for the dds texture
  105282. */
  105283. sphericalPolynomial?: SphericalPolynomial;
  105284. }
  105285. /**
  105286. * Class used to provide DDS decompression tools
  105287. */
  105288. export class DDSTools {
  105289. /**
  105290. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  105291. */
  105292. static StoreLODInAlphaChannel: boolean;
  105293. /**
  105294. * Gets DDS information from an array buffer
  105295. * @param arrayBuffer defines the array buffer to read data from
  105296. * @returns the DDS information
  105297. */
  105298. static GetDDSInfo(arrayBuffer: any): DDSInfo;
  105299. private static _FloatView;
  105300. private static _Int32View;
  105301. private static _ToHalfFloat;
  105302. private static _FromHalfFloat;
  105303. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  105304. private static _GetHalfFloatRGBAArrayBuffer;
  105305. private static _GetFloatRGBAArrayBuffer;
  105306. private static _GetFloatAsUIntRGBAArrayBuffer;
  105307. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  105308. private static _GetRGBAArrayBuffer;
  105309. private static _ExtractLongWordOrder;
  105310. private static _GetRGBArrayBuffer;
  105311. private static _GetLuminanceArrayBuffer;
  105312. /**
  105313. * Uploads DDS Levels to a Babylon Texture
  105314. * @hidden
  105315. */
  105316. static UploadDDSLevels(engine: Engine, texture: InternalTexture, arrayBuffer: any, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  105317. }
  105318. interface Engine {
  105319. /**
  105320. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  105321. * @param rootUrl defines the url where the file to load is located
  105322. * @param scene defines the current scene
  105323. * @param lodScale defines scale to apply to the mip map selection
  105324. * @param lodOffset defines offset to apply to the mip map selection
  105325. * @param onLoad defines an optional callback raised when the texture is loaded
  105326. * @param onError defines an optional callback raised if there is an issue to load the texture
  105327. * @param format defines the format of the data
  105328. * @param forcedExtension defines the extension to use to pick the right loader
  105329. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  105330. * @returns the cube texture as an InternalTexture
  105331. */
  105332. 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;
  105333. }
  105334. }
  105335. declare module BABYLON {
  105336. /**
  105337. * Implementation of the DDS Texture Loader.
  105338. * @hidden
  105339. */
  105340. export class _DDSTextureLoader implements IInternalTextureLoader {
  105341. /**
  105342. * Defines wether the loader supports cascade loading the different faces.
  105343. */
  105344. readonly supportCascades: boolean;
  105345. /**
  105346. * This returns if the loader support the current file information.
  105347. * @param extension defines the file extension of the file being loaded
  105348. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105349. * @param fallback defines the fallback internal texture if any
  105350. * @param isBase64 defines whether the texture is encoded as a base64
  105351. * @param isBuffer defines whether the texture data are stored as a buffer
  105352. * @returns true if the loader can load the specified file
  105353. */
  105354. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105355. /**
  105356. * Transform the url before loading if required.
  105357. * @param rootUrl the url of the texture
  105358. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105359. * @returns the transformed texture
  105360. */
  105361. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105362. /**
  105363. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105364. * @param rootUrl the url of the texture
  105365. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105366. * @returns the fallback texture
  105367. */
  105368. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105369. /**
  105370. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105371. * @param data contains the texture data
  105372. * @param texture defines the BabylonJS internal texture
  105373. * @param createPolynomials will be true if polynomials have been requested
  105374. * @param onLoad defines the callback to trigger once the texture is ready
  105375. * @param onError defines the callback to trigger in case of error
  105376. */
  105377. loadCubeData(imgs: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105378. /**
  105379. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105380. * @param data contains the texture data
  105381. * @param texture defines the BabylonJS internal texture
  105382. * @param callback defines the method to call once ready to upload
  105383. */
  105384. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105385. }
  105386. }
  105387. declare module BABYLON {
  105388. /** @hidden */
  105389. export var rgbdEncodePixelShader: {
  105390. name: string;
  105391. shader: string;
  105392. };
  105393. }
  105394. declare module BABYLON {
  105395. /**
  105396. * Raw texture data and descriptor sufficient for WebGL texture upload
  105397. */
  105398. export interface EnvironmentTextureInfo {
  105399. /**
  105400. * Version of the environment map
  105401. */
  105402. version: number;
  105403. /**
  105404. * Width of image
  105405. */
  105406. width: number;
  105407. /**
  105408. * Irradiance information stored in the file.
  105409. */
  105410. irradiance: any;
  105411. /**
  105412. * Specular information stored in the file.
  105413. */
  105414. specular: any;
  105415. }
  105416. /**
  105417. * Sets of helpers addressing the serialization and deserialization of environment texture
  105418. * stored in a BabylonJS env file.
  105419. * Those files are usually stored as .env files.
  105420. */
  105421. export class EnvironmentTextureTools {
  105422. /**
  105423. * Magic number identifying the env file.
  105424. */
  105425. private static _MagicBytes;
  105426. /**
  105427. * Gets the environment info from an env file.
  105428. * @param data The array buffer containing the .env bytes.
  105429. * @returns the environment file info (the json header) if successfully parsed.
  105430. */
  105431. static GetEnvInfo(data: ArrayBuffer): Nullable<EnvironmentTextureInfo>;
  105432. /**
  105433. * Creates an environment texture from a loaded cube texture.
  105434. * @param texture defines the cube texture to convert in env file
  105435. * @return a promise containing the environment data if succesfull.
  105436. */
  105437. static CreateEnvTextureAsync(texture: CubeTexture): Promise<ArrayBuffer>;
  105438. /**
  105439. * Creates a JSON representation of the spherical data.
  105440. * @param texture defines the texture containing the polynomials
  105441. * @return the JSON representation of the spherical info
  105442. */
  105443. private static _CreateEnvTextureIrradiance;
  105444. /**
  105445. * Uploads the texture info contained in the env file to the GPU.
  105446. * @param texture defines the internal texture to upload to
  105447. * @param arrayBuffer defines the buffer cotaining the data to load
  105448. * @param info defines the texture info retrieved through the GetEnvInfo method
  105449. * @returns a promise
  105450. */
  105451. static UploadEnvLevelsAsync(texture: InternalTexture, arrayBuffer: any, info: EnvironmentTextureInfo): Promise<void>;
  105452. /**
  105453. * Uploads the levels of image data to the GPU.
  105454. * @param texture defines the internal texture to upload to
  105455. * @param imageData defines the array buffer views of image data [mipmap][face]
  105456. * @returns a promise
  105457. */
  105458. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  105459. /**
  105460. * Uploads spherical polynomials information to the texture.
  105461. * @param texture defines the texture we are trying to upload the information to
  105462. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  105463. */
  105464. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  105465. /** @hidden */
  105466. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  105467. }
  105468. }
  105469. declare module BABYLON {
  105470. /**
  105471. * Implementation of the ENV Texture Loader.
  105472. * @hidden
  105473. */
  105474. export class _ENVTextureLoader implements IInternalTextureLoader {
  105475. /**
  105476. * Defines wether the loader supports cascade loading the different faces.
  105477. */
  105478. readonly supportCascades: boolean;
  105479. /**
  105480. * This returns if the loader support the current file information.
  105481. * @param extension defines the file extension of the file being loaded
  105482. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105483. * @param fallback defines the fallback internal texture if any
  105484. * @param isBase64 defines whether the texture is encoded as a base64
  105485. * @param isBuffer defines whether the texture data are stored as a buffer
  105486. * @returns true if the loader can load the specified file
  105487. */
  105488. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105489. /**
  105490. * Transform the url before loading if required.
  105491. * @param rootUrl the url of the texture
  105492. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105493. * @returns the transformed texture
  105494. */
  105495. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105496. /**
  105497. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105498. * @param rootUrl the url of the texture
  105499. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105500. * @returns the fallback texture
  105501. */
  105502. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105503. /**
  105504. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105505. * @param data contains the texture data
  105506. * @param texture defines the BabylonJS internal texture
  105507. * @param createPolynomials will be true if polynomials have been requested
  105508. * @param onLoad defines the callback to trigger once the texture is ready
  105509. * @param onError defines the callback to trigger in case of error
  105510. */
  105511. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105512. /**
  105513. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105514. * @param data contains the texture data
  105515. * @param texture defines the BabylonJS internal texture
  105516. * @param callback defines the method to call once ready to upload
  105517. */
  105518. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  105519. }
  105520. }
  105521. declare module BABYLON {
  105522. /**
  105523. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  105524. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  105525. */
  105526. export class KhronosTextureContainer {
  105527. /** contents of the KTX container file */
  105528. arrayBuffer: any;
  105529. private static HEADER_LEN;
  105530. private static COMPRESSED_2D;
  105531. private static COMPRESSED_3D;
  105532. private static TEX_2D;
  105533. private static TEX_3D;
  105534. /**
  105535. * Gets the openGL type
  105536. */
  105537. glType: number;
  105538. /**
  105539. * Gets the openGL type size
  105540. */
  105541. glTypeSize: number;
  105542. /**
  105543. * Gets the openGL format
  105544. */
  105545. glFormat: number;
  105546. /**
  105547. * Gets the openGL internal format
  105548. */
  105549. glInternalFormat: number;
  105550. /**
  105551. * Gets the base internal format
  105552. */
  105553. glBaseInternalFormat: number;
  105554. /**
  105555. * Gets image width in pixel
  105556. */
  105557. pixelWidth: number;
  105558. /**
  105559. * Gets image height in pixel
  105560. */
  105561. pixelHeight: number;
  105562. /**
  105563. * Gets image depth in pixels
  105564. */
  105565. pixelDepth: number;
  105566. /**
  105567. * Gets the number of array elements
  105568. */
  105569. numberOfArrayElements: number;
  105570. /**
  105571. * Gets the number of faces
  105572. */
  105573. numberOfFaces: number;
  105574. /**
  105575. * Gets the number of mipmap levels
  105576. */
  105577. numberOfMipmapLevels: number;
  105578. /**
  105579. * Gets the bytes of key value data
  105580. */
  105581. bytesOfKeyValueData: number;
  105582. /**
  105583. * Gets the load type
  105584. */
  105585. loadType: number;
  105586. /**
  105587. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  105588. */
  105589. isInvalid: boolean;
  105590. /**
  105591. * Creates a new KhronosTextureContainer
  105592. * @param arrayBuffer contents of the KTX container file
  105593. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  105594. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  105595. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  105596. */
  105597. constructor(
  105598. /** contents of the KTX container file */
  105599. arrayBuffer: any, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  105600. /**
  105601. * Uploads KTX content to a Babylon Texture.
  105602. * It is assumed that the texture has already been created & is currently bound
  105603. * @hidden
  105604. */
  105605. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  105606. private _upload2DCompressedLevels;
  105607. }
  105608. }
  105609. declare module BABYLON {
  105610. /**
  105611. * Implementation of the KTX Texture Loader.
  105612. * @hidden
  105613. */
  105614. export class _KTXTextureLoader implements IInternalTextureLoader {
  105615. /**
  105616. * Defines wether the loader supports cascade loading the different faces.
  105617. */
  105618. readonly supportCascades: boolean;
  105619. /**
  105620. * This returns if the loader support the current file information.
  105621. * @param extension defines the file extension of the file being loaded
  105622. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105623. * @param fallback defines the fallback internal texture if any
  105624. * @param isBase64 defines whether the texture is encoded as a base64
  105625. * @param isBuffer defines whether the texture data are stored as a buffer
  105626. * @returns true if the loader can load the specified file
  105627. */
  105628. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  105629. /**
  105630. * Transform the url before loading if required.
  105631. * @param rootUrl the url of the texture
  105632. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105633. * @returns the transformed texture
  105634. */
  105635. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  105636. /**
  105637. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  105638. * @param rootUrl the url of the texture
  105639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  105640. * @returns the fallback texture
  105641. */
  105642. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  105643. /**
  105644. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  105645. * @param data contains the texture data
  105646. * @param texture defines the BabylonJS internal texture
  105647. * @param createPolynomials will be true if polynomials have been requested
  105648. * @param onLoad defines the callback to trigger once the texture is ready
  105649. * @param onError defines the callback to trigger in case of error
  105650. */
  105651. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  105652. /**
  105653. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  105654. * @param data contains the texture data
  105655. * @param texture defines the BabylonJS internal texture
  105656. * @param callback defines the method to call once ready to upload
  105657. */
  105658. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  105659. }
  105660. }
  105661. declare module BABYLON {
  105662. /** @hidden */
  105663. export var _forceSceneHelpersToBundle: boolean;
  105664. interface Scene {
  105665. /**
  105666. * Creates a default light for the scene.
  105667. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  105668. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  105669. */
  105670. createDefaultLight(replace?: boolean): void;
  105671. /**
  105672. * Creates a default camera for the scene.
  105673. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  105674. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105675. * @param replace has default false, when true replaces the active camera in the scene
  105676. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  105677. */
  105678. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105679. /**
  105680. * Creates a default camera and a default light.
  105681. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  105682. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  105683. * @param replace has the default false, when true replaces the active camera/light in the scene
  105684. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  105685. */
  105686. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  105687. /**
  105688. * Creates a new sky box
  105689. * @see http://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  105690. * @param environmentTexture defines the texture to use as environment texture
  105691. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  105692. * @param scale defines the overall scale of the skybox
  105693. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  105694. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  105695. * @returns a new mesh holding the sky box
  105696. */
  105697. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  105698. /**
  105699. * Creates a new environment
  105700. * @see http://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  105701. * @param options defines the options you can use to configure the environment
  105702. * @returns the new EnvironmentHelper
  105703. */
  105704. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  105705. /**
  105706. * Creates a new VREXperienceHelper
  105707. * @see http://doc.babylonjs.com/how_to/webvr_helper
  105708. * @param webVROptions defines the options used to create the new VREXperienceHelper
  105709. * @returns a new VREXperienceHelper
  105710. */
  105711. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  105712. /**
  105713. * Creates a new XREXperienceHelper
  105714. * @see http://doc.babylonjs.com/how_to/webxr
  105715. * @returns a promise for a new XREXperienceHelper
  105716. */
  105717. createDefaultXRExperienceAsync(): Promise<WebXRExperienceHelper>;
  105718. }
  105719. }
  105720. declare module BABYLON {
  105721. /**
  105722. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  105723. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  105724. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  105725. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  105726. */
  105727. export class VideoDome extends TransformNode {
  105728. /**
  105729. * Define the video source as a Monoscopic panoramic 360 video.
  105730. */
  105731. static readonly MODE_MONOSCOPIC: number;
  105732. /**
  105733. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105734. */
  105735. static readonly MODE_TOPBOTTOM: number;
  105736. /**
  105737. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105738. */
  105739. static readonly MODE_SIDEBYSIDE: number;
  105740. private _useDirectMapping;
  105741. /**
  105742. * The video texture being displayed on the sphere
  105743. */
  105744. protected _videoTexture: VideoTexture;
  105745. /**
  105746. * Gets the video texture being displayed on the sphere
  105747. */
  105748. readonly videoTexture: VideoTexture;
  105749. /**
  105750. * The skybox material
  105751. */
  105752. protected _material: BackgroundMaterial;
  105753. /**
  105754. * The surface used for the skybox
  105755. */
  105756. protected _mesh: Mesh;
  105757. /**
  105758. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  105759. * Also see the options.resolution property.
  105760. */
  105761. fovMultiplier: number;
  105762. private _videoMode;
  105763. /**
  105764. * Gets or set the current video mode for the video. It can be:
  105765. * * VideoDome.MODE_MONOSCOPIC : Define the video source as a Monoscopic panoramic 360 video.
  105766. * * VideoDome.MODE_TOPBOTTOM : Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  105767. * * VideoDome.MODE_SIDEBYSIDE : Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  105768. */
  105769. videoMode: number;
  105770. /**
  105771. * Oberserver used in Stereoscopic VR Mode.
  105772. */
  105773. private _onBeforeCameraRenderObserver;
  105774. /**
  105775. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  105776. * @param name Element's name, child elements will append suffixes for their own names.
  105777. * @param urlsOrVideo defines the url(s) or the video element to use
  105778. * @param options An object containing optional or exposed sub element properties
  105779. */
  105780. constructor(name: string, urlsOrVideo: string | string[] | HTMLVideoElement, options: {
  105781. resolution?: number;
  105782. clickToPlay?: boolean;
  105783. autoPlay?: boolean;
  105784. loop?: boolean;
  105785. size?: number;
  105786. poster?: string;
  105787. faceForward?: boolean;
  105788. useDirectMapping?: boolean;
  105789. }, scene: Scene);
  105790. private _changeVideoMode;
  105791. /**
  105792. * Releases resources associated with this node.
  105793. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  105794. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  105795. */
  105796. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  105797. }
  105798. }
  105799. declare module BABYLON {
  105800. /**
  105801. * This class can be used to get instrumentation data from a Babylon engine
  105802. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105803. */
  105804. export class EngineInstrumentation implements IDisposable {
  105805. /**
  105806. * Define the instrumented engine.
  105807. */
  105808. engine: Engine;
  105809. private _captureGPUFrameTime;
  105810. private _gpuFrameTimeToken;
  105811. private _gpuFrameTime;
  105812. private _captureShaderCompilationTime;
  105813. private _shaderCompilationTime;
  105814. private _onBeginFrameObserver;
  105815. private _onEndFrameObserver;
  105816. private _onBeforeShaderCompilationObserver;
  105817. private _onAfterShaderCompilationObserver;
  105818. /**
  105819. * Gets the perf counter used for GPU frame time
  105820. */
  105821. readonly gpuFrameTimeCounter: PerfCounter;
  105822. /**
  105823. * Gets the GPU frame time capture status
  105824. */
  105825. /**
  105826. * Enable or disable the GPU frame time capture
  105827. */
  105828. captureGPUFrameTime: boolean;
  105829. /**
  105830. * Gets the perf counter used for shader compilation time
  105831. */
  105832. readonly shaderCompilationTimeCounter: PerfCounter;
  105833. /**
  105834. * Gets the shader compilation time capture status
  105835. */
  105836. /**
  105837. * Enable or disable the shader compilation time capture
  105838. */
  105839. captureShaderCompilationTime: boolean;
  105840. /**
  105841. * Instantiates a new engine instrumentation.
  105842. * This class can be used to get instrumentation data from a Babylon engine
  105843. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  105844. * @param engine Defines the engine to instrument
  105845. */
  105846. constructor(
  105847. /**
  105848. * Define the instrumented engine.
  105849. */
  105850. engine: Engine);
  105851. /**
  105852. * Dispose and release associated resources.
  105853. */
  105854. dispose(): void;
  105855. }
  105856. }
  105857. declare module BABYLON {
  105858. /**
  105859. * This class can be used to get instrumentation data from a Babylon engine
  105860. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  105861. */
  105862. export class SceneInstrumentation implements IDisposable {
  105863. /**
  105864. * Defines the scene to instrument
  105865. */
  105866. scene: Scene;
  105867. private _captureActiveMeshesEvaluationTime;
  105868. private _activeMeshesEvaluationTime;
  105869. private _captureRenderTargetsRenderTime;
  105870. private _renderTargetsRenderTime;
  105871. private _captureFrameTime;
  105872. private _frameTime;
  105873. private _captureRenderTime;
  105874. private _renderTime;
  105875. private _captureInterFrameTime;
  105876. private _interFrameTime;
  105877. private _captureParticlesRenderTime;
  105878. private _particlesRenderTime;
  105879. private _captureSpritesRenderTime;
  105880. private _spritesRenderTime;
  105881. private _capturePhysicsTime;
  105882. private _physicsTime;
  105883. private _captureAnimationsTime;
  105884. private _animationsTime;
  105885. private _captureCameraRenderTime;
  105886. private _cameraRenderTime;
  105887. private _onBeforeActiveMeshesEvaluationObserver;
  105888. private _onAfterActiveMeshesEvaluationObserver;
  105889. private _onBeforeRenderTargetsRenderObserver;
  105890. private _onAfterRenderTargetsRenderObserver;
  105891. private _onAfterRenderObserver;
  105892. private _onBeforeDrawPhaseObserver;
  105893. private _onAfterDrawPhaseObserver;
  105894. private _onBeforeAnimationsObserver;
  105895. private _onBeforeParticlesRenderingObserver;
  105896. private _onAfterParticlesRenderingObserver;
  105897. private _onBeforeSpritesRenderingObserver;
  105898. private _onAfterSpritesRenderingObserver;
  105899. private _onBeforePhysicsObserver;
  105900. private _onAfterPhysicsObserver;
  105901. private _onAfterAnimationsObserver;
  105902. private _onBeforeCameraRenderObserver;
  105903. private _onAfterCameraRenderObserver;
  105904. /**
  105905. * Gets the perf counter used for active meshes evaluation time
  105906. */
  105907. readonly activeMeshesEvaluationTimeCounter: PerfCounter;
  105908. /**
  105909. * Gets the active meshes evaluation time capture status
  105910. */
  105911. /**
  105912. * Enable or disable the active meshes evaluation time capture
  105913. */
  105914. captureActiveMeshesEvaluationTime: boolean;
  105915. /**
  105916. * Gets the perf counter used for render targets render time
  105917. */
  105918. readonly renderTargetsRenderTimeCounter: PerfCounter;
  105919. /**
  105920. * Gets the render targets render time capture status
  105921. */
  105922. /**
  105923. * Enable or disable the render targets render time capture
  105924. */
  105925. captureRenderTargetsRenderTime: boolean;
  105926. /**
  105927. * Gets the perf counter used for particles render time
  105928. */
  105929. readonly particlesRenderTimeCounter: PerfCounter;
  105930. /**
  105931. * Gets the particles render time capture status
  105932. */
  105933. /**
  105934. * Enable or disable the particles render time capture
  105935. */
  105936. captureParticlesRenderTime: boolean;
  105937. /**
  105938. * Gets the perf counter used for sprites render time
  105939. */
  105940. readonly spritesRenderTimeCounter: PerfCounter;
  105941. /**
  105942. * Gets the sprites render time capture status
  105943. */
  105944. /**
  105945. * Enable or disable the sprites render time capture
  105946. */
  105947. captureSpritesRenderTime: boolean;
  105948. /**
  105949. * Gets the perf counter used for physics time
  105950. */
  105951. readonly physicsTimeCounter: PerfCounter;
  105952. /**
  105953. * Gets the physics time capture status
  105954. */
  105955. /**
  105956. * Enable or disable the physics time capture
  105957. */
  105958. capturePhysicsTime: boolean;
  105959. /**
  105960. * Gets the perf counter used for animations time
  105961. */
  105962. readonly animationsTimeCounter: PerfCounter;
  105963. /**
  105964. * Gets the animations time capture status
  105965. */
  105966. /**
  105967. * Enable or disable the animations time capture
  105968. */
  105969. captureAnimationsTime: boolean;
  105970. /**
  105971. * Gets the perf counter used for frame time capture
  105972. */
  105973. readonly frameTimeCounter: PerfCounter;
  105974. /**
  105975. * Gets the frame time capture status
  105976. */
  105977. /**
  105978. * Enable or disable the frame time capture
  105979. */
  105980. captureFrameTime: boolean;
  105981. /**
  105982. * Gets the perf counter used for inter-frames time capture
  105983. */
  105984. readonly interFrameTimeCounter: PerfCounter;
  105985. /**
  105986. * Gets the inter-frames time capture status
  105987. */
  105988. /**
  105989. * Enable or disable the inter-frames time capture
  105990. */
  105991. captureInterFrameTime: boolean;
  105992. /**
  105993. * Gets the perf counter used for render time capture
  105994. */
  105995. readonly renderTimeCounter: PerfCounter;
  105996. /**
  105997. * Gets the render time capture status
  105998. */
  105999. /**
  106000. * Enable or disable the render time capture
  106001. */
  106002. captureRenderTime: boolean;
  106003. /**
  106004. * Gets the perf counter used for camera render time capture
  106005. */
  106006. readonly cameraRenderTimeCounter: PerfCounter;
  106007. /**
  106008. * Gets the camera render time capture status
  106009. */
  106010. /**
  106011. * Enable or disable the camera render time capture
  106012. */
  106013. captureCameraRenderTime: boolean;
  106014. /**
  106015. * Gets the perf counter used for draw calls
  106016. */
  106017. readonly drawCallsCounter: PerfCounter;
  106018. /**
  106019. * Instantiates a new scene instrumentation.
  106020. * This class can be used to get instrumentation data from a Babylon engine
  106021. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  106022. * @param scene Defines the scene to instrument
  106023. */
  106024. constructor(
  106025. /**
  106026. * Defines the scene to instrument
  106027. */
  106028. scene: Scene);
  106029. /**
  106030. * Dispose and release associated resources.
  106031. */
  106032. dispose(): void;
  106033. }
  106034. }
  106035. declare module BABYLON {
  106036. /** @hidden */
  106037. export var glowMapGenerationPixelShader: {
  106038. name: string;
  106039. shader: string;
  106040. };
  106041. }
  106042. declare module BABYLON {
  106043. /** @hidden */
  106044. export var glowMapGenerationVertexShader: {
  106045. name: string;
  106046. shader: string;
  106047. };
  106048. }
  106049. declare module BABYLON {
  106050. /**
  106051. * Effect layer options. This helps customizing the behaviour
  106052. * of the effect layer.
  106053. */
  106054. export interface IEffectLayerOptions {
  106055. /**
  106056. * Multiplication factor apply to the canvas size to compute the render target size
  106057. * used to generated the objects (the smaller the faster).
  106058. */
  106059. mainTextureRatio: number;
  106060. /**
  106061. * Enforces a fixed size texture to ensure effect stability across devices.
  106062. */
  106063. mainTextureFixedSize?: number;
  106064. /**
  106065. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  106066. */
  106067. alphaBlendingMode: number;
  106068. /**
  106069. * The camera attached to the layer.
  106070. */
  106071. camera: Nullable<Camera>;
  106072. /**
  106073. * The rendering group to draw the layer in.
  106074. */
  106075. renderingGroupId: number;
  106076. }
  106077. /**
  106078. * The effect layer Helps adding post process effect blended with the main pass.
  106079. *
  106080. * This can be for instance use to generate glow or higlight effects on the scene.
  106081. *
  106082. * The effect layer class can not be used directly and is intented to inherited from to be
  106083. * customized per effects.
  106084. */
  106085. export abstract class EffectLayer {
  106086. private _vertexBuffers;
  106087. private _indexBuffer;
  106088. private _cachedDefines;
  106089. private _effectLayerMapGenerationEffect;
  106090. private _effectLayerOptions;
  106091. private _mergeEffect;
  106092. protected _scene: Scene;
  106093. protected _engine: Engine;
  106094. protected _maxSize: number;
  106095. protected _mainTextureDesiredSize: ISize;
  106096. protected _mainTexture: RenderTargetTexture;
  106097. protected _shouldRender: boolean;
  106098. protected _postProcesses: PostProcess[];
  106099. protected _textures: BaseTexture[];
  106100. protected _emissiveTextureAndColor: {
  106101. texture: Nullable<BaseTexture>;
  106102. color: Color4;
  106103. };
  106104. /**
  106105. * The name of the layer
  106106. */
  106107. name: string;
  106108. /**
  106109. * The clear color of the texture used to generate the glow map.
  106110. */
  106111. neutralColor: Color4;
  106112. /**
  106113. * Specifies wether the highlight layer is enabled or not.
  106114. */
  106115. isEnabled: boolean;
  106116. /**
  106117. * Gets the camera attached to the layer.
  106118. */
  106119. readonly camera: Nullable<Camera>;
  106120. /**
  106121. * Gets the rendering group id the layer should render in.
  106122. */
  106123. readonly renderingGroupId: number;
  106124. /**
  106125. * An event triggered when the effect layer has been disposed.
  106126. */
  106127. onDisposeObservable: Observable<EffectLayer>;
  106128. /**
  106129. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  106130. */
  106131. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  106132. /**
  106133. * An event triggered when the generated texture is being merged in the scene.
  106134. */
  106135. onBeforeComposeObservable: Observable<EffectLayer>;
  106136. /**
  106137. * An event triggered when the generated texture has been merged in the scene.
  106138. */
  106139. onAfterComposeObservable: Observable<EffectLayer>;
  106140. /**
  106141. * An event triggered when the efffect layer changes its size.
  106142. */
  106143. onSizeChangedObservable: Observable<EffectLayer>;
  106144. /** @hidden */
  106145. static _SceneComponentInitialization: (scene: Scene) => void;
  106146. /**
  106147. * Instantiates a new effect Layer and references it in the scene.
  106148. * @param name The name of the layer
  106149. * @param scene The scene to use the layer in
  106150. */
  106151. constructor(
  106152. /** The Friendly of the effect in the scene */
  106153. name: string, scene: Scene);
  106154. /**
  106155. * Get the effect name of the layer.
  106156. * @return The effect name
  106157. */
  106158. abstract getEffectName(): string;
  106159. /**
  106160. * Checks for the readiness of the element composing the layer.
  106161. * @param subMesh the mesh to check for
  106162. * @param useInstances specify wether or not to use instances to render the mesh
  106163. * @return true if ready otherwise, false
  106164. */
  106165. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106166. /**
  106167. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106168. * @returns true if the effect requires stencil during the main canvas render pass.
  106169. */
  106170. abstract needStencil(): boolean;
  106171. /**
  106172. * Create the merge effect. This is the shader use to blit the information back
  106173. * to the main canvas at the end of the scene rendering.
  106174. * @returns The effect containing the shader used to merge the effect on the main canvas
  106175. */
  106176. protected abstract _createMergeEffect(): Effect;
  106177. /**
  106178. * Creates the render target textures and post processes used in the effect layer.
  106179. */
  106180. protected abstract _createTextureAndPostProcesses(): void;
  106181. /**
  106182. * Implementation specific of rendering the generating effect on the main canvas.
  106183. * @param effect The effect used to render through
  106184. */
  106185. protected abstract _internalRender(effect: Effect): void;
  106186. /**
  106187. * Sets the required values for both the emissive texture and and the main color.
  106188. */
  106189. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106190. /**
  106191. * Free any resources and references associated to a mesh.
  106192. * Internal use
  106193. * @param mesh The mesh to free.
  106194. */
  106195. abstract _disposeMesh(mesh: Mesh): void;
  106196. /**
  106197. * Serializes this layer (Glow or Highlight for example)
  106198. * @returns a serialized layer object
  106199. */
  106200. abstract serialize?(): any;
  106201. /**
  106202. * Initializes the effect layer with the required options.
  106203. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  106204. */
  106205. protected _init(options: Partial<IEffectLayerOptions>): void;
  106206. /**
  106207. * Generates the index buffer of the full screen quad blending to the main canvas.
  106208. */
  106209. private _generateIndexBuffer;
  106210. /**
  106211. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  106212. */
  106213. private _genrateVertexBuffer;
  106214. /**
  106215. * Sets the main texture desired size which is the closest power of two
  106216. * of the engine canvas size.
  106217. */
  106218. private _setMainTextureSize;
  106219. /**
  106220. * Creates the main texture for the effect layer.
  106221. */
  106222. protected _createMainTexture(): void;
  106223. /**
  106224. * Adds specific effects defines.
  106225. * @param defines The defines to add specifics to.
  106226. */
  106227. protected _addCustomEffectDefines(defines: string[]): void;
  106228. /**
  106229. * Checks for the readiness of the element composing the layer.
  106230. * @param subMesh the mesh to check for
  106231. * @param useInstances specify wether or not to use instances to render the mesh
  106232. * @param emissiveTexture the associated emissive texture used to generate the glow
  106233. * @return true if ready otherwise, false
  106234. */
  106235. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  106236. /**
  106237. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  106238. */
  106239. render(): void;
  106240. /**
  106241. * Determine if a given mesh will be used in the current effect.
  106242. * @param mesh mesh to test
  106243. * @returns true if the mesh will be used
  106244. */
  106245. hasMesh(mesh: AbstractMesh): boolean;
  106246. /**
  106247. * Returns true if the layer contains information to display, otherwise false.
  106248. * @returns true if the glow layer should be rendered
  106249. */
  106250. shouldRender(): boolean;
  106251. /**
  106252. * Returns true if the mesh should render, otherwise false.
  106253. * @param mesh The mesh to render
  106254. * @returns true if it should render otherwise false
  106255. */
  106256. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  106257. /**
  106258. * Returns true if the mesh can be rendered, otherwise false.
  106259. * @param mesh The mesh to render
  106260. * @param material The material used on the mesh
  106261. * @returns true if it can be rendered otherwise false
  106262. */
  106263. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106264. /**
  106265. * Returns true if the mesh should render, otherwise false.
  106266. * @param mesh The mesh to render
  106267. * @returns true if it should render otherwise false
  106268. */
  106269. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  106270. /**
  106271. * Renders the submesh passed in parameter to the generation map.
  106272. */
  106273. protected _renderSubMesh(subMesh: SubMesh): void;
  106274. /**
  106275. * Rebuild the required buffers.
  106276. * @hidden Internal use only.
  106277. */
  106278. _rebuild(): void;
  106279. /**
  106280. * Dispose only the render target textures and post process.
  106281. */
  106282. private _disposeTextureAndPostProcesses;
  106283. /**
  106284. * Dispose the highlight layer and free resources.
  106285. */
  106286. dispose(): void;
  106287. /**
  106288. * Gets the class name of the effect layer
  106289. * @returns the string with the class name of the effect layer
  106290. */
  106291. getClassName(): string;
  106292. /**
  106293. * Creates an effect layer from parsed effect layer data
  106294. * @param parsedEffectLayer defines effect layer data
  106295. * @param scene defines the current scene
  106296. * @param rootUrl defines the root URL containing the effect layer information
  106297. * @returns a parsed effect Layer
  106298. */
  106299. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  106300. }
  106301. }
  106302. declare module BABYLON {
  106303. interface AbstractScene {
  106304. /**
  106305. * The list of effect layers (highlights/glow) added to the scene
  106306. * @see http://doc.babylonjs.com/how_to/highlight_layer
  106307. * @see http://doc.babylonjs.com/how_to/glow_layer
  106308. */
  106309. effectLayers: Array<EffectLayer>;
  106310. /**
  106311. * Removes the given effect layer from this scene.
  106312. * @param toRemove defines the effect layer to remove
  106313. * @returns the index of the removed effect layer
  106314. */
  106315. removeEffectLayer(toRemove: EffectLayer): number;
  106316. /**
  106317. * Adds the given effect layer to this scene
  106318. * @param newEffectLayer defines the effect layer to add
  106319. */
  106320. addEffectLayer(newEffectLayer: EffectLayer): void;
  106321. }
  106322. /**
  106323. * Defines the layer scene component responsible to manage any effect layers
  106324. * in a given scene.
  106325. */
  106326. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  106327. /**
  106328. * The component name helpfull to identify the component in the list of scene components.
  106329. */
  106330. readonly name: string;
  106331. /**
  106332. * The scene the component belongs to.
  106333. */
  106334. scene: Scene;
  106335. private _engine;
  106336. private _renderEffects;
  106337. private _needStencil;
  106338. private _previousStencilState;
  106339. /**
  106340. * Creates a new instance of the component for the given scene
  106341. * @param scene Defines the scene to register the component in
  106342. */
  106343. constructor(scene: Scene);
  106344. /**
  106345. * Registers the component in a given scene
  106346. */
  106347. register(): void;
  106348. /**
  106349. * Rebuilds the elements related to this component in case of
  106350. * context lost for instance.
  106351. */
  106352. rebuild(): void;
  106353. /**
  106354. * Serializes the component data to the specified json object
  106355. * @param serializationObject The object to serialize to
  106356. */
  106357. serialize(serializationObject: any): void;
  106358. /**
  106359. * Adds all the element from the container to the scene
  106360. * @param container the container holding the elements
  106361. */
  106362. addFromContainer(container: AbstractScene): void;
  106363. /**
  106364. * Removes all the elements in the container from the scene
  106365. * @param container contains the elements to remove
  106366. * @param dispose if the removed element should be disposed (default: false)
  106367. */
  106368. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  106369. /**
  106370. * Disposes the component and the associated ressources.
  106371. */
  106372. dispose(): void;
  106373. private _isReadyForMesh;
  106374. private _renderMainTexture;
  106375. private _setStencil;
  106376. private _setStencilBack;
  106377. private _draw;
  106378. private _drawCamera;
  106379. private _drawRenderingGroup;
  106380. }
  106381. }
  106382. declare module BABYLON {
  106383. /** @hidden */
  106384. export var glowMapMergePixelShader: {
  106385. name: string;
  106386. shader: string;
  106387. };
  106388. }
  106389. declare module BABYLON {
  106390. /** @hidden */
  106391. export var glowMapMergeVertexShader: {
  106392. name: string;
  106393. shader: string;
  106394. };
  106395. }
  106396. declare module BABYLON {
  106397. interface AbstractScene {
  106398. /**
  106399. * Return a the first highlight layer of the scene with a given name.
  106400. * @param name The name of the highlight layer to look for.
  106401. * @return The highlight layer if found otherwise null.
  106402. */
  106403. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  106404. }
  106405. /**
  106406. * Glow layer options. This helps customizing the behaviour
  106407. * of the glow layer.
  106408. */
  106409. export interface IGlowLayerOptions {
  106410. /**
  106411. * Multiplication factor apply to the canvas size to compute the render target size
  106412. * used to generated the glowing objects (the smaller the faster).
  106413. */
  106414. mainTextureRatio: number;
  106415. /**
  106416. * Enforces a fixed size texture to ensure resize independant blur.
  106417. */
  106418. mainTextureFixedSize?: number;
  106419. /**
  106420. * How big is the kernel of the blur texture.
  106421. */
  106422. blurKernelSize: number;
  106423. /**
  106424. * The camera attached to the layer.
  106425. */
  106426. camera: Nullable<Camera>;
  106427. /**
  106428. * Enable MSAA by chosing the number of samples.
  106429. */
  106430. mainTextureSamples?: number;
  106431. /**
  106432. * The rendering group to draw the layer in.
  106433. */
  106434. renderingGroupId: number;
  106435. }
  106436. /**
  106437. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  106438. *
  106439. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106440. * glowy meshes to your scene.
  106441. *
  106442. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  106443. */
  106444. export class GlowLayer extends EffectLayer {
  106445. /**
  106446. * Effect Name of the layer.
  106447. */
  106448. static readonly EffectName: string;
  106449. /**
  106450. * The default blur kernel size used for the glow.
  106451. */
  106452. static DefaultBlurKernelSize: number;
  106453. /**
  106454. * The default texture size ratio used for the glow.
  106455. */
  106456. static DefaultTextureRatio: number;
  106457. /**
  106458. * Sets the kernel size of the blur.
  106459. */
  106460. /**
  106461. * Gets the kernel size of the blur.
  106462. */
  106463. blurKernelSize: number;
  106464. /**
  106465. * Sets the glow intensity.
  106466. */
  106467. /**
  106468. * Gets the glow intensity.
  106469. */
  106470. intensity: number;
  106471. private _options;
  106472. private _intensity;
  106473. private _horizontalBlurPostprocess1;
  106474. private _verticalBlurPostprocess1;
  106475. private _horizontalBlurPostprocess2;
  106476. private _verticalBlurPostprocess2;
  106477. private _blurTexture1;
  106478. private _blurTexture2;
  106479. private _postProcesses1;
  106480. private _postProcesses2;
  106481. private _includedOnlyMeshes;
  106482. private _excludedMeshes;
  106483. /**
  106484. * Callback used to let the user override the color selection on a per mesh basis
  106485. */
  106486. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  106487. /**
  106488. * Callback used to let the user override the texture selection on a per mesh basis
  106489. */
  106490. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  106491. /**
  106492. * Instantiates a new glow Layer and references it to the scene.
  106493. * @param name The name of the layer
  106494. * @param scene The scene to use the layer in
  106495. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  106496. */
  106497. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  106498. /**
  106499. * Get the effect name of the layer.
  106500. * @return The effect name
  106501. */
  106502. getEffectName(): string;
  106503. /**
  106504. * Create the merge effect. This is the shader use to blit the information back
  106505. * to the main canvas at the end of the scene rendering.
  106506. */
  106507. protected _createMergeEffect(): Effect;
  106508. /**
  106509. * Creates the render target textures and post processes used in the glow layer.
  106510. */
  106511. protected _createTextureAndPostProcesses(): void;
  106512. /**
  106513. * Checks for the readiness of the element composing the layer.
  106514. * @param subMesh the mesh to check for
  106515. * @param useInstances specify wether or not to use instances to render the mesh
  106516. * @param emissiveTexture the associated emissive texture used to generate the glow
  106517. * @return true if ready otherwise, false
  106518. */
  106519. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106520. /**
  106521. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106522. */
  106523. needStencil(): boolean;
  106524. /**
  106525. * Returns true if the mesh can be rendered, otherwise false.
  106526. * @param mesh The mesh to render
  106527. * @param material The material used on the mesh
  106528. * @returns true if it can be rendered otherwise false
  106529. */
  106530. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  106531. /**
  106532. * Implementation specific of rendering the generating effect on the main canvas.
  106533. * @param effect The effect used to render through
  106534. */
  106535. protected _internalRender(effect: Effect): void;
  106536. /**
  106537. * Sets the required values for both the emissive texture and and the main color.
  106538. */
  106539. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106540. /**
  106541. * Returns true if the mesh should render, otherwise false.
  106542. * @param mesh The mesh to render
  106543. * @returns true if it should render otherwise false
  106544. */
  106545. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106546. /**
  106547. * Adds specific effects defines.
  106548. * @param defines The defines to add specifics to.
  106549. */
  106550. protected _addCustomEffectDefines(defines: string[]): void;
  106551. /**
  106552. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  106553. * @param mesh The mesh to exclude from the glow layer
  106554. */
  106555. addExcludedMesh(mesh: Mesh): void;
  106556. /**
  106557. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  106558. * @param mesh The mesh to remove
  106559. */
  106560. removeExcludedMesh(mesh: Mesh): void;
  106561. /**
  106562. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  106563. * @param mesh The mesh to include in the glow layer
  106564. */
  106565. addIncludedOnlyMesh(mesh: Mesh): void;
  106566. /**
  106567. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  106568. * @param mesh The mesh to remove
  106569. */
  106570. removeIncludedOnlyMesh(mesh: Mesh): void;
  106571. /**
  106572. * Determine if a given mesh will be used in the glow layer
  106573. * @param mesh The mesh to test
  106574. * @returns true if the mesh will be highlighted by the current glow layer
  106575. */
  106576. hasMesh(mesh: AbstractMesh): boolean;
  106577. /**
  106578. * Free any resources and references associated to a mesh.
  106579. * Internal use
  106580. * @param mesh The mesh to free.
  106581. * @hidden
  106582. */
  106583. _disposeMesh(mesh: Mesh): void;
  106584. /**
  106585. * Gets the class name of the effect layer
  106586. * @returns the string with the class name of the effect layer
  106587. */
  106588. getClassName(): string;
  106589. /**
  106590. * Serializes this glow layer
  106591. * @returns a serialized glow layer object
  106592. */
  106593. serialize(): any;
  106594. /**
  106595. * Creates a Glow Layer from parsed glow layer data
  106596. * @param parsedGlowLayer defines glow layer data
  106597. * @param scene defines the current scene
  106598. * @param rootUrl defines the root URL containing the glow layer information
  106599. * @returns a parsed Glow Layer
  106600. */
  106601. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  106602. }
  106603. }
  106604. declare module BABYLON {
  106605. /** @hidden */
  106606. export var glowBlurPostProcessPixelShader: {
  106607. name: string;
  106608. shader: string;
  106609. };
  106610. }
  106611. declare module BABYLON {
  106612. interface AbstractScene {
  106613. /**
  106614. * Return a the first highlight layer of the scene with a given name.
  106615. * @param name The name of the highlight layer to look for.
  106616. * @return The highlight layer if found otherwise null.
  106617. */
  106618. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  106619. }
  106620. /**
  106621. * Highlight layer options. This helps customizing the behaviour
  106622. * of the highlight layer.
  106623. */
  106624. export interface IHighlightLayerOptions {
  106625. /**
  106626. * Multiplication factor apply to the canvas size to compute the render target size
  106627. * used to generated the glowing objects (the smaller the faster).
  106628. */
  106629. mainTextureRatio: number;
  106630. /**
  106631. * Enforces a fixed size texture to ensure resize independant blur.
  106632. */
  106633. mainTextureFixedSize?: number;
  106634. /**
  106635. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  106636. * of the picture to blur (the smaller the faster).
  106637. */
  106638. blurTextureSizeRatio: number;
  106639. /**
  106640. * How big in texel of the blur texture is the vertical blur.
  106641. */
  106642. blurVerticalSize: number;
  106643. /**
  106644. * How big in texel of the blur texture is the horizontal blur.
  106645. */
  106646. blurHorizontalSize: number;
  106647. /**
  106648. * Alpha blending mode used to apply the blur. Default is combine.
  106649. */
  106650. alphaBlendingMode: number;
  106651. /**
  106652. * The camera attached to the layer.
  106653. */
  106654. camera: Nullable<Camera>;
  106655. /**
  106656. * Should we display highlight as a solid stroke?
  106657. */
  106658. isStroke?: boolean;
  106659. /**
  106660. * The rendering group to draw the layer in.
  106661. */
  106662. renderingGroupId: number;
  106663. }
  106664. /**
  106665. * The highlight layer Helps adding a glow effect around a mesh.
  106666. *
  106667. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  106668. * glowy meshes to your scene.
  106669. *
  106670. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  106671. */
  106672. export class HighlightLayer extends EffectLayer {
  106673. name: string;
  106674. /**
  106675. * Effect Name of the highlight layer.
  106676. */
  106677. static readonly EffectName: string;
  106678. /**
  106679. * The neutral color used during the preparation of the glow effect.
  106680. * This is black by default as the blend operation is a blend operation.
  106681. */
  106682. static NeutralColor: Color4;
  106683. /**
  106684. * Stencil value used for glowing meshes.
  106685. */
  106686. static GlowingMeshStencilReference: number;
  106687. /**
  106688. * Stencil value used for the other meshes in the scene.
  106689. */
  106690. static NormalMeshStencilReference: number;
  106691. /**
  106692. * Specifies whether or not the inner glow is ACTIVE in the layer.
  106693. */
  106694. innerGlow: boolean;
  106695. /**
  106696. * Specifies whether or not the outer glow is ACTIVE in the layer.
  106697. */
  106698. outerGlow: boolean;
  106699. /**
  106700. * Specifies the horizontal size of the blur.
  106701. */
  106702. /**
  106703. * Gets the horizontal size of the blur.
  106704. */
  106705. blurHorizontalSize: number;
  106706. /**
  106707. * Specifies the vertical size of the blur.
  106708. */
  106709. /**
  106710. * Gets the vertical size of the blur.
  106711. */
  106712. blurVerticalSize: number;
  106713. /**
  106714. * An event triggered when the highlight layer is being blurred.
  106715. */
  106716. onBeforeBlurObservable: Observable<HighlightLayer>;
  106717. /**
  106718. * An event triggered when the highlight layer has been blurred.
  106719. */
  106720. onAfterBlurObservable: Observable<HighlightLayer>;
  106721. private _instanceGlowingMeshStencilReference;
  106722. private _options;
  106723. private _downSamplePostprocess;
  106724. private _horizontalBlurPostprocess;
  106725. private _verticalBlurPostprocess;
  106726. private _blurTexture;
  106727. private _meshes;
  106728. private _excludedMeshes;
  106729. /**
  106730. * Instantiates a new highlight Layer and references it to the scene..
  106731. * @param name The name of the layer
  106732. * @param scene The scene to use the layer in
  106733. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  106734. */
  106735. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  106736. /**
  106737. * Get the effect name of the layer.
  106738. * @return The effect name
  106739. */
  106740. getEffectName(): string;
  106741. /**
  106742. * Create the merge effect. This is the shader use to blit the information back
  106743. * to the main canvas at the end of the scene rendering.
  106744. */
  106745. protected _createMergeEffect(): Effect;
  106746. /**
  106747. * Creates the render target textures and post processes used in the highlight layer.
  106748. */
  106749. protected _createTextureAndPostProcesses(): void;
  106750. /**
  106751. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  106752. */
  106753. needStencil(): boolean;
  106754. /**
  106755. * Checks for the readiness of the element composing the layer.
  106756. * @param subMesh the mesh to check for
  106757. * @param useInstances specify wether or not to use instances to render the mesh
  106758. * @param emissiveTexture the associated emissive texture used to generate the glow
  106759. * @return true if ready otherwise, false
  106760. */
  106761. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  106762. /**
  106763. * Implementation specific of rendering the generating effect on the main canvas.
  106764. * @param effect The effect used to render through
  106765. */
  106766. protected _internalRender(effect: Effect): void;
  106767. /**
  106768. * Returns true if the layer contains information to display, otherwise false.
  106769. */
  106770. shouldRender(): boolean;
  106771. /**
  106772. * Returns true if the mesh should render, otherwise false.
  106773. * @param mesh The mesh to render
  106774. * @returns true if it should render otherwise false
  106775. */
  106776. protected _shouldRenderMesh(mesh: Mesh): boolean;
  106777. /**
  106778. * Sets the required values for both the emissive texture and and the main color.
  106779. */
  106780. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  106781. /**
  106782. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  106783. * @param mesh The mesh to exclude from the highlight layer
  106784. */
  106785. addExcludedMesh(mesh: Mesh): void;
  106786. /**
  106787. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  106788. * @param mesh The mesh to highlight
  106789. */
  106790. removeExcludedMesh(mesh: Mesh): void;
  106791. /**
  106792. * Determine if a given mesh will be highlighted by the current HighlightLayer
  106793. * @param mesh mesh to test
  106794. * @returns true if the mesh will be highlighted by the current HighlightLayer
  106795. */
  106796. hasMesh(mesh: AbstractMesh): boolean;
  106797. /**
  106798. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  106799. * @param mesh The mesh to highlight
  106800. * @param color The color of the highlight
  106801. * @param glowEmissiveOnly Extract the glow from the emissive texture
  106802. */
  106803. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  106804. /**
  106805. * Remove a mesh from the highlight layer in order to make it stop glowing.
  106806. * @param mesh The mesh to highlight
  106807. */
  106808. removeMesh(mesh: Mesh): void;
  106809. /**
  106810. * Force the stencil to the normal expected value for none glowing parts
  106811. */
  106812. private _defaultStencilReference;
  106813. /**
  106814. * Free any resources and references associated to a mesh.
  106815. * Internal use
  106816. * @param mesh The mesh to free.
  106817. * @hidden
  106818. */
  106819. _disposeMesh(mesh: Mesh): void;
  106820. /**
  106821. * Dispose the highlight layer and free resources.
  106822. */
  106823. dispose(): void;
  106824. /**
  106825. * Gets the class name of the effect layer
  106826. * @returns the string with the class name of the effect layer
  106827. */
  106828. getClassName(): string;
  106829. /**
  106830. * Serializes this Highlight layer
  106831. * @returns a serialized Highlight layer object
  106832. */
  106833. serialize(): any;
  106834. /**
  106835. * Creates a Highlight layer from parsed Highlight layer data
  106836. * @param parsedHightlightLayer defines the Highlight layer data
  106837. * @param scene defines the current scene
  106838. * @param rootUrl defines the root URL containing the Highlight layer information
  106839. * @returns a parsed Highlight layer
  106840. */
  106841. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  106842. }
  106843. }
  106844. declare module BABYLON {
  106845. /** @hidden */
  106846. export var lensFlarePixelShader: {
  106847. name: string;
  106848. shader: string;
  106849. };
  106850. }
  106851. declare module BABYLON {
  106852. /** @hidden */
  106853. export var lensFlareVertexShader: {
  106854. name: string;
  106855. shader: string;
  106856. };
  106857. }
  106858. declare module BABYLON {
  106859. /**
  106860. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106861. * It is usually composed of several `lensFlare`.
  106862. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106863. */
  106864. export class LensFlareSystem {
  106865. /**
  106866. * Define the name of the lens flare system
  106867. */
  106868. name: string;
  106869. /**
  106870. * List of lens flares used in this system.
  106871. */
  106872. lensFlares: LensFlare[];
  106873. /**
  106874. * Define a limit from the border the lens flare can be visible.
  106875. */
  106876. borderLimit: number;
  106877. /**
  106878. * Define a viewport border we do not want to see the lens flare in.
  106879. */
  106880. viewportBorder: number;
  106881. /**
  106882. * Define a predicate which could limit the list of meshes able to occlude the effect.
  106883. */
  106884. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  106885. /**
  106886. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  106887. */
  106888. layerMask: number;
  106889. /**
  106890. * Define the id of the lens flare system in the scene.
  106891. * (equal to name by default)
  106892. */
  106893. id: string;
  106894. private _scene;
  106895. private _emitter;
  106896. private _vertexBuffers;
  106897. private _indexBuffer;
  106898. private _effect;
  106899. private _positionX;
  106900. private _positionY;
  106901. private _isEnabled;
  106902. /** @hidden */
  106903. static _SceneComponentInitialization: (scene: Scene) => void;
  106904. /**
  106905. * Instantiates a lens flare system.
  106906. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  106907. * It is usually composed of several `lensFlare`.
  106908. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106909. * @param name Define the name of the lens flare system in the scene
  106910. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  106911. * @param scene Define the scene the lens flare system belongs to
  106912. */
  106913. constructor(
  106914. /**
  106915. * Define the name of the lens flare system
  106916. */
  106917. name: string, emitter: any, scene: Scene);
  106918. /**
  106919. * Define if the lens flare system is enabled.
  106920. */
  106921. isEnabled: boolean;
  106922. /**
  106923. * Get the scene the effects belongs to.
  106924. * @returns the scene holding the lens flare system
  106925. */
  106926. getScene(): Scene;
  106927. /**
  106928. * Get the emitter of the lens flare system.
  106929. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106930. * @returns the emitter of the lens flare system
  106931. */
  106932. getEmitter(): any;
  106933. /**
  106934. * Set the emitter of the lens flare system.
  106935. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  106936. * @param newEmitter Define the new emitter of the system
  106937. */
  106938. setEmitter(newEmitter: any): void;
  106939. /**
  106940. * Get the lens flare system emitter position.
  106941. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  106942. * @returns the position
  106943. */
  106944. getEmitterPosition(): Vector3;
  106945. /**
  106946. * @hidden
  106947. */
  106948. computeEffectivePosition(globalViewport: Viewport): boolean;
  106949. /** @hidden */
  106950. _isVisible(): boolean;
  106951. /**
  106952. * @hidden
  106953. */
  106954. render(): boolean;
  106955. /**
  106956. * Dispose and release the lens flare with its associated resources.
  106957. */
  106958. dispose(): void;
  106959. /**
  106960. * Parse a lens flare system from a JSON repressentation
  106961. * @param parsedLensFlareSystem Define the JSON to parse
  106962. * @param scene Define the scene the parsed system should be instantiated in
  106963. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  106964. * @returns the parsed system
  106965. */
  106966. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  106967. /**
  106968. * Serialize the current Lens Flare System into a JSON representation.
  106969. * @returns the serialized JSON
  106970. */
  106971. serialize(): any;
  106972. }
  106973. }
  106974. declare module BABYLON {
  106975. /**
  106976. * This represents one of the lens effect in a `lensFlareSystem`.
  106977. * It controls one of the indiviual texture used in the effect.
  106978. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  106979. */
  106980. export class LensFlare {
  106981. /**
  106982. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  106983. */
  106984. size: number;
  106985. /**
  106986. * 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.
  106987. */
  106988. position: number;
  106989. /**
  106990. * Define the lens color.
  106991. */
  106992. color: Color3;
  106993. /**
  106994. * Define the lens texture.
  106995. */
  106996. texture: Nullable<Texture>;
  106997. /**
  106998. * Define the alpha mode to render this particular lens.
  106999. */
  107000. alphaMode: number;
  107001. private _system;
  107002. /**
  107003. * Creates a new Lens Flare.
  107004. * This represents one of the lens effect in a `lensFlareSystem`.
  107005. * It controls one of the indiviual texture used in the effect.
  107006. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107007. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  107008. * @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.
  107009. * @param color Define the lens color
  107010. * @param imgUrl Define the lens texture url
  107011. * @param system Define the `lensFlareSystem` this flare is part of
  107012. * @returns The newly created Lens Flare
  107013. */
  107014. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  107015. /**
  107016. * Instantiates a new Lens Flare.
  107017. * This represents one of the lens effect in a `lensFlareSystem`.
  107018. * It controls one of the indiviual texture used in the effect.
  107019. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107020. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  107021. * @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.
  107022. * @param color Define the lens color
  107023. * @param imgUrl Define the lens texture url
  107024. * @param system Define the `lensFlareSystem` this flare is part of
  107025. */
  107026. constructor(
  107027. /**
  107028. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  107029. */
  107030. size: number,
  107031. /**
  107032. * 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.
  107033. */
  107034. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  107035. /**
  107036. * Dispose and release the lens flare with its associated resources.
  107037. */
  107038. dispose(): void;
  107039. }
  107040. }
  107041. declare module BABYLON {
  107042. interface AbstractScene {
  107043. /**
  107044. * The list of lens flare system added to the scene
  107045. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  107046. */
  107047. lensFlareSystems: Array<LensFlareSystem>;
  107048. /**
  107049. * Removes the given lens flare system from this scene.
  107050. * @param toRemove The lens flare system to remove
  107051. * @returns The index of the removed lens flare system
  107052. */
  107053. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  107054. /**
  107055. * Adds the given lens flare system to this scene
  107056. * @param newLensFlareSystem The lens flare system to add
  107057. */
  107058. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  107059. /**
  107060. * Gets a lens flare system using its name
  107061. * @param name defines the name to look for
  107062. * @returns the lens flare system or null if not found
  107063. */
  107064. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  107065. /**
  107066. * Gets a lens flare system using its id
  107067. * @param id defines the id to look for
  107068. * @returns the lens flare system or null if not found
  107069. */
  107070. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  107071. }
  107072. /**
  107073. * Defines the lens flare scene component responsible to manage any lens flares
  107074. * in a given scene.
  107075. */
  107076. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  107077. /**
  107078. * The component name helpfull to identify the component in the list of scene components.
  107079. */
  107080. readonly name: string;
  107081. /**
  107082. * The scene the component belongs to.
  107083. */
  107084. scene: Scene;
  107085. /**
  107086. * Creates a new instance of the component for the given scene
  107087. * @param scene Defines the scene to register the component in
  107088. */
  107089. constructor(scene: Scene);
  107090. /**
  107091. * Registers the component in a given scene
  107092. */
  107093. register(): void;
  107094. /**
  107095. * Rebuilds the elements related to this component in case of
  107096. * context lost for instance.
  107097. */
  107098. rebuild(): void;
  107099. /**
  107100. * Adds all the element from the container to the scene
  107101. * @param container the container holding the elements
  107102. */
  107103. addFromContainer(container: AbstractScene): void;
  107104. /**
  107105. * Removes all the elements in the container from the scene
  107106. * @param container contains the elements to remove
  107107. * @param dispose if the removed element should be disposed (default: false)
  107108. */
  107109. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107110. /**
  107111. * Serializes the component data to the specified json object
  107112. * @param serializationObject The object to serialize to
  107113. */
  107114. serialize(serializationObject: any): void;
  107115. /**
  107116. * Disposes the component and the associated ressources.
  107117. */
  107118. dispose(): void;
  107119. private _draw;
  107120. }
  107121. }
  107122. declare module BABYLON {
  107123. /**
  107124. * Defines the shadow generator component responsible to manage any shadow generators
  107125. * in a given scene.
  107126. */
  107127. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  107128. /**
  107129. * The component name helpfull to identify the component in the list of scene components.
  107130. */
  107131. readonly name: string;
  107132. /**
  107133. * The scene the component belongs to.
  107134. */
  107135. scene: Scene;
  107136. /**
  107137. * Creates a new instance of the component for the given scene
  107138. * @param scene Defines the scene to register the component in
  107139. */
  107140. constructor(scene: Scene);
  107141. /**
  107142. * Registers the component in a given scene
  107143. */
  107144. register(): void;
  107145. /**
  107146. * Rebuilds the elements related to this component in case of
  107147. * context lost for instance.
  107148. */
  107149. rebuild(): void;
  107150. /**
  107151. * Serializes the component data to the specified json object
  107152. * @param serializationObject The object to serialize to
  107153. */
  107154. serialize(serializationObject: any): void;
  107155. /**
  107156. * Adds all the element from the container to the scene
  107157. * @param container the container holding the elements
  107158. */
  107159. addFromContainer(container: AbstractScene): void;
  107160. /**
  107161. * Removes all the elements in the container from the scene
  107162. * @param container contains the elements to remove
  107163. * @param dispose if the removed element should be disposed (default: false)
  107164. */
  107165. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  107166. /**
  107167. * Rebuilds the elements related to this component in case of
  107168. * context lost for instance.
  107169. */
  107170. dispose(): void;
  107171. private _gatherRenderTargets;
  107172. }
  107173. }
  107174. declare module BABYLON {
  107175. /**
  107176. * A point light is a light defined by an unique point in world space.
  107177. * The light is emitted in every direction from this point.
  107178. * A good example of a point light is a standard light bulb.
  107179. * Documentation: https://doc.babylonjs.com/babylon101/lights
  107180. */
  107181. export class PointLight extends ShadowLight {
  107182. private _shadowAngle;
  107183. /**
  107184. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107185. * This specifies what angle the shadow will use to be created.
  107186. *
  107187. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107188. */
  107189. /**
  107190. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107191. * This specifies what angle the shadow will use to be created.
  107192. *
  107193. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  107194. */
  107195. shadowAngle: number;
  107196. /**
  107197. * Gets the direction if it has been set.
  107198. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107199. */
  107200. /**
  107201. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  107202. */
  107203. direction: Vector3;
  107204. /**
  107205. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  107206. * A PointLight emits the light in every direction.
  107207. * It can cast shadows.
  107208. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  107209. * ```javascript
  107210. * var pointLight = new PointLight("pl", camera.position, scene);
  107211. * ```
  107212. * Documentation : https://doc.babylonjs.com/babylon101/lights
  107213. * @param name The light friendly name
  107214. * @param position The position of the point light in the scene
  107215. * @param scene The scene the lights belongs to
  107216. */
  107217. constructor(name: string, position: Vector3, scene: Scene);
  107218. /**
  107219. * Returns the string "PointLight"
  107220. * @returns the class name
  107221. */
  107222. getClassName(): string;
  107223. /**
  107224. * Returns the integer 0.
  107225. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  107226. */
  107227. getTypeID(): number;
  107228. /**
  107229. * Specifies wether or not the shadowmap should be a cube texture.
  107230. * @returns true if the shadowmap needs to be a cube texture.
  107231. */
  107232. needCube(): boolean;
  107233. /**
  107234. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  107235. * @param faceIndex The index of the face we are computed the direction to generate shadow
  107236. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  107237. */
  107238. getShadowDirection(faceIndex?: number): Vector3;
  107239. /**
  107240. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  107241. * - fov = PI / 2
  107242. * - aspect ratio : 1.0
  107243. * - z-near and far equal to the active camera minZ and maxZ.
  107244. * Returns the PointLight.
  107245. */
  107246. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  107247. protected _buildUniformLayout(): void;
  107248. /**
  107249. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  107250. * @param effect The effect to update
  107251. * @param lightIndex The index of the light in the effect to update
  107252. * @returns The point light
  107253. */
  107254. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  107255. /**
  107256. * Prepares the list of defines specific to the light type.
  107257. * @param defines the list of defines
  107258. * @param lightIndex defines the index of the light for the effect
  107259. */
  107260. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  107261. }
  107262. }
  107263. declare module BABYLON {
  107264. /**
  107265. * Header information of HDR texture files.
  107266. */
  107267. export interface HDRInfo {
  107268. /**
  107269. * The height of the texture in pixels.
  107270. */
  107271. height: number;
  107272. /**
  107273. * The width of the texture in pixels.
  107274. */
  107275. width: number;
  107276. /**
  107277. * The index of the beginning of the data in the binary file.
  107278. */
  107279. dataPosition: number;
  107280. }
  107281. /**
  107282. * This groups tools to convert HDR texture to native colors array.
  107283. */
  107284. export class HDRTools {
  107285. private static Ldexp;
  107286. private static Rgbe2float;
  107287. private static readStringLine;
  107288. /**
  107289. * Reads header information from an RGBE texture stored in a native array.
  107290. * More information on this format are available here:
  107291. * https://en.wikipedia.org/wiki/RGBE_image_format
  107292. *
  107293. * @param uint8array The binary file stored in native array.
  107294. * @return The header information.
  107295. */
  107296. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  107297. /**
  107298. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  107299. * This RGBE texture needs to store the information as a panorama.
  107300. *
  107301. * More information on this format are available here:
  107302. * https://en.wikipedia.org/wiki/RGBE_image_format
  107303. *
  107304. * @param buffer The binary file stored in an array buffer.
  107305. * @param size The expected size of the extracted cubemap.
  107306. * @return The Cube Map information.
  107307. */
  107308. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  107309. /**
  107310. * Returns the pixels data extracted from an RGBE texture.
  107311. * This pixels will be stored left to right up to down in the R G B order in one array.
  107312. *
  107313. * More information on this format are available here:
  107314. * https://en.wikipedia.org/wiki/RGBE_image_format
  107315. *
  107316. * @param uint8array The binary file stored in an array buffer.
  107317. * @param hdrInfo The header information of the file.
  107318. * @return The pixels data in RGB right to left up to down order.
  107319. */
  107320. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  107321. private static RGBE_ReadPixels_RLE;
  107322. }
  107323. }
  107324. declare module BABYLON {
  107325. /**
  107326. * This represents a texture coming from an HDR input.
  107327. *
  107328. * The only supported format is currently panorama picture stored in RGBE format.
  107329. * Example of such files can be found on HDRLib: http://hdrlib.com/
  107330. */
  107331. export class HDRCubeTexture extends BaseTexture {
  107332. private static _facesMapping;
  107333. private _generateHarmonics;
  107334. private _noMipmap;
  107335. private _textureMatrix;
  107336. private _size;
  107337. private _onLoad;
  107338. private _onError;
  107339. /**
  107340. * The texture URL.
  107341. */
  107342. url: string;
  107343. /**
  107344. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  107345. */
  107346. coordinatesMode: number;
  107347. protected _isBlocking: boolean;
  107348. /**
  107349. * Sets wether or not the texture is blocking during loading.
  107350. */
  107351. /**
  107352. * Gets wether or not the texture is blocking during loading.
  107353. */
  107354. isBlocking: boolean;
  107355. protected _rotationY: number;
  107356. /**
  107357. * Sets texture matrix rotation angle around Y axis in radians.
  107358. */
  107359. /**
  107360. * Gets texture matrix rotation angle around Y axis radians.
  107361. */
  107362. rotationY: number;
  107363. /**
  107364. * Gets or sets the center of the bounding box associated with the cube texture
  107365. * It must define where the camera used to render the texture was set
  107366. */
  107367. boundingBoxPosition: Vector3;
  107368. private _boundingBoxSize;
  107369. /**
  107370. * Gets or sets the size of the bounding box associated with the cube texture
  107371. * When defined, the cubemap will switch to local mode
  107372. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  107373. * @example https://www.babylonjs-playground.com/#RNASML
  107374. */
  107375. boundingBoxSize: Vector3;
  107376. /**
  107377. * Instantiates an HDRTexture from the following parameters.
  107378. *
  107379. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  107380. * @param scene The scene the texture will be used in
  107381. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  107382. * @param noMipmap Forces to not generate the mipmap if true
  107383. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  107384. * @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)
  107385. * @param reserved Reserved flag for internal use.
  107386. */
  107387. 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>);
  107388. /**
  107389. * Get the current class name of the texture useful for serialization or dynamic coding.
  107390. * @returns "HDRCubeTexture"
  107391. */
  107392. getClassName(): string;
  107393. /**
  107394. * Occurs when the file is raw .hdr file.
  107395. */
  107396. private loadTexture;
  107397. clone(): HDRCubeTexture;
  107398. delayLoad(): void;
  107399. /**
  107400. * Get the texture reflection matrix used to rotate/transform the reflection.
  107401. * @returns the reflection matrix
  107402. */
  107403. getReflectionTextureMatrix(): Matrix;
  107404. /**
  107405. * Set the texture reflection matrix used to rotate/transform the reflection.
  107406. * @param value Define the reflection matrix to set
  107407. */
  107408. setReflectionTextureMatrix(value: Matrix): void;
  107409. /**
  107410. * Parses a JSON representation of an HDR Texture in order to create the texture
  107411. * @param parsedTexture Define the JSON representation
  107412. * @param scene Define the scene the texture should be created in
  107413. * @param rootUrl Define the root url in case we need to load relative dependencies
  107414. * @returns the newly created texture after parsing
  107415. */
  107416. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  107417. serialize(): any;
  107418. }
  107419. }
  107420. declare module BABYLON {
  107421. /**
  107422. * Class used to control physics engine
  107423. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  107424. */
  107425. export class PhysicsEngine implements IPhysicsEngine {
  107426. private _physicsPlugin;
  107427. /**
  107428. * Global value used to control the smallest number supported by the simulation
  107429. */
  107430. static Epsilon: number;
  107431. private _impostors;
  107432. private _joints;
  107433. /**
  107434. * Gets the gravity vector used by the simulation
  107435. */
  107436. gravity: Vector3;
  107437. /**
  107438. * Factory used to create the default physics plugin.
  107439. * @returns The default physics plugin
  107440. */
  107441. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  107442. /**
  107443. * Creates a new Physics Engine
  107444. * @param gravity defines the gravity vector used by the simulation
  107445. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  107446. */
  107447. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  107448. /**
  107449. * Sets the gravity vector used by the simulation
  107450. * @param gravity defines the gravity vector to use
  107451. */
  107452. setGravity(gravity: Vector3): void;
  107453. /**
  107454. * Set the time step of the physics engine.
  107455. * Default is 1/60.
  107456. * To slow it down, enter 1/600 for example.
  107457. * To speed it up, 1/30
  107458. * @param newTimeStep defines the new timestep to apply to this world.
  107459. */
  107460. setTimeStep(newTimeStep?: number): void;
  107461. /**
  107462. * Get the time step of the physics engine.
  107463. * @returns the current time step
  107464. */
  107465. getTimeStep(): number;
  107466. /**
  107467. * Release all resources
  107468. */
  107469. dispose(): void;
  107470. /**
  107471. * Gets the name of the current physics plugin
  107472. * @returns the name of the plugin
  107473. */
  107474. getPhysicsPluginName(): string;
  107475. /**
  107476. * Adding a new impostor for the impostor tracking.
  107477. * This will be done by the impostor itself.
  107478. * @param impostor the impostor to add
  107479. */
  107480. addImpostor(impostor: PhysicsImpostor): void;
  107481. /**
  107482. * Remove an impostor from the engine.
  107483. * This impostor and its mesh will not longer be updated by the physics engine.
  107484. * @param impostor the impostor to remove
  107485. */
  107486. removeImpostor(impostor: PhysicsImpostor): void;
  107487. /**
  107488. * Add a joint to the physics engine
  107489. * @param mainImpostor defines the main impostor to which the joint is added.
  107490. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  107491. * @param joint defines the joint that will connect both impostors.
  107492. */
  107493. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107494. /**
  107495. * Removes a joint from the simulation
  107496. * @param mainImpostor defines the impostor used with the joint
  107497. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  107498. * @param joint defines the joint to remove
  107499. */
  107500. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  107501. /**
  107502. * Called by the scene. No need to call it.
  107503. * @param delta defines the timespam between frames
  107504. */
  107505. _step(delta: number): void;
  107506. /**
  107507. * Gets the current plugin used to run the simulation
  107508. * @returns current plugin
  107509. */
  107510. getPhysicsPlugin(): IPhysicsEnginePlugin;
  107511. /**
  107512. * Gets the list of physic impostors
  107513. * @returns an array of PhysicsImpostor
  107514. */
  107515. getImpostors(): Array<PhysicsImpostor>;
  107516. /**
  107517. * Gets the impostor for a physics enabled object
  107518. * @param object defines the object impersonated by the impostor
  107519. * @returns the PhysicsImpostor or null if not found
  107520. */
  107521. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  107522. /**
  107523. * Gets the impostor for a physics body object
  107524. * @param body defines physics body used by the impostor
  107525. * @returns the PhysicsImpostor or null if not found
  107526. */
  107527. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  107528. /**
  107529. * Does a raycast in the physics world
  107530. * @param from when should the ray start?
  107531. * @param to when should the ray end?
  107532. * @returns PhysicsRaycastResult
  107533. */
  107534. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107535. }
  107536. }
  107537. declare module BABYLON {
  107538. /** @hidden */
  107539. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  107540. private _useDeltaForWorldStep;
  107541. world: any;
  107542. name: string;
  107543. private _physicsMaterials;
  107544. private _fixedTimeStep;
  107545. private _cannonRaycastResult;
  107546. private _raycastResult;
  107547. private _removeAfterStep;
  107548. BJSCANNON: any;
  107549. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  107550. setGravity(gravity: Vector3): void;
  107551. setTimeStep(timeStep: number): void;
  107552. getTimeStep(): number;
  107553. executeStep(delta: number): void;
  107554. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107555. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107556. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107557. private _processChildMeshes;
  107558. removePhysicsBody(impostor: PhysicsImpostor): void;
  107559. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107560. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107561. private _addMaterial;
  107562. private _checkWithEpsilon;
  107563. private _createShape;
  107564. private _createHeightmap;
  107565. private _minus90X;
  107566. private _plus90X;
  107567. private _tmpPosition;
  107568. private _tmpDeltaPosition;
  107569. private _tmpUnityRotation;
  107570. private _updatePhysicsBodyTransformation;
  107571. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107572. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107573. isSupported(): boolean;
  107574. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107575. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107576. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107577. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107578. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107579. getBodyMass(impostor: PhysicsImpostor): number;
  107580. getBodyFriction(impostor: PhysicsImpostor): number;
  107581. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107582. getBodyRestitution(impostor: PhysicsImpostor): number;
  107583. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107584. sleepBody(impostor: PhysicsImpostor): void;
  107585. wakeUpBody(impostor: PhysicsImpostor): void;
  107586. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  107587. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  107588. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  107589. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107590. getRadius(impostor: PhysicsImpostor): number;
  107591. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107592. dispose(): void;
  107593. private _extendNamespace;
  107594. /**
  107595. * Does a raycast in the physics world
  107596. * @param from when should the ray start?
  107597. * @param to when should the ray end?
  107598. * @returns PhysicsRaycastResult
  107599. */
  107600. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107601. }
  107602. }
  107603. declare module BABYLON {
  107604. /** @hidden */
  107605. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  107606. world: any;
  107607. name: string;
  107608. BJSOIMO: any;
  107609. private _raycastResult;
  107610. constructor(iterations?: number, oimoInjection?: any);
  107611. setGravity(gravity: Vector3): void;
  107612. setTimeStep(timeStep: number): void;
  107613. getTimeStep(): number;
  107614. private _tmpImpostorsArray;
  107615. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107616. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107617. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107618. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107619. private _tmpPositionVector;
  107620. removePhysicsBody(impostor: PhysicsImpostor): void;
  107621. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107622. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107623. isSupported(): boolean;
  107624. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107625. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107626. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107627. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107628. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107629. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107630. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107631. getBodyMass(impostor: PhysicsImpostor): number;
  107632. getBodyFriction(impostor: PhysicsImpostor): number;
  107633. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107634. getBodyRestitution(impostor: PhysicsImpostor): number;
  107635. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107636. sleepBody(impostor: PhysicsImpostor): void;
  107637. wakeUpBody(impostor: PhysicsImpostor): void;
  107638. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107639. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  107640. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107641. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107642. getRadius(impostor: PhysicsImpostor): number;
  107643. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107644. dispose(): void;
  107645. /**
  107646. * Does a raycast in the physics world
  107647. * @param from when should the ray start?
  107648. * @param to when should the ray end?
  107649. * @returns PhysicsRaycastResult
  107650. */
  107651. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107652. }
  107653. }
  107654. declare module BABYLON {
  107655. /**
  107656. * Class containing static functions to help procedurally build meshes
  107657. */
  107658. export class RibbonBuilder {
  107659. /**
  107660. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  107661. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  107662. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  107663. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  107664. * * 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
  107665. * * 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
  107666. * * 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
  107667. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107668. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107669. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107670. * * 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
  107671. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  107672. * * 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
  107673. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  107674. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107675. * @param name defines the name of the mesh
  107676. * @param options defines the options used to create the mesh
  107677. * @param scene defines the hosting scene
  107678. * @returns the ribbon mesh
  107679. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  107680. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107681. */
  107682. static CreateRibbon(name: string, options: {
  107683. pathArray: Vector3[][];
  107684. closeArray?: boolean;
  107685. closePath?: boolean;
  107686. offset?: number;
  107687. updatable?: boolean;
  107688. sideOrientation?: number;
  107689. frontUVs?: Vector4;
  107690. backUVs?: Vector4;
  107691. instance?: Mesh;
  107692. invertUV?: boolean;
  107693. uvs?: Vector2[];
  107694. colors?: Color4[];
  107695. }, scene?: Nullable<Scene>): Mesh;
  107696. }
  107697. }
  107698. declare module BABYLON {
  107699. /**
  107700. * Class containing static functions to help procedurally build meshes
  107701. */
  107702. export class ShapeBuilder {
  107703. /**
  107704. * 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.
  107705. * * 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.
  107706. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107707. * * 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.
  107708. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  107709. * * 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
  107710. * * 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
  107711. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  107712. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107713. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107714. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  107715. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  107716. * @param name defines the name of the mesh
  107717. * @param options defines the options used to create the mesh
  107718. * @param scene defines the hosting scene
  107719. * @returns the extruded shape mesh
  107720. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107721. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107722. */
  107723. static ExtrudeShape(name: string, options: {
  107724. shape: Vector3[];
  107725. path: Vector3[];
  107726. scale?: number;
  107727. rotation?: number;
  107728. cap?: number;
  107729. updatable?: boolean;
  107730. sideOrientation?: number;
  107731. frontUVs?: Vector4;
  107732. backUVs?: Vector4;
  107733. instance?: Mesh;
  107734. invertUV?: boolean;
  107735. }, scene?: Nullable<Scene>): Mesh;
  107736. /**
  107737. * Creates an custom extruded shape mesh.
  107738. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  107739. * * 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.
  107740. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  107741. * * 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
  107742. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  107743. * * 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
  107744. * * It must returns a float value that will be the scale value applied to the shape on each path point
  107745. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  107746. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  107747. * * 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
  107748. * * 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
  107749. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  107750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  107751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  107752. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  107753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  107754. * @param name defines the name of the mesh
  107755. * @param options defines the options used to create the mesh
  107756. * @param scene defines the hosting scene
  107757. * @returns the custom extruded shape mesh
  107758. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  107759. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  107760. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  107761. */
  107762. static ExtrudeShapeCustom(name: string, options: {
  107763. shape: Vector3[];
  107764. path: Vector3[];
  107765. scaleFunction?: any;
  107766. rotationFunction?: any;
  107767. ribbonCloseArray?: boolean;
  107768. ribbonClosePath?: boolean;
  107769. cap?: number;
  107770. updatable?: boolean;
  107771. sideOrientation?: number;
  107772. frontUVs?: Vector4;
  107773. backUVs?: Vector4;
  107774. instance?: Mesh;
  107775. invertUV?: boolean;
  107776. }, scene?: Nullable<Scene>): Mesh;
  107777. private static _ExtrudeShapeGeneric;
  107778. }
  107779. }
  107780. declare module BABYLON {
  107781. /**
  107782. * AmmoJS Physics plugin
  107783. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107784. * @see https://github.com/kripken/ammo.js/
  107785. */
  107786. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  107787. private _useDeltaForWorldStep;
  107788. /**
  107789. * Reference to the Ammo library
  107790. */
  107791. bjsAMMO: any;
  107792. /**
  107793. * Created ammoJS world which physics bodies are added to
  107794. */
  107795. world: any;
  107796. /**
  107797. * Name of the plugin
  107798. */
  107799. name: string;
  107800. private _timeStep;
  107801. private _fixedTimeStep;
  107802. private _maxSteps;
  107803. private _tmpQuaternion;
  107804. private _tmpAmmoTransform;
  107805. private _tmpAmmoQuaternion;
  107806. private _tmpAmmoConcreteContactResultCallback;
  107807. private _collisionConfiguration;
  107808. private _dispatcher;
  107809. private _overlappingPairCache;
  107810. private _solver;
  107811. private _softBodySolver;
  107812. private _tmpAmmoVectorA;
  107813. private _tmpAmmoVectorB;
  107814. private _tmpAmmoVectorC;
  107815. private _tmpAmmoVectorD;
  107816. private _tmpContactCallbackResult;
  107817. private _tmpAmmoVectorRCA;
  107818. private _tmpAmmoVectorRCB;
  107819. private _raycastResult;
  107820. private static readonly DISABLE_COLLISION_FLAG;
  107821. private static readonly KINEMATIC_FLAG;
  107822. private static readonly DISABLE_DEACTIVATION_FLAG;
  107823. /**
  107824. * Initializes the ammoJS plugin
  107825. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  107826. * @param ammoInjection can be used to inject your own ammo reference
  107827. */
  107828. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any);
  107829. /**
  107830. * Sets the gravity of the physics world (m/(s^2))
  107831. * @param gravity Gravity to set
  107832. */
  107833. setGravity(gravity: Vector3): void;
  107834. /**
  107835. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  107836. * @param timeStep timestep to use in seconds
  107837. */
  107838. setTimeStep(timeStep: number): void;
  107839. /**
  107840. * 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)
  107841. * @param fixedTimeStep fixedTimeStep to use in seconds
  107842. */
  107843. setFixedTimeStep(fixedTimeStep: number): void;
  107844. /**
  107845. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  107846. * @param maxSteps the maximum number of steps by the physics engine per frame
  107847. */
  107848. setMaxSteps(maxSteps: number): void;
  107849. /**
  107850. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  107851. * @returns the current timestep in seconds
  107852. */
  107853. getTimeStep(): number;
  107854. private _isImpostorInContact;
  107855. private _isImpostorPairInContact;
  107856. private _stepSimulation;
  107857. /**
  107858. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  107859. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  107860. * After the step the babylon meshes are set to the position of the physics imposters
  107861. * @param delta amount of time to step forward
  107862. * @param impostors array of imposters to update before/after the step
  107863. */
  107864. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107865. /**
  107866. * Update babylon mesh to match physics world object
  107867. * @param impostor imposter to match
  107868. */
  107869. private _afterSoftStep;
  107870. /**
  107871. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107872. * @param impostor imposter to match
  107873. */
  107874. private _ropeStep;
  107875. /**
  107876. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  107877. * @param impostor imposter to match
  107878. */
  107879. private _softbodyOrClothStep;
  107880. private _tmpVector;
  107881. private _tmpMatrix;
  107882. /**
  107883. * Applies an impulse on the imposter
  107884. * @param impostor imposter to apply impulse to
  107885. * @param force amount of force to be applied to the imposter
  107886. * @param contactPoint the location to apply the impulse on the imposter
  107887. */
  107888. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107889. /**
  107890. * Applies a force on the imposter
  107891. * @param impostor imposter to apply force
  107892. * @param force amount of force to be applied to the imposter
  107893. * @param contactPoint the location to apply the force on the imposter
  107894. */
  107895. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107896. /**
  107897. * Creates a physics body using the plugin
  107898. * @param impostor the imposter to create the physics body on
  107899. */
  107900. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107901. /**
  107902. * Removes the physics body from the imposter and disposes of the body's memory
  107903. * @param impostor imposter to remove the physics body from
  107904. */
  107905. removePhysicsBody(impostor: PhysicsImpostor): void;
  107906. /**
  107907. * Generates a joint
  107908. * @param impostorJoint the imposter joint to create the joint with
  107909. */
  107910. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  107911. /**
  107912. * Removes a joint
  107913. * @param impostorJoint the imposter joint to remove the joint from
  107914. */
  107915. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  107916. private _addMeshVerts;
  107917. /**
  107918. * Initialise the soft body vertices to match its object's (mesh) vertices
  107919. * Softbody vertices (nodes) are in world space and to match this
  107920. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  107921. * @param impostor to create the softbody for
  107922. */
  107923. private _softVertexData;
  107924. /**
  107925. * Create an impostor's soft body
  107926. * @param impostor to create the softbody for
  107927. */
  107928. private _createSoftbody;
  107929. /**
  107930. * Create cloth for an impostor
  107931. * @param impostor to create the softbody for
  107932. */
  107933. private _createCloth;
  107934. /**
  107935. * Create rope for an impostor
  107936. * @param impostor to create the softbody for
  107937. */
  107938. private _createRope;
  107939. private _addHullVerts;
  107940. private _createShape;
  107941. /**
  107942. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  107943. * @param impostor imposter containing the physics body and babylon object
  107944. */
  107945. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107946. /**
  107947. * Sets the babylon object's position/rotation from the physics body's position/rotation
  107948. * @param impostor imposter containing the physics body and babylon object
  107949. * @param newPosition new position
  107950. * @param newRotation new rotation
  107951. */
  107952. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107953. /**
  107954. * If this plugin is supported
  107955. * @returns true if its supported
  107956. */
  107957. isSupported(): boolean;
  107958. /**
  107959. * Sets the linear velocity of the physics body
  107960. * @param impostor imposter to set the velocity on
  107961. * @param velocity velocity to set
  107962. */
  107963. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107964. /**
  107965. * Sets the angular velocity of the physics body
  107966. * @param impostor imposter to set the velocity on
  107967. * @param velocity velocity to set
  107968. */
  107969. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  107970. /**
  107971. * gets the linear velocity
  107972. * @param impostor imposter to get linear velocity from
  107973. * @returns linear velocity
  107974. */
  107975. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107976. /**
  107977. * gets the angular velocity
  107978. * @param impostor imposter to get angular velocity from
  107979. * @returns angular velocity
  107980. */
  107981. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107982. /**
  107983. * Sets the mass of physics body
  107984. * @param impostor imposter to set the mass on
  107985. * @param mass mass to set
  107986. */
  107987. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107988. /**
  107989. * Gets the mass of the physics body
  107990. * @param impostor imposter to get the mass from
  107991. * @returns mass
  107992. */
  107993. getBodyMass(impostor: PhysicsImpostor): number;
  107994. /**
  107995. * Gets friction of the impostor
  107996. * @param impostor impostor to get friction from
  107997. * @returns friction value
  107998. */
  107999. getBodyFriction(impostor: PhysicsImpostor): number;
  108000. /**
  108001. * Sets friction of the impostor
  108002. * @param impostor impostor to set friction on
  108003. * @param friction friction value
  108004. */
  108005. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  108006. /**
  108007. * Gets restitution of the impostor
  108008. * @param impostor impostor to get restitution from
  108009. * @returns restitution value
  108010. */
  108011. getBodyRestitution(impostor: PhysicsImpostor): number;
  108012. /**
  108013. * Sets resitution of the impostor
  108014. * @param impostor impostor to set resitution on
  108015. * @param restitution resitution value
  108016. */
  108017. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  108018. /**
  108019. * Gets pressure inside the impostor
  108020. * @param impostor impostor to get pressure from
  108021. * @returns pressure value
  108022. */
  108023. getBodyPressure(impostor: PhysicsImpostor): number;
  108024. /**
  108025. * Sets pressure inside a soft body impostor
  108026. * Cloth and rope must remain 0 pressure
  108027. * @param impostor impostor to set pressure on
  108028. * @param pressure pressure value
  108029. */
  108030. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  108031. /**
  108032. * Gets stiffness of the impostor
  108033. * @param impostor impostor to get stiffness from
  108034. * @returns pressure value
  108035. */
  108036. getBodyStiffness(impostor: PhysicsImpostor): number;
  108037. /**
  108038. * Sets stiffness of the impostor
  108039. * @param impostor impostor to set stiffness on
  108040. * @param stiffness stiffness value from 0 to 1
  108041. */
  108042. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  108043. /**
  108044. * Gets velocityIterations of the impostor
  108045. * @param impostor impostor to get velocity iterations from
  108046. * @returns velocityIterations value
  108047. */
  108048. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  108049. /**
  108050. * Sets velocityIterations of the impostor
  108051. * @param impostor impostor to set velocity iterations on
  108052. * @param velocityIterations velocityIterations value
  108053. */
  108054. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  108055. /**
  108056. * Gets positionIterations of the impostor
  108057. * @param impostor impostor to get position iterations from
  108058. * @returns positionIterations value
  108059. */
  108060. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  108061. /**
  108062. * Sets positionIterations of the impostor
  108063. * @param impostor impostor to set position on
  108064. * @param positionIterations positionIterations value
  108065. */
  108066. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  108067. /**
  108068. * Append an anchor to a cloth object
  108069. * @param impostor is the cloth impostor to add anchor to
  108070. * @param otherImpostor is the rigid impostor to anchor to
  108071. * @param width ratio across width from 0 to 1
  108072. * @param height ratio up height from 0 to 1
  108073. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108074. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108075. */
  108076. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108077. /**
  108078. * Append an hook to a rope object
  108079. * @param impostor is the rope impostor to add hook to
  108080. * @param otherImpostor is the rigid impostor to hook to
  108081. * @param length ratio along the rope from 0 to 1
  108082. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  108083. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108084. */
  108085. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  108086. /**
  108087. * Sleeps the physics body and stops it from being active
  108088. * @param impostor impostor to sleep
  108089. */
  108090. sleepBody(impostor: PhysicsImpostor): void;
  108091. /**
  108092. * Activates the physics body
  108093. * @param impostor impostor to activate
  108094. */
  108095. wakeUpBody(impostor: PhysicsImpostor): void;
  108096. /**
  108097. * Updates the distance parameters of the joint
  108098. * @param joint joint to update
  108099. * @param maxDistance maximum distance of the joint
  108100. * @param minDistance minimum distance of the joint
  108101. */
  108102. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  108103. /**
  108104. * Sets a motor on the joint
  108105. * @param joint joint to set motor on
  108106. * @param speed speed of the motor
  108107. * @param maxForce maximum force of the motor
  108108. * @param motorIndex index of the motor
  108109. */
  108110. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  108111. /**
  108112. * Sets the motors limit
  108113. * @param joint joint to set limit on
  108114. * @param upperLimit upper limit
  108115. * @param lowerLimit lower limit
  108116. */
  108117. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  108118. /**
  108119. * Syncs the position and rotation of a mesh with the impostor
  108120. * @param mesh mesh to sync
  108121. * @param impostor impostor to update the mesh with
  108122. */
  108123. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  108124. /**
  108125. * Gets the radius of the impostor
  108126. * @param impostor impostor to get radius from
  108127. * @returns the radius
  108128. */
  108129. getRadius(impostor: PhysicsImpostor): number;
  108130. /**
  108131. * Gets the box size of the impostor
  108132. * @param impostor impostor to get box size from
  108133. * @param result the resulting box size
  108134. */
  108135. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  108136. /**
  108137. * Disposes of the impostor
  108138. */
  108139. dispose(): void;
  108140. /**
  108141. * Does a raycast in the physics world
  108142. * @param from when should the ray start?
  108143. * @param to when should the ray end?
  108144. * @returns PhysicsRaycastResult
  108145. */
  108146. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108147. }
  108148. }
  108149. declare module BABYLON {
  108150. interface AbstractScene {
  108151. /**
  108152. * The list of reflection probes added to the scene
  108153. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108154. */
  108155. reflectionProbes: Array<ReflectionProbe>;
  108156. /**
  108157. * Removes the given reflection probe from this scene.
  108158. * @param toRemove The reflection probe to remove
  108159. * @returns The index of the removed reflection probe
  108160. */
  108161. removeReflectionProbe(toRemove: ReflectionProbe): number;
  108162. /**
  108163. * Adds the given reflection probe to this scene.
  108164. * @param newReflectionProbe The reflection probe to add
  108165. */
  108166. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  108167. }
  108168. /**
  108169. * Class used to generate realtime reflection / refraction cube textures
  108170. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  108171. */
  108172. export class ReflectionProbe {
  108173. /** defines the name of the probe */
  108174. name: string;
  108175. private _scene;
  108176. private _renderTargetTexture;
  108177. private _projectionMatrix;
  108178. private _viewMatrix;
  108179. private _target;
  108180. private _add;
  108181. private _attachedMesh;
  108182. private _invertYAxis;
  108183. /** Gets or sets probe position (center of the cube map) */
  108184. position: Vector3;
  108185. /**
  108186. * Creates a new reflection probe
  108187. * @param name defines the name of the probe
  108188. * @param size defines the texture resolution (for each face)
  108189. * @param scene defines the hosting scene
  108190. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  108191. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  108192. */
  108193. constructor(
  108194. /** defines the name of the probe */
  108195. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  108196. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  108197. samples: number;
  108198. /** Gets or sets the refresh rate to use (on every frame by default) */
  108199. refreshRate: number;
  108200. /**
  108201. * Gets the hosting scene
  108202. * @returns a Scene
  108203. */
  108204. getScene(): Scene;
  108205. /** Gets the internal CubeTexture used to render to */
  108206. readonly cubeTexture: RenderTargetTexture;
  108207. /** Gets the list of meshes to render */
  108208. readonly renderList: Nullable<AbstractMesh[]>;
  108209. /**
  108210. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  108211. * @param mesh defines the mesh to attach to
  108212. */
  108213. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  108214. /**
  108215. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  108216. * @param renderingGroupId The rendering group id corresponding to its index
  108217. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  108218. */
  108219. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  108220. /**
  108221. * Clean all associated resources
  108222. */
  108223. dispose(): void;
  108224. /**
  108225. * Converts the reflection probe information to a readable string for debug purpose.
  108226. * @param fullDetails Supports for multiple levels of logging within scene loading
  108227. * @returns the human readable reflection probe info
  108228. */
  108229. toString(fullDetails?: boolean): string;
  108230. /**
  108231. * Get the class name of the relfection probe.
  108232. * @returns "ReflectionProbe"
  108233. */
  108234. getClassName(): string;
  108235. /**
  108236. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  108237. * @returns The JSON representation of the texture
  108238. */
  108239. serialize(): any;
  108240. /**
  108241. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  108242. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  108243. * @param scene Define the scene the parsed reflection probe should be instantiated in
  108244. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  108245. * @returns The parsed reflection probe if successful
  108246. */
  108247. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  108248. }
  108249. }
  108250. declare module BABYLON {
  108251. /** @hidden */
  108252. export var _BabylonLoaderRegistered: boolean;
  108253. }
  108254. declare module BABYLON {
  108255. /**
  108256. * The Physically based simple base material of BJS.
  108257. *
  108258. * This enables better naming and convention enforcements on top of the pbrMaterial.
  108259. * It is used as the base class for both the specGloss and metalRough conventions.
  108260. */
  108261. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  108262. /**
  108263. * Number of Simultaneous lights allowed on the material.
  108264. */
  108265. maxSimultaneousLights: number;
  108266. /**
  108267. * If sets to true, disables all the lights affecting the material.
  108268. */
  108269. disableLighting: boolean;
  108270. /**
  108271. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  108272. */
  108273. environmentTexture: BaseTexture;
  108274. /**
  108275. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  108276. */
  108277. invertNormalMapX: boolean;
  108278. /**
  108279. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  108280. */
  108281. invertNormalMapY: boolean;
  108282. /**
  108283. * Normal map used in the model.
  108284. */
  108285. normalTexture: BaseTexture;
  108286. /**
  108287. * Emissivie color used to self-illuminate the model.
  108288. */
  108289. emissiveColor: Color3;
  108290. /**
  108291. * Emissivie texture used to self-illuminate the model.
  108292. */
  108293. emissiveTexture: BaseTexture;
  108294. /**
  108295. * Occlusion Channel Strenght.
  108296. */
  108297. occlusionStrength: number;
  108298. /**
  108299. * Occlusion Texture of the material (adding extra occlusion effects).
  108300. */
  108301. occlusionTexture: BaseTexture;
  108302. /**
  108303. * Defines the alpha limits in alpha test mode.
  108304. */
  108305. alphaCutOff: number;
  108306. /**
  108307. * Gets the current double sided mode.
  108308. */
  108309. /**
  108310. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  108311. */
  108312. doubleSided: boolean;
  108313. /**
  108314. * Stores the pre-calculated light information of a mesh in a texture.
  108315. */
  108316. lightmapTexture: BaseTexture;
  108317. /**
  108318. * If true, the light map contains occlusion information instead of lighting info.
  108319. */
  108320. useLightmapAsShadowmap: boolean;
  108321. /**
  108322. * Instantiates a new PBRMaterial instance.
  108323. *
  108324. * @param name The material name
  108325. * @param scene The scene the material will be use in.
  108326. */
  108327. constructor(name: string, scene: Scene);
  108328. getClassName(): string;
  108329. }
  108330. }
  108331. declare module BABYLON {
  108332. /**
  108333. * The PBR material of BJS following the metal roughness convention.
  108334. *
  108335. * This fits to the PBR convention in the GLTF definition:
  108336. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  108337. */
  108338. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  108339. /**
  108340. * The base color has two different interpretations depending on the value of metalness.
  108341. * When the material is a metal, the base color is the specific measured reflectance value
  108342. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  108343. * of the material.
  108344. */
  108345. baseColor: Color3;
  108346. /**
  108347. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  108348. * well as opacity information in the alpha channel.
  108349. */
  108350. baseTexture: BaseTexture;
  108351. /**
  108352. * Specifies the metallic scalar value of the material.
  108353. * Can also be used to scale the metalness values of the metallic texture.
  108354. */
  108355. metallic: number;
  108356. /**
  108357. * Specifies the roughness scalar value of the material.
  108358. * Can also be used to scale the roughness values of the metallic texture.
  108359. */
  108360. roughness: number;
  108361. /**
  108362. * Texture containing both the metallic value in the B channel and the
  108363. * roughness value in the G channel to keep better precision.
  108364. */
  108365. metallicRoughnessTexture: BaseTexture;
  108366. /**
  108367. * Instantiates a new PBRMetalRoughnessMaterial instance.
  108368. *
  108369. * @param name The material name
  108370. * @param scene The scene the material will be use in.
  108371. */
  108372. constructor(name: string, scene: Scene);
  108373. /**
  108374. * Return the currrent class name of the material.
  108375. */
  108376. getClassName(): string;
  108377. /**
  108378. * Makes a duplicate of the current material.
  108379. * @param name - name to use for the new material.
  108380. */
  108381. clone(name: string): PBRMetallicRoughnessMaterial;
  108382. /**
  108383. * Serialize the material to a parsable JSON object.
  108384. */
  108385. serialize(): any;
  108386. /**
  108387. * Parses a JSON object correponding to the serialize function.
  108388. */
  108389. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  108390. }
  108391. }
  108392. declare module BABYLON {
  108393. /**
  108394. * The PBR material of BJS following the specular glossiness convention.
  108395. *
  108396. * This fits to the PBR convention in the GLTF definition:
  108397. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  108398. */
  108399. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  108400. /**
  108401. * Specifies the diffuse color of the material.
  108402. */
  108403. diffuseColor: Color3;
  108404. /**
  108405. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  108406. * channel.
  108407. */
  108408. diffuseTexture: BaseTexture;
  108409. /**
  108410. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  108411. */
  108412. specularColor: Color3;
  108413. /**
  108414. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  108415. */
  108416. glossiness: number;
  108417. /**
  108418. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  108419. */
  108420. specularGlossinessTexture: BaseTexture;
  108421. /**
  108422. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  108423. *
  108424. * @param name The material name
  108425. * @param scene The scene the material will be use in.
  108426. */
  108427. constructor(name: string, scene: Scene);
  108428. /**
  108429. * Return the currrent class name of the material.
  108430. */
  108431. getClassName(): string;
  108432. /**
  108433. * Makes a duplicate of the current material.
  108434. * @param name - name to use for the new material.
  108435. */
  108436. clone(name: string): PBRSpecularGlossinessMaterial;
  108437. /**
  108438. * Serialize the material to a parsable JSON object.
  108439. */
  108440. serialize(): any;
  108441. /**
  108442. * Parses a JSON object correponding to the serialize function.
  108443. */
  108444. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  108445. }
  108446. }
  108447. declare module BABYLON {
  108448. /**
  108449. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  108450. * It can help converting any input color in a desired output one. This can then be used to create effects
  108451. * from sepia, black and white to sixties or futuristic rendering...
  108452. *
  108453. * The only supported format is currently 3dl.
  108454. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  108455. */
  108456. export class ColorGradingTexture extends BaseTexture {
  108457. /**
  108458. * The current texture matrix. (will always be identity in color grading texture)
  108459. */
  108460. private _textureMatrix;
  108461. /**
  108462. * The texture URL.
  108463. */
  108464. url: string;
  108465. /**
  108466. * Empty line regex stored for GC.
  108467. */
  108468. private static _noneEmptyLineRegex;
  108469. private _engine;
  108470. /**
  108471. * Instantiates a ColorGradingTexture from the following parameters.
  108472. *
  108473. * @param url The location of the color gradind data (currently only supporting 3dl)
  108474. * @param scene The scene the texture will be used in
  108475. */
  108476. constructor(url: string, scene: Scene);
  108477. /**
  108478. * Returns the texture matrix used in most of the material.
  108479. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  108480. */
  108481. getTextureMatrix(): Matrix;
  108482. /**
  108483. * Occurs when the file being loaded is a .3dl LUT file.
  108484. */
  108485. private load3dlTexture;
  108486. /**
  108487. * Starts the loading process of the texture.
  108488. */
  108489. private loadTexture;
  108490. /**
  108491. * Clones the color gradind texture.
  108492. */
  108493. clone(): ColorGradingTexture;
  108494. /**
  108495. * Called during delayed load for textures.
  108496. */
  108497. delayLoad(): void;
  108498. /**
  108499. * Parses a color grading texture serialized by Babylon.
  108500. * @param parsedTexture The texture information being parsedTexture
  108501. * @param scene The scene to load the texture in
  108502. * @param rootUrl The root url of the data assets to load
  108503. * @return A color gradind texture
  108504. */
  108505. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  108506. /**
  108507. * Serializes the LUT texture to json format.
  108508. */
  108509. serialize(): any;
  108510. }
  108511. }
  108512. declare module BABYLON {
  108513. /**
  108514. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  108515. */
  108516. export class EquiRectangularCubeTexture extends BaseTexture {
  108517. /** The six faces of the cube. */
  108518. private static _FacesMapping;
  108519. private _noMipmap;
  108520. private _onLoad;
  108521. private _onError;
  108522. /** The size of the cubemap. */
  108523. private _size;
  108524. /** The buffer of the image. */
  108525. private _buffer;
  108526. /** The width of the input image. */
  108527. private _width;
  108528. /** The height of the input image. */
  108529. private _height;
  108530. /** The URL to the image. */
  108531. url: string;
  108532. /** The texture coordinates mode. As this texture is stored in a cube format, please modify carefully. */
  108533. coordinatesMode: number;
  108534. /**
  108535. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  108536. * @param url The location of the image
  108537. * @param scene The scene the texture will be used in
  108538. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  108539. * @param noMipmap Forces to not generate the mipmap if true
  108540. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  108541. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  108542. * @param onLoad — defines a callback called when texture is loaded
  108543. * @param onError — defines a callback called if there is an error
  108544. */
  108545. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  108546. /**
  108547. * Load the image data, by putting the image on a canvas and extracting its buffer.
  108548. */
  108549. private loadImage;
  108550. /**
  108551. * Convert the image buffer into a cubemap and create a CubeTexture.
  108552. */
  108553. private loadTexture;
  108554. /**
  108555. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  108556. * @param buffer The ArrayBuffer that should be converted.
  108557. * @returns The buffer as Float32Array.
  108558. */
  108559. private getFloat32ArrayFromArrayBuffer;
  108560. /**
  108561. * Get the current class name of the texture useful for serialization or dynamic coding.
  108562. * @returns "EquiRectangularCubeTexture"
  108563. */
  108564. getClassName(): string;
  108565. /**
  108566. * Create a clone of the current EquiRectangularCubeTexture and return it.
  108567. * @returns A clone of the current EquiRectangularCubeTexture.
  108568. */
  108569. clone(): EquiRectangularCubeTexture;
  108570. }
  108571. }
  108572. declare module BABYLON {
  108573. /**
  108574. * Based on jsTGALoader - Javascript loader for TGA file
  108575. * By Vincent Thibault
  108576. * @see http://blog.robrowser.com/javascript-tga-loader.html
  108577. */
  108578. export class TGATools {
  108579. private static _TYPE_INDEXED;
  108580. private static _TYPE_RGB;
  108581. private static _TYPE_GREY;
  108582. private static _TYPE_RLE_INDEXED;
  108583. private static _TYPE_RLE_RGB;
  108584. private static _TYPE_RLE_GREY;
  108585. private static _ORIGIN_MASK;
  108586. private static _ORIGIN_SHIFT;
  108587. private static _ORIGIN_BL;
  108588. private static _ORIGIN_BR;
  108589. private static _ORIGIN_UL;
  108590. private static _ORIGIN_UR;
  108591. /**
  108592. * Gets the header of a TGA file
  108593. * @param data defines the TGA data
  108594. * @returns the header
  108595. */
  108596. static GetTGAHeader(data: Uint8Array): any;
  108597. /**
  108598. * Uploads TGA content to a Babylon Texture
  108599. * @hidden
  108600. */
  108601. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  108602. /** @hidden */
  108603. 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;
  108604. /** @hidden */
  108605. 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;
  108606. /** @hidden */
  108607. 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;
  108608. /** @hidden */
  108609. 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;
  108610. /** @hidden */
  108611. 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;
  108612. /** @hidden */
  108613. 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;
  108614. }
  108615. }
  108616. declare module BABYLON {
  108617. /**
  108618. * Implementation of the TGA Texture Loader.
  108619. * @hidden
  108620. */
  108621. export class _TGATextureLoader implements IInternalTextureLoader {
  108622. /**
  108623. * Defines wether the loader supports cascade loading the different faces.
  108624. */
  108625. readonly supportCascades: boolean;
  108626. /**
  108627. * This returns if the loader support the current file information.
  108628. * @param extension defines the file extension of the file being loaded
  108629. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108630. * @param fallback defines the fallback internal texture if any
  108631. * @param isBase64 defines whether the texture is encoded as a base64
  108632. * @param isBuffer defines whether the texture data are stored as a buffer
  108633. * @returns true if the loader can load the specified file
  108634. */
  108635. canLoad(extension: string, textureFormatInUse: Nullable<string>, fallback: Nullable<InternalTexture>, isBase64: boolean, isBuffer: boolean): boolean;
  108636. /**
  108637. * Transform the url before loading if required.
  108638. * @param rootUrl the url of the texture
  108639. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108640. * @returns the transformed texture
  108641. */
  108642. transformUrl(rootUrl: string, textureFormatInUse: Nullable<string>): string;
  108643. /**
  108644. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  108645. * @param rootUrl the url of the texture
  108646. * @param textureFormatInUse defines the current compressed format in use iun the engine
  108647. * @returns the fallback texture
  108648. */
  108649. getFallbackTextureUrl(rootUrl: string, textureFormatInUse: Nullable<string>): Nullable<string>;
  108650. /**
  108651. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  108652. * @param data contains the texture data
  108653. * @param texture defines the BabylonJS internal texture
  108654. * @param createPolynomials will be true if polynomials have been requested
  108655. * @param onLoad defines the callback to trigger once the texture is ready
  108656. * @param onError defines the callback to trigger in case of error
  108657. */
  108658. loadCubeData(data: string | ArrayBuffer | (string | ArrayBuffer)[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  108659. /**
  108660. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  108661. * @param data contains the texture data
  108662. * @param texture defines the BabylonJS internal texture
  108663. * @param callback defines the method to call once ready to upload
  108664. */
  108665. loadData(data: ArrayBuffer, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  108666. }
  108667. }
  108668. declare module BABYLON {
  108669. /**
  108670. * 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.
  108671. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108672. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108673. */
  108674. export class CustomProceduralTexture extends ProceduralTexture {
  108675. private _animate;
  108676. private _time;
  108677. private _config;
  108678. private _texturePath;
  108679. /**
  108680. * Instantiates a new Custom Procedural Texture.
  108681. * 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.
  108682. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  108683. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  108684. * @param name Define the name of the texture
  108685. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  108686. * @param size Define the size of the texture to create
  108687. * @param scene Define the scene the texture belongs to
  108688. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  108689. * @param generateMipMaps Define if the texture should creates mip maps or not
  108690. */
  108691. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108692. private _loadJson;
  108693. /**
  108694. * Is the texture ready to be used ? (rendered at least once)
  108695. * @returns true if ready, otherwise, false.
  108696. */
  108697. isReady(): boolean;
  108698. /**
  108699. * Render the texture to its associated render target.
  108700. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  108701. */
  108702. render(useCameraPostProcess?: boolean): void;
  108703. /**
  108704. * Update the list of dependant textures samplers in the shader.
  108705. */
  108706. updateTextures(): void;
  108707. /**
  108708. * Update the uniform values of the procedural texture in the shader.
  108709. */
  108710. updateShaderUniforms(): void;
  108711. /**
  108712. * Define if the texture animates or not.
  108713. */
  108714. animate: boolean;
  108715. }
  108716. }
  108717. declare module BABYLON {
  108718. /** @hidden */
  108719. export var noisePixelShader: {
  108720. name: string;
  108721. shader: string;
  108722. };
  108723. }
  108724. declare module BABYLON {
  108725. /**
  108726. * Class used to generate noise procedural textures
  108727. */
  108728. export class NoiseProceduralTexture extends ProceduralTexture {
  108729. private _time;
  108730. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  108731. brightness: number;
  108732. /** Defines the number of octaves to process */
  108733. octaves: number;
  108734. /** Defines the level of persistence (0.8 by default) */
  108735. persistence: number;
  108736. /** Gets or sets animation speed factor (default is 1) */
  108737. animationSpeedFactor: number;
  108738. /**
  108739. * Creates a new NoiseProceduralTexture
  108740. * @param name defines the name fo the texture
  108741. * @param size defines the size of the texture (default is 256)
  108742. * @param scene defines the hosting scene
  108743. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  108744. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  108745. */
  108746. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  108747. private _updateShaderUniforms;
  108748. protected _getDefines(): string;
  108749. /** Generate the current state of the procedural texture */
  108750. render(useCameraPostProcess?: boolean): void;
  108751. /**
  108752. * Serializes this noise procedural texture
  108753. * @returns a serialized noise procedural texture object
  108754. */
  108755. serialize(): any;
  108756. /**
  108757. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  108758. * @param parsedTexture defines parsed texture data
  108759. * @param scene defines the current scene
  108760. * @param rootUrl defines the root URL containing noise procedural texture information
  108761. * @returns a parsed NoiseProceduralTexture
  108762. */
  108763. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  108764. }
  108765. }
  108766. declare module BABYLON {
  108767. /**
  108768. * Raw cube texture where the raw buffers are passed in
  108769. */
  108770. export class RawCubeTexture extends CubeTexture {
  108771. /**
  108772. * Creates a cube texture where the raw buffers are passed in.
  108773. * @param scene defines the scene the texture is attached to
  108774. * @param data defines the array of data to use to create each face
  108775. * @param size defines the size of the textures
  108776. * @param format defines the format of the data
  108777. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  108778. * @param generateMipMaps defines if the engine should generate the mip levels
  108779. * @param invertY defines if data must be stored with Y axis inverted
  108780. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  108781. * @param compression defines the compression used (null by default)
  108782. */
  108783. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  108784. /**
  108785. * Updates the raw cube texture.
  108786. * @param data defines the data to store
  108787. * @param format defines the data format
  108788. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  108789. * @param invertY defines if data must be stored with Y axis inverted
  108790. * @param compression defines the compression used (null by default)
  108791. * @param level defines which level of the texture to update
  108792. */
  108793. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  108794. /**
  108795. * Updates a raw cube texture with RGBD encoded data.
  108796. * @param data defines the array of data [mipmap][face] to use to create each face
  108797. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  108798. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  108799. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  108800. * @returns a promsie that resolves when the operation is complete
  108801. */
  108802. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  108803. /**
  108804. * Clones the raw cube texture.
  108805. * @return a new cube texture
  108806. */
  108807. clone(): CubeTexture;
  108808. /** @hidden */
  108809. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  108810. }
  108811. }
  108812. declare module BABYLON {
  108813. /**
  108814. * Class used to store 3D textures containing user data
  108815. */
  108816. export class RawTexture3D extends Texture {
  108817. /** Gets or sets the texture format to use */
  108818. format: number;
  108819. private _engine;
  108820. /**
  108821. * Create a new RawTexture3D
  108822. * @param data defines the data of the texture
  108823. * @param width defines the width of the texture
  108824. * @param height defines the height of the texture
  108825. * @param depth defines the depth of the texture
  108826. * @param format defines the texture format to use
  108827. * @param scene defines the hosting scene
  108828. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  108829. * @param invertY defines if texture must be stored with Y axis inverted
  108830. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  108831. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  108832. */
  108833. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  108834. /** Gets or sets the texture format to use */
  108835. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  108836. /**
  108837. * Update the texture with new data
  108838. * @param data defines the data to store in the texture
  108839. */
  108840. update(data: ArrayBufferView): void;
  108841. }
  108842. }
  108843. declare module BABYLON {
  108844. /**
  108845. * Creates a refraction texture used by refraction channel of the standard material.
  108846. * It is like a mirror but to see through a material.
  108847. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108848. */
  108849. export class RefractionTexture extends RenderTargetTexture {
  108850. /**
  108851. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  108852. * 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.
  108853. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108854. */
  108855. refractionPlane: Plane;
  108856. /**
  108857. * Define how deep under the surface we should see.
  108858. */
  108859. depth: number;
  108860. /**
  108861. * Creates a refraction texture used by refraction channel of the standard material.
  108862. * It is like a mirror but to see through a material.
  108863. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  108864. * @param name Define the texture name
  108865. * @param size Define the size of the underlying texture
  108866. * @param scene Define the scene the refraction belongs to
  108867. * @param generateMipMaps Define if we need to generate mips level for the refraction
  108868. */
  108869. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  108870. /**
  108871. * Clone the refraction texture.
  108872. * @returns the cloned texture
  108873. */
  108874. clone(): RefractionTexture;
  108875. /**
  108876. * Serialize the texture to a JSON representation you could use in Parse later on
  108877. * @returns the serialized JSON representation
  108878. */
  108879. serialize(): any;
  108880. }
  108881. }
  108882. declare module BABYLON {
  108883. /**
  108884. * Defines the options related to the creation of an HtmlElementTexture
  108885. */
  108886. export interface IHtmlElementTextureOptions {
  108887. /**
  108888. * Defines wether mip maps should be created or not.
  108889. */
  108890. generateMipMaps?: boolean;
  108891. /**
  108892. * Defines the sampling mode of the texture.
  108893. */
  108894. samplingMode?: number;
  108895. /**
  108896. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  108897. */
  108898. engine: Nullable<Engine>;
  108899. /**
  108900. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  108901. */
  108902. scene: Nullable<Scene>;
  108903. }
  108904. /**
  108905. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  108906. * To be as efficient as possible depending on your constraints nothing aside the first upload
  108907. * is automatically managed.
  108908. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  108909. * in your application.
  108910. *
  108911. * As the update is not automatic, you need to call them manually.
  108912. */
  108913. export class HtmlElementTexture extends BaseTexture {
  108914. /**
  108915. * The texture URL.
  108916. */
  108917. element: HTMLVideoElement | HTMLCanvasElement;
  108918. private static readonly DefaultOptions;
  108919. private _textureMatrix;
  108920. private _engine;
  108921. private _isVideo;
  108922. private _generateMipMaps;
  108923. private _samplingMode;
  108924. /**
  108925. * Instantiates a HtmlElementTexture from the following parameters.
  108926. *
  108927. * @param name Defines the name of the texture
  108928. * @param element Defines the video or canvas the texture is filled with
  108929. * @param options Defines the other none mandatory texture creation options
  108930. */
  108931. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  108932. private _createInternalTexture;
  108933. /**
  108934. * Returns the texture matrix used in most of the material.
  108935. */
  108936. getTextureMatrix(): Matrix;
  108937. /**
  108938. * Updates the content of the texture.
  108939. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  108940. */
  108941. update(invertY?: Nullable<boolean>): void;
  108942. }
  108943. }
  108944. declare module BABYLON {
  108945. /**
  108946. * Helper class to push actions to a pool of workers.
  108947. */
  108948. export class WorkerPool implements IDisposable {
  108949. private _workerInfos;
  108950. private _pendingActions;
  108951. /**
  108952. * Constructor
  108953. * @param workers Array of workers to use for actions
  108954. */
  108955. constructor(workers: Array<Worker>);
  108956. /**
  108957. * Terminates all workers and clears any pending actions.
  108958. */
  108959. dispose(): void;
  108960. /**
  108961. * Pushes an action to the worker pool. If all the workers are active, the action will be
  108962. * pended until a worker has completed its action.
  108963. * @param action The action to perform. Call onComplete when the action is complete.
  108964. */
  108965. push(action: (worker: Worker, onComplete: () => void) => void): void;
  108966. private _execute;
  108967. }
  108968. }
  108969. declare module BABYLON {
  108970. /**
  108971. * Configuration for Draco compression
  108972. */
  108973. export interface IDracoCompressionConfiguration {
  108974. /**
  108975. * Configuration for the decoder.
  108976. */
  108977. decoder?: {
  108978. /**
  108979. * The url to the WebAssembly module.
  108980. */
  108981. wasmUrl?: string;
  108982. /**
  108983. * The url to the WebAssembly binary.
  108984. */
  108985. wasmBinaryUrl?: string;
  108986. /**
  108987. * The url to the fallback JavaScript module.
  108988. */
  108989. fallbackUrl?: string;
  108990. };
  108991. }
  108992. /**
  108993. * Draco compression (https://google.github.io/draco/)
  108994. *
  108995. * This class wraps the Draco module.
  108996. *
  108997. * **Encoder**
  108998. *
  108999. * The encoder is not currently implemented.
  109000. *
  109001. * **Decoder**
  109002. *
  109003. * 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.
  109004. *
  109005. * To update the configuration, use the following code:
  109006. * ```javascript
  109007. * DracoCompression.Configuration = {
  109008. * decoder: {
  109009. * wasmUrl: "<url to the WebAssembly library>",
  109010. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  109011. * fallbackUrl: "<url to the fallback JavaScript library>",
  109012. * }
  109013. * };
  109014. * ```
  109015. *
  109016. * 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.
  109017. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  109018. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  109019. *
  109020. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  109021. * ```javascript
  109022. * var dracoCompression = new DracoCompression();
  109023. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  109024. * [VertexBuffer.PositionKind]: 0
  109025. * });
  109026. * ```
  109027. *
  109028. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  109029. */
  109030. export class DracoCompression implements IDisposable {
  109031. private _workerPoolPromise;
  109032. /**
  109033. * The configuration. Defaults to the following urls:
  109034. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  109035. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  109036. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  109037. */
  109038. static Configuration: IDracoCompressionConfiguration;
  109039. /**
  109040. * Returns true if the decoder is available.
  109041. */
  109042. static readonly DecoderAvailable: boolean;
  109043. /**
  109044. * Default number of workers to create when creating the draco compression object.
  109045. */
  109046. static DefaultNumWorkers: number;
  109047. private static GetDefaultNumWorkers;
  109048. /**
  109049. * Constructor
  109050. * @param numWorkers The number of workers for async operations
  109051. */
  109052. constructor(numWorkers?: number);
  109053. /**
  109054. * Stop all async operations and release resources.
  109055. */
  109056. dispose(): void;
  109057. /**
  109058. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  109059. * @returns a promise that resolves when ready
  109060. */
  109061. whenReadyAsync(): Promise<void>;
  109062. /**
  109063. * Decode Draco compressed mesh data to vertex data.
  109064. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  109065. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  109066. * @returns A promise that resolves with the decoded vertex data
  109067. */
  109068. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  109069. [kind: string]: number;
  109070. }): Promise<VertexData>;
  109071. /**
  109072. * The worker function that gets converted to a blob url to pass into a worker.
  109073. */
  109074. private static _Worker;
  109075. private _loadDecoderWasmBinaryAsync;
  109076. }
  109077. }
  109078. declare module BABYLON {
  109079. /**
  109080. * Class for building Constructive Solid Geometry
  109081. */
  109082. export class CSG {
  109083. private polygons;
  109084. /**
  109085. * The world matrix
  109086. */
  109087. matrix: Matrix;
  109088. /**
  109089. * Stores the position
  109090. */
  109091. position: Vector3;
  109092. /**
  109093. * Stores the rotation
  109094. */
  109095. rotation: Vector3;
  109096. /**
  109097. * Stores the rotation quaternion
  109098. */
  109099. rotationQuaternion: Nullable<Quaternion>;
  109100. /**
  109101. * Stores the scaling vector
  109102. */
  109103. scaling: Vector3;
  109104. /**
  109105. * Convert the Mesh to CSG
  109106. * @param mesh The Mesh to convert to CSG
  109107. * @returns A new CSG from the Mesh
  109108. */
  109109. static FromMesh(mesh: Mesh): CSG;
  109110. /**
  109111. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  109112. * @param polygons Polygons used to construct a CSG solid
  109113. */
  109114. private static FromPolygons;
  109115. /**
  109116. * Clones, or makes a deep copy, of the CSG
  109117. * @returns A new CSG
  109118. */
  109119. clone(): CSG;
  109120. /**
  109121. * Unions this CSG with another CSG
  109122. * @param csg The CSG to union against this CSG
  109123. * @returns The unioned CSG
  109124. */
  109125. union(csg: CSG): CSG;
  109126. /**
  109127. * Unions this CSG with another CSG in place
  109128. * @param csg The CSG to union against this CSG
  109129. */
  109130. unionInPlace(csg: CSG): void;
  109131. /**
  109132. * Subtracts this CSG with another CSG
  109133. * @param csg The CSG to subtract against this CSG
  109134. * @returns A new CSG
  109135. */
  109136. subtract(csg: CSG): CSG;
  109137. /**
  109138. * Subtracts this CSG with another CSG in place
  109139. * @param csg The CSG to subtact against this CSG
  109140. */
  109141. subtractInPlace(csg: CSG): void;
  109142. /**
  109143. * Intersect this CSG with another CSG
  109144. * @param csg The CSG to intersect against this CSG
  109145. * @returns A new CSG
  109146. */
  109147. intersect(csg: CSG): CSG;
  109148. /**
  109149. * Intersects this CSG with another CSG in place
  109150. * @param csg The CSG to intersect against this CSG
  109151. */
  109152. intersectInPlace(csg: CSG): void;
  109153. /**
  109154. * Return a new CSG solid with solid and empty space switched. This solid is
  109155. * not modified.
  109156. * @returns A new CSG solid with solid and empty space switched
  109157. */
  109158. inverse(): CSG;
  109159. /**
  109160. * Inverses the CSG in place
  109161. */
  109162. inverseInPlace(): void;
  109163. /**
  109164. * This is used to keep meshes transformations so they can be restored
  109165. * when we build back a Babylon Mesh
  109166. * NB : All CSG operations are performed in world coordinates
  109167. * @param csg The CSG to copy the transform attributes from
  109168. * @returns This CSG
  109169. */
  109170. copyTransformAttributes(csg: CSG): CSG;
  109171. /**
  109172. * Build Raw mesh from CSG
  109173. * Coordinates here are in world space
  109174. * @param name The name of the mesh geometry
  109175. * @param scene The Scene
  109176. * @param keepSubMeshes Specifies if the submeshes should be kept
  109177. * @returns A new Mesh
  109178. */
  109179. buildMeshGeometry(name: string, scene: Scene, keepSubMeshes: boolean): Mesh;
  109180. /**
  109181. * Build Mesh from CSG taking material and transforms into account
  109182. * @param name The name of the Mesh
  109183. * @param material The material of the Mesh
  109184. * @param scene The Scene
  109185. * @param keepSubMeshes Specifies if submeshes should be kept
  109186. * @returns The new Mesh
  109187. */
  109188. toMesh(name: string, material: Nullable<Material>, scene: Scene, keepSubMeshes: boolean): Mesh;
  109189. }
  109190. }
  109191. declare module BABYLON {
  109192. /**
  109193. * Class used to create a trail following a mesh
  109194. */
  109195. export class TrailMesh extends Mesh {
  109196. private _generator;
  109197. private _autoStart;
  109198. private _running;
  109199. private _diameter;
  109200. private _length;
  109201. private _sectionPolygonPointsCount;
  109202. private _sectionVectors;
  109203. private _sectionNormalVectors;
  109204. private _beforeRenderObserver;
  109205. /**
  109206. * @constructor
  109207. * @param name The value used by scene.getMeshByName() to do a lookup.
  109208. * @param generator The mesh to generate a trail.
  109209. * @param scene The scene to add this mesh to.
  109210. * @param diameter Diameter of trailing mesh. Default is 1.
  109211. * @param length Length of trailing mesh. Default is 60.
  109212. * @param autoStart Automatically start trailing mesh. Default true.
  109213. */
  109214. constructor(name: string, generator: AbstractMesh, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  109215. /**
  109216. * "TrailMesh"
  109217. * @returns "TrailMesh"
  109218. */
  109219. getClassName(): string;
  109220. private _createMesh;
  109221. /**
  109222. * Start trailing mesh.
  109223. */
  109224. start(): void;
  109225. /**
  109226. * Stop trailing mesh.
  109227. */
  109228. stop(): void;
  109229. /**
  109230. * Update trailing mesh geometry.
  109231. */
  109232. update(): void;
  109233. /**
  109234. * Returns a new TrailMesh object.
  109235. * @param name is a string, the name given to the new mesh
  109236. * @param newGenerator use new generator object for cloned trail mesh
  109237. * @returns a new mesh
  109238. */
  109239. clone(name: string | undefined, newGenerator: AbstractMesh): TrailMesh;
  109240. /**
  109241. * Serializes this trail mesh
  109242. * @param serializationObject object to write serialization to
  109243. */
  109244. serialize(serializationObject: any): void;
  109245. /**
  109246. * Parses a serialized trail mesh
  109247. * @param parsedMesh the serialized mesh
  109248. * @param scene the scene to create the trail mesh in
  109249. * @returns the created trail mesh
  109250. */
  109251. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  109252. }
  109253. }
  109254. declare module BABYLON {
  109255. /**
  109256. * Class containing static functions to help procedurally build meshes
  109257. */
  109258. export class TorusKnotBuilder {
  109259. /**
  109260. * Creates a torus knot mesh
  109261. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109262. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109263. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109264. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109265. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109266. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109267. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109268. * @param name defines the name of the mesh
  109269. * @param options defines the options used to create the mesh
  109270. * @param scene defines the hosting scene
  109271. * @returns the torus knot mesh
  109272. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109273. */
  109274. static CreateTorusKnot(name: string, options: {
  109275. radius?: number;
  109276. tube?: number;
  109277. radialSegments?: number;
  109278. tubularSegments?: number;
  109279. p?: number;
  109280. q?: number;
  109281. updatable?: boolean;
  109282. sideOrientation?: number;
  109283. frontUVs?: Vector4;
  109284. backUVs?: Vector4;
  109285. }, scene: any): Mesh;
  109286. }
  109287. }
  109288. declare module BABYLON {
  109289. /**
  109290. * Polygon
  109291. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109292. */
  109293. export class Polygon {
  109294. /**
  109295. * Creates a rectangle
  109296. * @param xmin bottom X coord
  109297. * @param ymin bottom Y coord
  109298. * @param xmax top X coord
  109299. * @param ymax top Y coord
  109300. * @returns points that make the resulting rectation
  109301. */
  109302. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  109303. /**
  109304. * Creates a circle
  109305. * @param radius radius of circle
  109306. * @param cx scale in x
  109307. * @param cy scale in y
  109308. * @param numberOfSides number of sides that make up the circle
  109309. * @returns points that make the resulting circle
  109310. */
  109311. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  109312. /**
  109313. * Creates a polygon from input string
  109314. * @param input Input polygon data
  109315. * @returns the parsed points
  109316. */
  109317. static Parse(input: string): Vector2[];
  109318. /**
  109319. * Starts building a polygon from x and y coordinates
  109320. * @param x x coordinate
  109321. * @param y y coordinate
  109322. * @returns the started path2
  109323. */
  109324. static StartingAt(x: number, y: number): Path2;
  109325. }
  109326. /**
  109327. * Builds a polygon
  109328. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  109329. */
  109330. export class PolygonMeshBuilder {
  109331. private _points;
  109332. private _outlinepoints;
  109333. private _holes;
  109334. private _name;
  109335. private _scene;
  109336. private _epoints;
  109337. private _eholes;
  109338. private _addToepoint;
  109339. /**
  109340. * Babylon reference to the earcut plugin.
  109341. */
  109342. bjsEarcut: any;
  109343. /**
  109344. * Creates a PolygonMeshBuilder
  109345. * @param name name of the builder
  109346. * @param contours Path of the polygon
  109347. * @param scene scene to add to when creating the mesh
  109348. * @param earcutInjection can be used to inject your own earcut reference
  109349. */
  109350. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  109351. /**
  109352. * Adds a whole within the polygon
  109353. * @param hole Array of points defining the hole
  109354. * @returns this
  109355. */
  109356. addHole(hole: Vector2[]): PolygonMeshBuilder;
  109357. /**
  109358. * Creates the polygon
  109359. * @param updatable If the mesh should be updatable
  109360. * @param depth The depth of the mesh created
  109361. * @returns the created mesh
  109362. */
  109363. build(updatable?: boolean, depth?: number): Mesh;
  109364. /**
  109365. * Creates the polygon
  109366. * @param depth The depth of the mesh created
  109367. * @returns the created VertexData
  109368. */
  109369. buildVertexData(depth?: number): VertexData;
  109370. /**
  109371. * Adds a side to the polygon
  109372. * @param positions points that make the polygon
  109373. * @param normals normals of the polygon
  109374. * @param uvs uvs of the polygon
  109375. * @param indices indices of the polygon
  109376. * @param bounds bounds of the polygon
  109377. * @param points points of the polygon
  109378. * @param depth depth of the polygon
  109379. * @param flip flip of the polygon
  109380. */
  109381. private addSide;
  109382. }
  109383. }
  109384. declare module BABYLON {
  109385. /**
  109386. * Class containing static functions to help procedurally build meshes
  109387. */
  109388. export class PolygonBuilder {
  109389. /**
  109390. * Creates a polygon mesh
  109391. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  109392. * * 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
  109393. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109394. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  109396. * * Remember you can only change the shape positions, not their number when updating a polygon
  109397. * @param name defines the name of the mesh
  109398. * @param options defines the options used to create the mesh
  109399. * @param scene defines the hosting scene
  109400. * @param earcutInjection can be used to inject your own earcut reference
  109401. * @returns the polygon mesh
  109402. */
  109403. static CreatePolygon(name: string, options: {
  109404. shape: Vector3[];
  109405. holes?: Vector3[][];
  109406. depth?: number;
  109407. faceUV?: Vector4[];
  109408. faceColors?: Color4[];
  109409. updatable?: boolean;
  109410. sideOrientation?: number;
  109411. frontUVs?: Vector4;
  109412. backUVs?: Vector4;
  109413. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109414. /**
  109415. * Creates an extruded polygon mesh, with depth in the Y direction.
  109416. * * 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)
  109417. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109418. * @param name defines the name of the mesh
  109419. * @param options defines the options used to create the mesh
  109420. * @param scene defines the hosting scene
  109421. * @param earcutInjection can be used to inject your own earcut reference
  109422. * @returns the polygon mesh
  109423. */
  109424. static ExtrudePolygon(name: string, options: {
  109425. shape: Vector3[];
  109426. holes?: Vector3[][];
  109427. depth?: number;
  109428. faceUV?: Vector4[];
  109429. faceColors?: Color4[];
  109430. updatable?: boolean;
  109431. sideOrientation?: number;
  109432. frontUVs?: Vector4;
  109433. backUVs?: Vector4;
  109434. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  109435. }
  109436. }
  109437. declare module BABYLON {
  109438. /**
  109439. * Class containing static functions to help procedurally build meshes
  109440. */
  109441. export class LatheBuilder {
  109442. /**
  109443. * Creates lathe mesh.
  109444. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109445. * * 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
  109446. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109447. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109448. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109449. * * 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
  109450. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109451. * * 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
  109452. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109453. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109454. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109455. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109456. * @param name defines the name of the mesh
  109457. * @param options defines the options used to create the mesh
  109458. * @param scene defines the hosting scene
  109459. * @returns the lathe mesh
  109460. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109461. */
  109462. static CreateLathe(name: string, options: {
  109463. shape: Vector3[];
  109464. radius?: number;
  109465. tessellation?: number;
  109466. clip?: number;
  109467. arc?: number;
  109468. closed?: boolean;
  109469. updatable?: boolean;
  109470. sideOrientation?: number;
  109471. frontUVs?: Vector4;
  109472. backUVs?: Vector4;
  109473. cap?: number;
  109474. invertUV?: boolean;
  109475. }, scene?: Nullable<Scene>): Mesh;
  109476. }
  109477. }
  109478. declare module BABYLON {
  109479. /**
  109480. * Class containing static functions to help procedurally build meshes
  109481. */
  109482. export class TubeBuilder {
  109483. /**
  109484. * Creates a tube mesh.
  109485. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109486. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  109487. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  109488. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  109489. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  109490. * * 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)
  109491. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  109492. * * 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
  109493. * * 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
  109494. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109495. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109496. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109498. * @param name defines the name of the mesh
  109499. * @param options defines the options used to create the mesh
  109500. * @param scene defines the hosting scene
  109501. * @returns the tube mesh
  109502. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109503. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  109504. */
  109505. static CreateTube(name: string, options: {
  109506. path: Vector3[];
  109507. radius?: number;
  109508. tessellation?: number;
  109509. radiusFunction?: {
  109510. (i: number, distance: number): number;
  109511. };
  109512. cap?: number;
  109513. arc?: number;
  109514. updatable?: boolean;
  109515. sideOrientation?: number;
  109516. frontUVs?: Vector4;
  109517. backUVs?: Vector4;
  109518. instance?: Mesh;
  109519. invertUV?: boolean;
  109520. }, scene?: Nullable<Scene>): Mesh;
  109521. }
  109522. }
  109523. declare module BABYLON {
  109524. /**
  109525. * Class containing static functions to help procedurally build meshes
  109526. */
  109527. export class IcoSphereBuilder {
  109528. /**
  109529. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109530. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109531. * * 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`)
  109532. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109533. * * 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
  109534. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109535. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109536. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109537. * @param name defines the name of the mesh
  109538. * @param options defines the options used to create the mesh
  109539. * @param scene defines the hosting scene
  109540. * @returns the icosahedron mesh
  109541. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109542. */
  109543. static CreateIcoSphere(name: string, options: {
  109544. radius?: number;
  109545. radiusX?: number;
  109546. radiusY?: number;
  109547. radiusZ?: number;
  109548. flat?: boolean;
  109549. subdivisions?: number;
  109550. sideOrientation?: number;
  109551. frontUVs?: Vector4;
  109552. backUVs?: Vector4;
  109553. updatable?: boolean;
  109554. }, scene?: Nullable<Scene>): Mesh;
  109555. }
  109556. }
  109557. declare module BABYLON {
  109558. /**
  109559. * Class containing static functions to help procedurally build meshes
  109560. */
  109561. export class DecalBuilder {
  109562. /**
  109563. * Creates a decal mesh.
  109564. * 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
  109565. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  109566. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  109567. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  109568. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  109569. * @param name defines the name of the mesh
  109570. * @param sourceMesh defines the mesh where the decal must be applied
  109571. * @param options defines the options used to create the mesh
  109572. * @param scene defines the hosting scene
  109573. * @returns the decal mesh
  109574. * @see https://doc.babylonjs.com/how_to/decals
  109575. */
  109576. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  109577. position?: Vector3;
  109578. normal?: Vector3;
  109579. size?: Vector3;
  109580. angle?: number;
  109581. }): Mesh;
  109582. }
  109583. }
  109584. declare module BABYLON {
  109585. /**
  109586. * Class containing static functions to help procedurally build meshes
  109587. */
  109588. export class MeshBuilder {
  109589. /**
  109590. * Creates a box mesh
  109591. * * The parameter `size` sets the size (float) of each box side (default 1)
  109592. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  109593. * * 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)
  109594. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  109595. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109596. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109597. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109598. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  109599. * @param name defines the name of the mesh
  109600. * @param options defines the options used to create the mesh
  109601. * @param scene defines the hosting scene
  109602. * @returns the box mesh
  109603. */
  109604. static CreateBox(name: string, options: {
  109605. size?: number;
  109606. width?: number;
  109607. height?: number;
  109608. depth?: number;
  109609. faceUV?: Vector4[];
  109610. faceColors?: Color4[];
  109611. sideOrientation?: number;
  109612. frontUVs?: Vector4;
  109613. backUVs?: Vector4;
  109614. updatable?: boolean;
  109615. }, scene?: Nullable<Scene>): Mesh;
  109616. /**
  109617. * Creates a sphere mesh
  109618. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  109619. * * 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`)
  109620. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  109621. * * 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
  109622. * * 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)
  109623. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109624. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109625. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109626. * @param name defines the name of the mesh
  109627. * @param options defines the options used to create the mesh
  109628. * @param scene defines the hosting scene
  109629. * @returns the sphere mesh
  109630. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  109631. */
  109632. static CreateSphere(name: string, options: {
  109633. segments?: number;
  109634. diameter?: number;
  109635. diameterX?: number;
  109636. diameterY?: number;
  109637. diameterZ?: number;
  109638. arc?: number;
  109639. slice?: number;
  109640. sideOrientation?: number;
  109641. frontUVs?: Vector4;
  109642. backUVs?: Vector4;
  109643. updatable?: boolean;
  109644. }, scene?: Nullable<Scene>): Mesh;
  109645. /**
  109646. * Creates a plane polygonal mesh. By default, this is a disc
  109647. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  109648. * * 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
  109649. * * 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
  109650. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109651. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109652. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109653. * @param name defines the name of the mesh
  109654. * @param options defines the options used to create the mesh
  109655. * @param scene defines the hosting scene
  109656. * @returns the plane polygonal mesh
  109657. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  109658. */
  109659. static CreateDisc(name: string, options: {
  109660. radius?: number;
  109661. tessellation?: number;
  109662. arc?: number;
  109663. updatable?: boolean;
  109664. sideOrientation?: number;
  109665. frontUVs?: Vector4;
  109666. backUVs?: Vector4;
  109667. }, scene?: Nullable<Scene>): Mesh;
  109668. /**
  109669. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109670. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109671. * * 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`)
  109672. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109673. * * 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
  109674. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109675. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109676. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109677. * @param name defines the name of the mesh
  109678. * @param options defines the options used to create the mesh
  109679. * @param scene defines the hosting scene
  109680. * @returns the icosahedron mesh
  109681. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109682. */
  109683. static CreateIcoSphere(name: string, options: {
  109684. radius?: number;
  109685. radiusX?: number;
  109686. radiusY?: number;
  109687. radiusZ?: number;
  109688. flat?: boolean;
  109689. subdivisions?: number;
  109690. sideOrientation?: number;
  109691. frontUVs?: Vector4;
  109692. backUVs?: Vector4;
  109693. updatable?: boolean;
  109694. }, scene?: Nullable<Scene>): Mesh;
  109695. /**
  109696. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  109697. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  109698. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  109699. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  109700. * * 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
  109701. * * 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
  109702. * * 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
  109703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109705. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109706. * * 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
  109707. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  109708. * * 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
  109709. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  109710. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109711. * @param name defines the name of the mesh
  109712. * @param options defines the options used to create the mesh
  109713. * @param scene defines the hosting scene
  109714. * @returns the ribbon mesh
  109715. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  109716. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109717. */
  109718. static CreateRibbon(name: string, options: {
  109719. pathArray: Vector3[][];
  109720. closeArray?: boolean;
  109721. closePath?: boolean;
  109722. offset?: number;
  109723. updatable?: boolean;
  109724. sideOrientation?: number;
  109725. frontUVs?: Vector4;
  109726. backUVs?: Vector4;
  109727. instance?: Mesh;
  109728. invertUV?: boolean;
  109729. uvs?: Vector2[];
  109730. colors?: Color4[];
  109731. }, scene?: Nullable<Scene>): Mesh;
  109732. /**
  109733. * Creates a cylinder or a cone mesh
  109734. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  109735. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  109736. * * 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.
  109737. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  109738. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  109739. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  109740. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  109741. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  109742. * * 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).
  109743. * * 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
  109744. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  109745. * * 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
  109746. * * 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.
  109747. * * If `enclose` is false, a ring surface is one element.
  109748. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  109749. * * 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
  109750. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109751. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109752. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109753. * @param name defines the name of the mesh
  109754. * @param options defines the options used to create the mesh
  109755. * @param scene defines the hosting scene
  109756. * @returns the cylinder mesh
  109757. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  109758. */
  109759. static CreateCylinder(name: string, options: {
  109760. height?: number;
  109761. diameterTop?: number;
  109762. diameterBottom?: number;
  109763. diameter?: number;
  109764. tessellation?: number;
  109765. subdivisions?: number;
  109766. arc?: number;
  109767. faceColors?: Color4[];
  109768. faceUV?: Vector4[];
  109769. updatable?: boolean;
  109770. hasRings?: boolean;
  109771. enclose?: boolean;
  109772. sideOrientation?: number;
  109773. frontUVs?: Vector4;
  109774. backUVs?: Vector4;
  109775. }, scene?: Nullable<Scene>): Mesh;
  109776. /**
  109777. * Creates a torus mesh
  109778. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  109779. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  109780. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  109781. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109782. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109783. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109784. * @param name defines the name of the mesh
  109785. * @param options defines the options used to create the mesh
  109786. * @param scene defines the hosting scene
  109787. * @returns the torus mesh
  109788. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  109789. */
  109790. static CreateTorus(name: string, options: {
  109791. diameter?: number;
  109792. thickness?: number;
  109793. tessellation?: number;
  109794. updatable?: boolean;
  109795. sideOrientation?: number;
  109796. frontUVs?: Vector4;
  109797. backUVs?: Vector4;
  109798. }, scene?: Nullable<Scene>): Mesh;
  109799. /**
  109800. * Creates a torus knot mesh
  109801. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  109802. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  109803. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  109804. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  109805. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109806. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109807. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109808. * @param name defines the name of the mesh
  109809. * @param options defines the options used to create the mesh
  109810. * @param scene defines the hosting scene
  109811. * @returns the torus knot mesh
  109812. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  109813. */
  109814. static CreateTorusKnot(name: string, options: {
  109815. radius?: number;
  109816. tube?: number;
  109817. radialSegments?: number;
  109818. tubularSegments?: number;
  109819. p?: number;
  109820. q?: number;
  109821. updatable?: boolean;
  109822. sideOrientation?: number;
  109823. frontUVs?: Vector4;
  109824. backUVs?: Vector4;
  109825. }, scene?: Nullable<Scene>): Mesh;
  109826. /**
  109827. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  109828. * * 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
  109829. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  109830. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  109831. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  109832. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  109833. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  109834. * * 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
  109835. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  109836. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109837. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  109838. * @param name defines the name of the new line system
  109839. * @param options defines the options used to create the line system
  109840. * @param scene defines the hosting scene
  109841. * @returns a new line system mesh
  109842. */
  109843. static CreateLineSystem(name: string, options: {
  109844. lines: Vector3[][];
  109845. updatable?: boolean;
  109846. instance?: Nullable<LinesMesh>;
  109847. colors?: Nullable<Color4[][]>;
  109848. useVertexAlpha?: boolean;
  109849. }, scene: Nullable<Scene>): LinesMesh;
  109850. /**
  109851. * Creates a line mesh
  109852. * 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
  109853. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109854. * * The parameter `points` is an array successive Vector3
  109855. * * 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
  109856. * * The optional parameter `colors` is an array of successive Color4, one per line point
  109857. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  109858. * * When updating an instance, remember that only point positions can change, not the number of points
  109859. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109860. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  109861. * @param name defines the name of the new line system
  109862. * @param options defines the options used to create the line system
  109863. * @param scene defines the hosting scene
  109864. * @returns a new line mesh
  109865. */
  109866. static CreateLines(name: string, options: {
  109867. points: Vector3[];
  109868. updatable?: boolean;
  109869. instance?: Nullable<LinesMesh>;
  109870. colors?: Color4[];
  109871. useVertexAlpha?: boolean;
  109872. }, scene?: Nullable<Scene>): LinesMesh;
  109873. /**
  109874. * Creates a dashed line mesh
  109875. * * 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
  109876. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  109877. * * The parameter `points` is an array successive Vector3
  109878. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  109879. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  109880. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109881. * * 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
  109882. * * When updating an instance, remember that only point positions can change, not the number of points
  109883. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109884. * @param name defines the name of the mesh
  109885. * @param options defines the options used to create the mesh
  109886. * @param scene defines the hosting scene
  109887. * @returns the dashed line mesh
  109888. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  109889. */
  109890. static CreateDashedLines(name: string, options: {
  109891. points: Vector3[];
  109892. dashSize?: number;
  109893. gapSize?: number;
  109894. dashNb?: number;
  109895. updatable?: boolean;
  109896. instance?: LinesMesh;
  109897. }, scene?: Nullable<Scene>): LinesMesh;
  109898. /**
  109899. * 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.
  109900. * * 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.
  109901. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109902. * * 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.
  109903. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  109904. * * 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
  109905. * * 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
  109906. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  109907. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109908. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109909. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  109910. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109911. * @param name defines the name of the mesh
  109912. * @param options defines the options used to create the mesh
  109913. * @param scene defines the hosting scene
  109914. * @returns the extruded shape mesh
  109915. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109916. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109917. */
  109918. static ExtrudeShape(name: string, options: {
  109919. shape: Vector3[];
  109920. path: Vector3[];
  109921. scale?: number;
  109922. rotation?: number;
  109923. cap?: number;
  109924. updatable?: boolean;
  109925. sideOrientation?: number;
  109926. frontUVs?: Vector4;
  109927. backUVs?: Vector4;
  109928. instance?: Mesh;
  109929. invertUV?: boolean;
  109930. }, scene?: Nullable<Scene>): Mesh;
  109931. /**
  109932. * Creates an custom extruded shape mesh.
  109933. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  109934. * * 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.
  109935. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  109936. * * 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
  109937. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  109938. * * 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
  109939. * * It must returns a float value that will be the scale value applied to the shape on each path point
  109940. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109941. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  109942. * * 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
  109943. * * 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
  109944. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  109945. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109946. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109947. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109948. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109949. * @param name defines the name of the mesh
  109950. * @param options defines the options used to create the mesh
  109951. * @param scene defines the hosting scene
  109952. * @returns the custom extruded shape mesh
  109953. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  109954. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109955. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109956. */
  109957. static ExtrudeShapeCustom(name: string, options: {
  109958. shape: Vector3[];
  109959. path: Vector3[];
  109960. scaleFunction?: any;
  109961. rotationFunction?: any;
  109962. ribbonCloseArray?: boolean;
  109963. ribbonClosePath?: boolean;
  109964. cap?: number;
  109965. updatable?: boolean;
  109966. sideOrientation?: number;
  109967. frontUVs?: Vector4;
  109968. backUVs?: Vector4;
  109969. instance?: Mesh;
  109970. invertUV?: boolean;
  109971. }, scene?: Nullable<Scene>): Mesh;
  109972. /**
  109973. * Creates lathe mesh.
  109974. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  109975. * * 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
  109976. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  109977. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  109978. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  109979. * * 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
  109980. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  109981. * * 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
  109982. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  109983. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109984. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  109985. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109986. * @param name defines the name of the mesh
  109987. * @param options defines the options used to create the mesh
  109988. * @param scene defines the hosting scene
  109989. * @returns the lathe mesh
  109990. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  109991. */
  109992. static CreateLathe(name: string, options: {
  109993. shape: Vector3[];
  109994. radius?: number;
  109995. tessellation?: number;
  109996. clip?: number;
  109997. arc?: number;
  109998. closed?: boolean;
  109999. updatable?: boolean;
  110000. sideOrientation?: number;
  110001. frontUVs?: Vector4;
  110002. backUVs?: Vector4;
  110003. cap?: number;
  110004. invertUV?: boolean;
  110005. }, scene?: Nullable<Scene>): Mesh;
  110006. /**
  110007. * Creates a plane mesh
  110008. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  110009. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  110010. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  110011. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110012. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110013. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110014. * @param name defines the name of the mesh
  110015. * @param options defines the options used to create the mesh
  110016. * @param scene defines the hosting scene
  110017. * @returns the plane mesh
  110018. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  110019. */
  110020. static CreatePlane(name: string, options: {
  110021. size?: number;
  110022. width?: number;
  110023. height?: number;
  110024. sideOrientation?: number;
  110025. frontUVs?: Vector4;
  110026. backUVs?: Vector4;
  110027. updatable?: boolean;
  110028. sourcePlane?: Plane;
  110029. }, scene?: Nullable<Scene>): Mesh;
  110030. /**
  110031. * Creates a ground mesh
  110032. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  110033. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  110034. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110035. * @param name defines the name of the mesh
  110036. * @param options defines the options used to create the mesh
  110037. * @param scene defines the hosting scene
  110038. * @returns the ground mesh
  110039. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  110040. */
  110041. static CreateGround(name: string, options: {
  110042. width?: number;
  110043. height?: number;
  110044. subdivisions?: number;
  110045. subdivisionsX?: number;
  110046. subdivisionsY?: number;
  110047. updatable?: boolean;
  110048. }, scene?: Nullable<Scene>): Mesh;
  110049. /**
  110050. * Creates a tiled ground mesh
  110051. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  110052. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  110053. * * 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
  110054. * * 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
  110055. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110056. * @param name defines the name of the mesh
  110057. * @param options defines the options used to create the mesh
  110058. * @param scene defines the hosting scene
  110059. * @returns the tiled ground mesh
  110060. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  110061. */
  110062. static CreateTiledGround(name: string, options: {
  110063. xmin: number;
  110064. zmin: number;
  110065. xmax: number;
  110066. zmax: number;
  110067. subdivisions?: {
  110068. w: number;
  110069. h: number;
  110070. };
  110071. precision?: {
  110072. w: number;
  110073. h: number;
  110074. };
  110075. updatable?: boolean;
  110076. }, scene?: Nullable<Scene>): Mesh;
  110077. /**
  110078. * Creates a ground mesh from a height map
  110079. * * The parameter `url` sets the URL of the height map image resource.
  110080. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  110081. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  110082. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  110083. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  110084. * * 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.
  110085. * * 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).
  110086. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  110087. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  110088. * @param name defines the name of the mesh
  110089. * @param url defines the url to the height map
  110090. * @param options defines the options used to create the mesh
  110091. * @param scene defines the hosting scene
  110092. * @returns the ground mesh
  110093. * @see https://doc.babylonjs.com/babylon101/height_map
  110094. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  110095. */
  110096. static CreateGroundFromHeightMap(name: string, url: string, options: {
  110097. width?: number;
  110098. height?: number;
  110099. subdivisions?: number;
  110100. minHeight?: number;
  110101. maxHeight?: number;
  110102. colorFilter?: Color3;
  110103. alphaFilter?: number;
  110104. updatable?: boolean;
  110105. onReady?: (mesh: GroundMesh) => void;
  110106. }, scene?: Nullable<Scene>): GroundMesh;
  110107. /**
  110108. * Creates a polygon mesh
  110109. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  110110. * * 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
  110111. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  110112. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110113. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  110114. * * Remember you can only change the shape positions, not their number when updating a polygon
  110115. * @param name defines the name of the mesh
  110116. * @param options defines the options used to create the mesh
  110117. * @param scene defines the hosting scene
  110118. * @param earcutInjection can be used to inject your own earcut reference
  110119. * @returns the polygon mesh
  110120. */
  110121. static CreatePolygon(name: string, options: {
  110122. shape: Vector3[];
  110123. holes?: Vector3[][];
  110124. depth?: number;
  110125. faceUV?: Vector4[];
  110126. faceColors?: Color4[];
  110127. updatable?: boolean;
  110128. sideOrientation?: number;
  110129. frontUVs?: Vector4;
  110130. backUVs?: Vector4;
  110131. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110132. /**
  110133. * Creates an extruded polygon mesh, with depth in the Y direction.
  110134. * * 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)
  110135. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  110136. * @param name defines the name of the mesh
  110137. * @param options defines the options used to create the mesh
  110138. * @param scene defines the hosting scene
  110139. * @param earcutInjection can be used to inject your own earcut reference
  110140. * @returns the polygon mesh
  110141. */
  110142. static ExtrudePolygon(name: string, options: {
  110143. shape: Vector3[];
  110144. holes?: Vector3[][];
  110145. depth?: number;
  110146. faceUV?: Vector4[];
  110147. faceColors?: Color4[];
  110148. updatable?: boolean;
  110149. sideOrientation?: number;
  110150. frontUVs?: Vector4;
  110151. backUVs?: Vector4;
  110152. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  110153. /**
  110154. * Creates a tube mesh.
  110155. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  110156. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  110157. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  110158. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  110159. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  110160. * * 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)
  110161. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  110162. * * 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
  110163. * * 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
  110164. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110165. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110166. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  110167. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110168. * @param name defines the name of the mesh
  110169. * @param options defines the options used to create the mesh
  110170. * @param scene defines the hosting scene
  110171. * @returns the tube mesh
  110172. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  110173. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  110174. */
  110175. static CreateTube(name: string, options: {
  110176. path: Vector3[];
  110177. radius?: number;
  110178. tessellation?: number;
  110179. radiusFunction?: {
  110180. (i: number, distance: number): number;
  110181. };
  110182. cap?: number;
  110183. arc?: number;
  110184. updatable?: boolean;
  110185. sideOrientation?: number;
  110186. frontUVs?: Vector4;
  110187. backUVs?: Vector4;
  110188. instance?: Mesh;
  110189. invertUV?: boolean;
  110190. }, scene?: Nullable<Scene>): Mesh;
  110191. /**
  110192. * Creates a polyhedron mesh
  110193. * * 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
  110194. * * The parameter `size` (positive float, default 1) sets the polygon size
  110195. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  110196. * * 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`
  110197. * * 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
  110198. * * 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)`)
  110199. * * 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
  110200. * * 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
  110201. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110202. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110203. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110204. * @param name defines the name of the mesh
  110205. * @param options defines the options used to create the mesh
  110206. * @param scene defines the hosting scene
  110207. * @returns the polyhedron mesh
  110208. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  110209. */
  110210. static CreatePolyhedron(name: string, options: {
  110211. type?: number;
  110212. size?: number;
  110213. sizeX?: number;
  110214. sizeY?: number;
  110215. sizeZ?: number;
  110216. custom?: any;
  110217. faceUV?: Vector4[];
  110218. faceColors?: Color4[];
  110219. flat?: boolean;
  110220. updatable?: boolean;
  110221. sideOrientation?: number;
  110222. frontUVs?: Vector4;
  110223. backUVs?: Vector4;
  110224. }, scene?: Nullable<Scene>): Mesh;
  110225. /**
  110226. * Creates a decal mesh.
  110227. * 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
  110228. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  110229. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  110230. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  110231. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  110232. * @param name defines the name of the mesh
  110233. * @param sourceMesh defines the mesh where the decal must be applied
  110234. * @param options defines the options used to create the mesh
  110235. * @param scene defines the hosting scene
  110236. * @returns the decal mesh
  110237. * @see https://doc.babylonjs.com/how_to/decals
  110238. */
  110239. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  110240. position?: Vector3;
  110241. normal?: Vector3;
  110242. size?: Vector3;
  110243. angle?: number;
  110244. }): Mesh;
  110245. }
  110246. }
  110247. declare module BABYLON {
  110248. /**
  110249. * A simplifier interface for future simplification implementations
  110250. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110251. */
  110252. export interface ISimplifier {
  110253. /**
  110254. * Simplification of a given mesh according to the given settings.
  110255. * Since this requires computation, it is assumed that the function runs async.
  110256. * @param settings The settings of the simplification, including quality and distance
  110257. * @param successCallback A callback that will be called after the mesh was simplified.
  110258. * @param errorCallback in case of an error, this callback will be called. optional.
  110259. */
  110260. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  110261. }
  110262. /**
  110263. * Expected simplification settings.
  110264. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  110265. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110266. */
  110267. export interface ISimplificationSettings {
  110268. /**
  110269. * Gets or sets the expected quality
  110270. */
  110271. quality: number;
  110272. /**
  110273. * Gets or sets the distance when this optimized version should be used
  110274. */
  110275. distance: number;
  110276. /**
  110277. * Gets an already optimized mesh
  110278. */
  110279. optimizeMesh?: boolean;
  110280. }
  110281. /**
  110282. * Class used to specify simplification options
  110283. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110284. */
  110285. export class SimplificationSettings implements ISimplificationSettings {
  110286. /** expected quality */
  110287. quality: number;
  110288. /** distance when this optimized version should be used */
  110289. distance: number;
  110290. /** already optimized mesh */
  110291. optimizeMesh?: boolean | undefined;
  110292. /**
  110293. * Creates a SimplificationSettings
  110294. * @param quality expected quality
  110295. * @param distance distance when this optimized version should be used
  110296. * @param optimizeMesh already optimized mesh
  110297. */
  110298. constructor(
  110299. /** expected quality */
  110300. quality: number,
  110301. /** distance when this optimized version should be used */
  110302. distance: number,
  110303. /** already optimized mesh */
  110304. optimizeMesh?: boolean | undefined);
  110305. }
  110306. /**
  110307. * Interface used to define a simplification task
  110308. */
  110309. export interface ISimplificationTask {
  110310. /**
  110311. * Array of settings
  110312. */
  110313. settings: Array<ISimplificationSettings>;
  110314. /**
  110315. * Simplification type
  110316. */
  110317. simplificationType: SimplificationType;
  110318. /**
  110319. * Mesh to simplify
  110320. */
  110321. mesh: Mesh;
  110322. /**
  110323. * Callback called on success
  110324. */
  110325. successCallback?: () => void;
  110326. /**
  110327. * Defines if parallel processing can be used
  110328. */
  110329. parallelProcessing: boolean;
  110330. }
  110331. /**
  110332. * Queue used to order the simplification tasks
  110333. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110334. */
  110335. export class SimplificationQueue {
  110336. private _simplificationArray;
  110337. /**
  110338. * Gets a boolean indicating that the process is still running
  110339. */
  110340. running: boolean;
  110341. /**
  110342. * Creates a new queue
  110343. */
  110344. constructor();
  110345. /**
  110346. * Adds a new simplification task
  110347. * @param task defines a task to add
  110348. */
  110349. addTask(task: ISimplificationTask): void;
  110350. /**
  110351. * Execute next task
  110352. */
  110353. executeNext(): void;
  110354. /**
  110355. * Execute a simplification task
  110356. * @param task defines the task to run
  110357. */
  110358. runSimplification(task: ISimplificationTask): void;
  110359. private getSimplifier;
  110360. }
  110361. /**
  110362. * The implemented types of simplification
  110363. * At the moment only Quadratic Error Decimation is implemented
  110364. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110365. */
  110366. export enum SimplificationType {
  110367. /** Quadratic error decimation */
  110368. QUADRATIC = 0
  110369. }
  110370. }
  110371. declare module BABYLON {
  110372. interface Scene {
  110373. /** @hidden (Backing field) */
  110374. _simplificationQueue: SimplificationQueue;
  110375. /**
  110376. * Gets or sets the simplification queue attached to the scene
  110377. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  110378. */
  110379. simplificationQueue: SimplificationQueue;
  110380. }
  110381. interface Mesh {
  110382. /**
  110383. * Simplify the mesh according to the given array of settings.
  110384. * Function will return immediately and will simplify async
  110385. * @param settings a collection of simplification settings
  110386. * @param parallelProcessing should all levels calculate parallel or one after the other
  110387. * @param simplificationType the type of simplification to run
  110388. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  110389. * @returns the current mesh
  110390. */
  110391. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  110392. }
  110393. /**
  110394. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  110395. * created in a scene
  110396. */
  110397. export class SimplicationQueueSceneComponent implements ISceneComponent {
  110398. /**
  110399. * The component name helpfull to identify the component in the list of scene components.
  110400. */
  110401. readonly name: string;
  110402. /**
  110403. * The scene the component belongs to.
  110404. */
  110405. scene: Scene;
  110406. /**
  110407. * Creates a new instance of the component for the given scene
  110408. * @param scene Defines the scene to register the component in
  110409. */
  110410. constructor(scene: Scene);
  110411. /**
  110412. * Registers the component in a given scene
  110413. */
  110414. register(): void;
  110415. /**
  110416. * Rebuilds the elements related to this component in case of
  110417. * context lost for instance.
  110418. */
  110419. rebuild(): void;
  110420. /**
  110421. * Disposes the component and the associated ressources
  110422. */
  110423. dispose(): void;
  110424. private _beforeCameraUpdate;
  110425. }
  110426. }
  110427. declare module BABYLON {
  110428. /**
  110429. * Class used to enable access to IndexedDB
  110430. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  110431. */
  110432. export class Database implements IOfflineProvider {
  110433. private _callbackManifestChecked;
  110434. private _currentSceneUrl;
  110435. private _db;
  110436. private _enableSceneOffline;
  110437. private _enableTexturesOffline;
  110438. private _manifestVersionFound;
  110439. private _mustUpdateRessources;
  110440. private _hasReachedQuota;
  110441. private _isSupported;
  110442. private _idbFactory;
  110443. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  110444. private static IsUASupportingBlobStorage;
  110445. /**
  110446. * Gets a boolean indicating if Database storate is enabled (off by default)
  110447. */
  110448. static IDBStorageEnabled: boolean;
  110449. /**
  110450. * Gets a boolean indicating if scene must be saved in the database
  110451. */
  110452. readonly enableSceneOffline: boolean;
  110453. /**
  110454. * Gets a boolean indicating if textures must be saved in the database
  110455. */
  110456. readonly enableTexturesOffline: boolean;
  110457. /**
  110458. * Creates a new Database
  110459. * @param urlToScene defines the url to load the scene
  110460. * @param callbackManifestChecked defines the callback to use when manifest is checked
  110461. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  110462. */
  110463. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  110464. private static _ParseURL;
  110465. private static _ReturnFullUrlLocation;
  110466. private _checkManifestFile;
  110467. /**
  110468. * Open the database and make it available
  110469. * @param successCallback defines the callback to call on success
  110470. * @param errorCallback defines the callback to call on error
  110471. */
  110472. open(successCallback: () => void, errorCallback: () => void): void;
  110473. /**
  110474. * Loads an image from the database
  110475. * @param url defines the url to load from
  110476. * @param image defines the target DOM image
  110477. */
  110478. loadImage(url: string, image: HTMLImageElement): void;
  110479. private _loadImageFromDBAsync;
  110480. private _saveImageIntoDBAsync;
  110481. private _checkVersionFromDB;
  110482. private _loadVersionFromDBAsync;
  110483. private _saveVersionIntoDBAsync;
  110484. /**
  110485. * Loads a file from database
  110486. * @param url defines the URL to load from
  110487. * @param sceneLoaded defines a callback to call on success
  110488. * @param progressCallBack defines a callback to call when progress changed
  110489. * @param errorCallback defines a callback to call on error
  110490. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  110491. */
  110492. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  110493. private _loadFileAsync;
  110494. private _saveFileAsync;
  110495. /**
  110496. * Validates if xhr data is correct
  110497. * @param xhr defines the request to validate
  110498. * @param dataType defines the expected data type
  110499. * @returns true if data is correct
  110500. */
  110501. private static _ValidateXHRData;
  110502. }
  110503. }
  110504. declare module BABYLON {
  110505. /** @hidden */
  110506. export var gpuUpdateParticlesPixelShader: {
  110507. name: string;
  110508. shader: string;
  110509. };
  110510. }
  110511. declare module BABYLON {
  110512. /** @hidden */
  110513. export var gpuUpdateParticlesVertexShader: {
  110514. name: string;
  110515. shader: string;
  110516. };
  110517. }
  110518. declare module BABYLON {
  110519. /** @hidden */
  110520. export var clipPlaneFragmentDeclaration2: {
  110521. name: string;
  110522. shader: string;
  110523. };
  110524. }
  110525. declare module BABYLON {
  110526. /** @hidden */
  110527. export var gpuRenderParticlesPixelShader: {
  110528. name: string;
  110529. shader: string;
  110530. };
  110531. }
  110532. declare module BABYLON {
  110533. /** @hidden */
  110534. export var clipPlaneVertexDeclaration2: {
  110535. name: string;
  110536. shader: string;
  110537. };
  110538. }
  110539. declare module BABYLON {
  110540. /** @hidden */
  110541. export var gpuRenderParticlesVertexShader: {
  110542. name: string;
  110543. shader: string;
  110544. };
  110545. }
  110546. declare module BABYLON {
  110547. /**
  110548. * This represents a GPU particle system in Babylon
  110549. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  110550. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  110551. */
  110552. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  110553. /**
  110554. * The layer mask we are rendering the particles through.
  110555. */
  110556. layerMask: number;
  110557. private _capacity;
  110558. private _activeCount;
  110559. private _currentActiveCount;
  110560. private _accumulatedCount;
  110561. private _renderEffect;
  110562. private _updateEffect;
  110563. private _buffer0;
  110564. private _buffer1;
  110565. private _spriteBuffer;
  110566. private _updateVAO;
  110567. private _renderVAO;
  110568. private _targetIndex;
  110569. private _sourceBuffer;
  110570. private _targetBuffer;
  110571. private _engine;
  110572. private _currentRenderId;
  110573. private _started;
  110574. private _stopped;
  110575. private _timeDelta;
  110576. private _randomTexture;
  110577. private _randomTexture2;
  110578. private _attributesStrideSize;
  110579. private _updateEffectOptions;
  110580. private _randomTextureSize;
  110581. private _actualFrame;
  110582. private readonly _rawTextureWidth;
  110583. /**
  110584. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  110585. */
  110586. static readonly IsSupported: boolean;
  110587. /**
  110588. * An event triggered when the system is disposed.
  110589. */
  110590. onDisposeObservable: Observable<GPUParticleSystem>;
  110591. /**
  110592. * Gets the maximum number of particles active at the same time.
  110593. * @returns The max number of active particles.
  110594. */
  110595. getCapacity(): number;
  110596. /**
  110597. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  110598. * to override the particles.
  110599. */
  110600. forceDepthWrite: boolean;
  110601. /**
  110602. * Gets or set the number of active particles
  110603. */
  110604. activeParticleCount: number;
  110605. private _preWarmDone;
  110606. /**
  110607. * Is this system ready to be used/rendered
  110608. * @return true if the system is ready
  110609. */
  110610. isReady(): boolean;
  110611. /**
  110612. * Gets if the system has been started. (Note: this will still be true after stop is called)
  110613. * @returns True if it has been started, otherwise false.
  110614. */
  110615. isStarted(): boolean;
  110616. /**
  110617. * Starts the particle system and begins to emit
  110618. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  110619. */
  110620. start(delay?: number): void;
  110621. /**
  110622. * Stops the particle system.
  110623. */
  110624. stop(): void;
  110625. /**
  110626. * Remove all active particles
  110627. */
  110628. reset(): void;
  110629. /**
  110630. * Returns the string "GPUParticleSystem"
  110631. * @returns a string containing the class name
  110632. */
  110633. getClassName(): string;
  110634. private _colorGradientsTexture;
  110635. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  110636. /**
  110637. * Adds a new color gradient
  110638. * @param gradient defines the gradient to use (between 0 and 1)
  110639. * @param color1 defines the color to affect to the specified gradient
  110640. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  110641. * @returns the current particle system
  110642. */
  110643. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  110644. /**
  110645. * Remove a specific color gradient
  110646. * @param gradient defines the gradient to remove
  110647. * @returns the current particle system
  110648. */
  110649. removeColorGradient(gradient: number): GPUParticleSystem;
  110650. private _angularSpeedGradientsTexture;
  110651. private _sizeGradientsTexture;
  110652. private _velocityGradientsTexture;
  110653. private _limitVelocityGradientsTexture;
  110654. private _dragGradientsTexture;
  110655. private _addFactorGradient;
  110656. /**
  110657. * Adds a new size gradient
  110658. * @param gradient defines the gradient to use (between 0 and 1)
  110659. * @param factor defines the size factor to affect to the specified gradient
  110660. * @returns the current particle system
  110661. */
  110662. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  110663. /**
  110664. * Remove a specific size gradient
  110665. * @param gradient defines the gradient to remove
  110666. * @returns the current particle system
  110667. */
  110668. removeSizeGradient(gradient: number): GPUParticleSystem;
  110669. /**
  110670. * Adds a new angular speed gradient
  110671. * @param gradient defines the gradient to use (between 0 and 1)
  110672. * @param factor defines the angular speed to affect to the specified gradient
  110673. * @returns the current particle system
  110674. */
  110675. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  110676. /**
  110677. * Remove a specific angular speed gradient
  110678. * @param gradient defines the gradient to remove
  110679. * @returns the current particle system
  110680. */
  110681. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  110682. /**
  110683. * Adds a new velocity gradient
  110684. * @param gradient defines the gradient to use (between 0 and 1)
  110685. * @param factor defines the velocity to affect to the specified gradient
  110686. * @returns the current particle system
  110687. */
  110688. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110689. /**
  110690. * Remove a specific velocity gradient
  110691. * @param gradient defines the gradient to remove
  110692. * @returns the current particle system
  110693. */
  110694. removeVelocityGradient(gradient: number): GPUParticleSystem;
  110695. /**
  110696. * Adds a new limit velocity gradient
  110697. * @param gradient defines the gradient to use (between 0 and 1)
  110698. * @param factor defines the limit velocity value to affect to the specified gradient
  110699. * @returns the current particle system
  110700. */
  110701. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  110702. /**
  110703. * Remove a specific limit velocity gradient
  110704. * @param gradient defines the gradient to remove
  110705. * @returns the current particle system
  110706. */
  110707. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  110708. /**
  110709. * Adds a new drag gradient
  110710. * @param gradient defines the gradient to use (between 0 and 1)
  110711. * @param factor defines the drag value to affect to the specified gradient
  110712. * @returns the current particle system
  110713. */
  110714. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  110715. /**
  110716. * Remove a specific drag gradient
  110717. * @param gradient defines the gradient to remove
  110718. * @returns the current particle system
  110719. */
  110720. removeDragGradient(gradient: number): GPUParticleSystem;
  110721. /**
  110722. * Not supported by GPUParticleSystem
  110723. * @param gradient defines the gradient to use (between 0 and 1)
  110724. * @param factor defines the emit rate value to affect to the specified gradient
  110725. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110726. * @returns the current particle system
  110727. */
  110728. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110729. /**
  110730. * Not supported by GPUParticleSystem
  110731. * @param gradient defines the gradient to remove
  110732. * @returns the current particle system
  110733. */
  110734. removeEmitRateGradient(gradient: number): IParticleSystem;
  110735. /**
  110736. * Not supported by GPUParticleSystem
  110737. * @param gradient defines the gradient to use (between 0 and 1)
  110738. * @param factor defines the start size value to affect to the specified gradient
  110739. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110740. * @returns the current particle system
  110741. */
  110742. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110743. /**
  110744. * Not supported by GPUParticleSystem
  110745. * @param gradient defines the gradient to remove
  110746. * @returns the current particle system
  110747. */
  110748. removeStartSizeGradient(gradient: number): IParticleSystem;
  110749. /**
  110750. * Not supported by GPUParticleSystem
  110751. * @param gradient defines the gradient to use (between 0 and 1)
  110752. * @param min defines the color remap minimal range
  110753. * @param max defines the color remap maximal range
  110754. * @returns the current particle system
  110755. */
  110756. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110757. /**
  110758. * Not supported by GPUParticleSystem
  110759. * @param gradient defines the gradient to remove
  110760. * @returns the current particle system
  110761. */
  110762. removeColorRemapGradient(): IParticleSystem;
  110763. /**
  110764. * Not supported by GPUParticleSystem
  110765. * @param gradient defines the gradient to use (between 0 and 1)
  110766. * @param min defines the alpha remap minimal range
  110767. * @param max defines the alpha remap maximal range
  110768. * @returns the current particle system
  110769. */
  110770. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  110771. /**
  110772. * Not supported by GPUParticleSystem
  110773. * @param gradient defines the gradient to remove
  110774. * @returns the current particle system
  110775. */
  110776. removeAlphaRemapGradient(): IParticleSystem;
  110777. /**
  110778. * Not supported by GPUParticleSystem
  110779. * @param gradient defines the gradient to use (between 0 and 1)
  110780. * @param color defines the color to affect to the specified gradient
  110781. * @returns the current particle system
  110782. */
  110783. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  110784. /**
  110785. * Not supported by GPUParticleSystem
  110786. * @param gradient defines the gradient to remove
  110787. * @returns the current particle system
  110788. */
  110789. removeRampGradient(): IParticleSystem;
  110790. /**
  110791. * Not supported by GPUParticleSystem
  110792. * @returns the list of ramp gradients
  110793. */
  110794. getRampGradients(): Nullable<Array<Color3Gradient>>;
  110795. /**
  110796. * Not supported by GPUParticleSystem
  110797. * Gets or sets a boolean indicating that ramp gradients must be used
  110798. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  110799. */
  110800. useRampGradients: boolean;
  110801. /**
  110802. * Not supported by GPUParticleSystem
  110803. * @param gradient defines the gradient to use (between 0 and 1)
  110804. * @param factor defines the life time factor to affect to the specified gradient
  110805. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  110806. * @returns the current particle system
  110807. */
  110808. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  110809. /**
  110810. * Not supported by GPUParticleSystem
  110811. * @param gradient defines the gradient to remove
  110812. * @returns the current particle system
  110813. */
  110814. removeLifeTimeGradient(gradient: number): IParticleSystem;
  110815. /**
  110816. * Instantiates a GPU particle system.
  110817. * 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.
  110818. * @param name The name of the particle system
  110819. * @param options The options used to create the system
  110820. * @param scene The scene the particle system belongs to
  110821. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  110822. */
  110823. constructor(name: string, options: Partial<{
  110824. capacity: number;
  110825. randomTextureSize: number;
  110826. }>, scene: Scene, isAnimationSheetEnabled?: boolean);
  110827. protected _reset(): void;
  110828. private _createUpdateVAO;
  110829. private _createRenderVAO;
  110830. private _initialize;
  110831. /** @hidden */
  110832. _recreateUpdateEffect(): void;
  110833. /** @hidden */
  110834. _recreateRenderEffect(): void;
  110835. /**
  110836. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  110837. * @param preWarm defines if we are in the pre-warmimg phase
  110838. */
  110839. animate(preWarm?: boolean): void;
  110840. private _createFactorGradientTexture;
  110841. private _createSizeGradientTexture;
  110842. private _createAngularSpeedGradientTexture;
  110843. private _createVelocityGradientTexture;
  110844. private _createLimitVelocityGradientTexture;
  110845. private _createDragGradientTexture;
  110846. private _createColorGradientTexture;
  110847. /**
  110848. * Renders the particle system in its current state
  110849. * @param preWarm defines if the system should only update the particles but not render them
  110850. * @returns the current number of particles
  110851. */
  110852. render(preWarm?: boolean): number;
  110853. /**
  110854. * Rebuilds the particle system
  110855. */
  110856. rebuild(): void;
  110857. private _releaseBuffers;
  110858. private _releaseVAOs;
  110859. /**
  110860. * Disposes the particle system and free the associated resources
  110861. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  110862. */
  110863. dispose(disposeTexture?: boolean): void;
  110864. /**
  110865. * Clones the particle system.
  110866. * @param name The name of the cloned object
  110867. * @param newEmitter The new emitter to use
  110868. * @returns the cloned particle system
  110869. */
  110870. clone(name: string, newEmitter: any): GPUParticleSystem;
  110871. /**
  110872. * Serializes the particle system to a JSON object.
  110873. * @returns the JSON object
  110874. */
  110875. serialize(): any;
  110876. /**
  110877. * Parses a JSON object to create a GPU particle system.
  110878. * @param parsedParticleSystem The JSON object to parse
  110879. * @param scene The scene to create the particle system in
  110880. * @param rootUrl The root url to use to load external dependencies like texture
  110881. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  110882. * @returns the parsed GPU particle system
  110883. */
  110884. static Parse(parsedParticleSystem: any, scene: Scene, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  110885. }
  110886. }
  110887. declare module BABYLON {
  110888. /**
  110889. * Represents a set of particle systems working together to create a specific effect
  110890. */
  110891. export class ParticleSystemSet implements IDisposable {
  110892. private _emitterCreationOptions;
  110893. private _emitterNode;
  110894. /**
  110895. * Gets the particle system list
  110896. */
  110897. systems: IParticleSystem[];
  110898. /**
  110899. * Gets the emitter node used with this set
  110900. */
  110901. readonly emitterNode: Nullable<TransformNode>;
  110902. /**
  110903. * Creates a new emitter mesh as a sphere
  110904. * @param options defines the options used to create the sphere
  110905. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  110906. * @param scene defines the hosting scene
  110907. */
  110908. setEmitterAsSphere(options: {
  110909. diameter: number;
  110910. segments: number;
  110911. color: Color3;
  110912. }, renderingGroupId: number, scene: Scene): void;
  110913. /**
  110914. * Starts all particle systems of the set
  110915. * @param emitter defines an optional mesh to use as emitter for the particle systems
  110916. */
  110917. start(emitter?: AbstractMesh): void;
  110918. /**
  110919. * Release all associated resources
  110920. */
  110921. dispose(): void;
  110922. /**
  110923. * Serialize the set into a JSON compatible object
  110924. * @returns a JSON compatible representation of the set
  110925. */
  110926. serialize(): any;
  110927. /**
  110928. * Parse a new ParticleSystemSet from a serialized source
  110929. * @param data defines a JSON compatible representation of the set
  110930. * @param scene defines the hosting scene
  110931. * @param gpu defines if we want GPU particles or CPU particles
  110932. * @returns a new ParticleSystemSet
  110933. */
  110934. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  110935. }
  110936. }
  110937. declare module BABYLON {
  110938. /**
  110939. * This class is made for on one-liner static method to help creating particle system set.
  110940. */
  110941. export class ParticleHelper {
  110942. /**
  110943. * Gets or sets base Assets URL
  110944. */
  110945. static BaseAssetsUrl: string;
  110946. /**
  110947. * Create a default particle system that you can tweak
  110948. * @param emitter defines the emitter to use
  110949. * @param capacity defines the system capacity (default is 500 particles)
  110950. * @param scene defines the hosting scene
  110951. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  110952. * @returns the new Particle system
  110953. */
  110954. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  110955. /**
  110956. * This is the main static method (one-liner) of this helper to create different particle systems
  110957. * @param type This string represents the type to the particle system to create
  110958. * @param scene The scene where the particle system should live
  110959. * @param gpu If the system will use gpu
  110960. * @returns the ParticleSystemSet created
  110961. */
  110962. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  110963. /**
  110964. * Static function used to export a particle system to a ParticleSystemSet variable.
  110965. * Please note that the emitter shape is not exported
  110966. * @param systems defines the particle systems to export
  110967. * @returns the created particle system set
  110968. */
  110969. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  110970. }
  110971. }
  110972. declare module BABYLON {
  110973. interface Engine {
  110974. /**
  110975. * Create an effect to use with particle systems.
  110976. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration
  110977. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  110978. * @param uniformsNames defines a list of attribute names
  110979. * @param samplers defines an array of string used to represent textures
  110980. * @param defines defines the string containing the defines to use to compile the shaders
  110981. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  110982. * @param onCompiled defines a function to call when the effect creation is successful
  110983. * @param onError defines a function to call when the effect creation has failed
  110984. * @returns the new Effect
  110985. */
  110986. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): Effect;
  110987. }
  110988. interface Mesh {
  110989. /**
  110990. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  110991. * @returns an array of IParticleSystem
  110992. */
  110993. getEmittedParticleSystems(): IParticleSystem[];
  110994. /**
  110995. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  110996. * @returns an array of IParticleSystem
  110997. */
  110998. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  110999. }
  111000. /**
  111001. * @hidden
  111002. */
  111003. export var _IDoNeedToBeInTheBuild: number;
  111004. }
  111005. declare module BABYLON {
  111006. interface Scene {
  111007. /** @hidden (Backing field) */
  111008. _physicsEngine: Nullable<IPhysicsEngine>;
  111009. /**
  111010. * Gets the current physics engine
  111011. * @returns a IPhysicsEngine or null if none attached
  111012. */
  111013. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  111014. /**
  111015. * Enables physics to the current scene
  111016. * @param gravity defines the scene's gravity for the physics engine
  111017. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111018. * @return a boolean indicating if the physics engine was initialized
  111019. */
  111020. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  111021. /**
  111022. * Disables and disposes the physics engine associated with the scene
  111023. */
  111024. disablePhysicsEngine(): void;
  111025. /**
  111026. * Gets a boolean indicating if there is an active physics engine
  111027. * @returns a boolean indicating if there is an active physics engine
  111028. */
  111029. isPhysicsEnabled(): boolean;
  111030. /**
  111031. * Deletes a physics compound impostor
  111032. * @param compound defines the compound to delete
  111033. */
  111034. deleteCompoundImpostor(compound: any): void;
  111035. /**
  111036. * An event triggered when physic simulation is about to be run
  111037. */
  111038. onBeforePhysicsObservable: Observable<Scene>;
  111039. /**
  111040. * An event triggered when physic simulation has been done
  111041. */
  111042. onAfterPhysicsObservable: Observable<Scene>;
  111043. }
  111044. interface AbstractMesh {
  111045. /** @hidden */
  111046. _physicsImpostor: Nullable<PhysicsImpostor>;
  111047. /**
  111048. * Gets or sets impostor used for physic simulation
  111049. * @see http://doc.babylonjs.com/features/physics_engine
  111050. */
  111051. physicsImpostor: Nullable<PhysicsImpostor>;
  111052. /**
  111053. * Gets the current physics impostor
  111054. * @see http://doc.babylonjs.com/features/physics_engine
  111055. * @returns a physics impostor or null
  111056. */
  111057. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  111058. /** Apply a physic impulse to the mesh
  111059. * @param force defines the force to apply
  111060. * @param contactPoint defines where to apply the force
  111061. * @returns the current mesh
  111062. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111063. */
  111064. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  111065. /**
  111066. * Creates a physic joint between two meshes
  111067. * @param otherMesh defines the other mesh to use
  111068. * @param pivot1 defines the pivot to use on this mesh
  111069. * @param pivot2 defines the pivot to use on the other mesh
  111070. * @param options defines additional options (can be plugin dependent)
  111071. * @returns the current mesh
  111072. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111073. */
  111074. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  111075. /** @hidden */
  111076. _disposePhysicsObserver: Nullable<Observer<Node>>;
  111077. }
  111078. /**
  111079. * Defines the physics engine scene component responsible to manage a physics engine
  111080. */
  111081. export class PhysicsEngineSceneComponent implements ISceneComponent {
  111082. /**
  111083. * The component name helpful to identify the component in the list of scene components.
  111084. */
  111085. readonly name: string;
  111086. /**
  111087. * The scene the component belongs to.
  111088. */
  111089. scene: Scene;
  111090. /**
  111091. * Creates a new instance of the component for the given scene
  111092. * @param scene Defines the scene to register the component in
  111093. */
  111094. constructor(scene: Scene);
  111095. /**
  111096. * Registers the component in a given scene
  111097. */
  111098. register(): void;
  111099. /**
  111100. * Rebuilds the elements related to this component in case of
  111101. * context lost for instance.
  111102. */
  111103. rebuild(): void;
  111104. /**
  111105. * Disposes the component and the associated ressources
  111106. */
  111107. dispose(): void;
  111108. }
  111109. }
  111110. declare module BABYLON {
  111111. /**
  111112. * A helper for physics simulations
  111113. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111114. */
  111115. export class PhysicsHelper {
  111116. private _scene;
  111117. private _physicsEngine;
  111118. /**
  111119. * Initializes the Physics helper
  111120. * @param scene Babylon.js scene
  111121. */
  111122. constructor(scene: Scene);
  111123. /**
  111124. * Applies a radial explosion impulse
  111125. * @param origin the origin of the explosion
  111126. * @param radiusOrEventOptions the radius or the options of radial explosion
  111127. * @param strength the explosion strength
  111128. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111129. * @returns A physics radial explosion event, or null
  111130. */
  111131. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111132. /**
  111133. * Applies a radial explosion force
  111134. * @param origin the origin of the explosion
  111135. * @param radiusOrEventOptions the radius or the options of radial explosion
  111136. * @param strength the explosion strength
  111137. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111138. * @returns A physics radial explosion event, or null
  111139. */
  111140. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  111141. /**
  111142. * Creates a gravitational field
  111143. * @param origin the origin of the explosion
  111144. * @param radiusOrEventOptions the radius or the options of radial explosion
  111145. * @param strength the explosion strength
  111146. * @param falloff possible options: Constant & Linear. Defaults to Constant
  111147. * @returns A physics gravitational field event, or null
  111148. */
  111149. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  111150. /**
  111151. * Creates a physics updraft event
  111152. * @param origin the origin of the updraft
  111153. * @param radiusOrEventOptions the radius or the options of the updraft
  111154. * @param strength the strength of the updraft
  111155. * @param height the height of the updraft
  111156. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  111157. * @returns A physics updraft event, or null
  111158. */
  111159. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  111160. /**
  111161. * Creates a physics vortex event
  111162. * @param origin the of the vortex
  111163. * @param radiusOrEventOptions the radius or the options of the vortex
  111164. * @param strength the strength of the vortex
  111165. * @param height the height of the vortex
  111166. * @returns a Physics vortex event, or null
  111167. * A physics vortex event or null
  111168. */
  111169. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  111170. }
  111171. /**
  111172. * Represents a physics radial explosion event
  111173. */
  111174. class PhysicsRadialExplosionEvent {
  111175. private _scene;
  111176. private _options;
  111177. private _sphere;
  111178. private _dataFetched;
  111179. /**
  111180. * Initializes a radial explosioin event
  111181. * @param _scene BabylonJS scene
  111182. * @param _options The options for the vortex event
  111183. */
  111184. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  111185. /**
  111186. * Returns the data related to the radial explosion event (sphere).
  111187. * @returns The radial explosion event data
  111188. */
  111189. getData(): PhysicsRadialExplosionEventData;
  111190. /**
  111191. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  111192. * @param impostor A physics imposter
  111193. * @param origin the origin of the explosion
  111194. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  111195. */
  111196. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  111197. /**
  111198. * Triggers affecterd impostors callbacks
  111199. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  111200. */
  111201. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  111202. /**
  111203. * Disposes the sphere.
  111204. * @param force Specifies if the sphere should be disposed by force
  111205. */
  111206. dispose(force?: boolean): void;
  111207. /*** Helpers ***/
  111208. private _prepareSphere;
  111209. private _intersectsWithSphere;
  111210. }
  111211. /**
  111212. * Represents a gravitational field event
  111213. */
  111214. class PhysicsGravitationalFieldEvent {
  111215. private _physicsHelper;
  111216. private _scene;
  111217. private _origin;
  111218. private _options;
  111219. private _tickCallback;
  111220. private _sphere;
  111221. private _dataFetched;
  111222. /**
  111223. * Initializes the physics gravitational field event
  111224. * @param _physicsHelper A physics helper
  111225. * @param _scene BabylonJS scene
  111226. * @param _origin The origin position of the gravitational field event
  111227. * @param _options The options for the vortex event
  111228. */
  111229. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  111230. /**
  111231. * Returns the data related to the gravitational field event (sphere).
  111232. * @returns A gravitational field event
  111233. */
  111234. getData(): PhysicsGravitationalFieldEventData;
  111235. /**
  111236. * Enables the gravitational field.
  111237. */
  111238. enable(): void;
  111239. /**
  111240. * Disables the gravitational field.
  111241. */
  111242. disable(): void;
  111243. /**
  111244. * Disposes the sphere.
  111245. * @param force The force to dispose from the gravitational field event
  111246. */
  111247. dispose(force?: boolean): void;
  111248. private _tick;
  111249. }
  111250. /**
  111251. * Represents a physics updraft event
  111252. */
  111253. class PhysicsUpdraftEvent {
  111254. private _scene;
  111255. private _origin;
  111256. private _options;
  111257. private _physicsEngine;
  111258. private _originTop;
  111259. private _originDirection;
  111260. private _tickCallback;
  111261. private _cylinder;
  111262. private _cylinderPosition;
  111263. private _dataFetched;
  111264. /**
  111265. * Initializes the physics updraft event
  111266. * @param _scene BabylonJS scene
  111267. * @param _origin The origin position of the updraft
  111268. * @param _options The options for the updraft event
  111269. */
  111270. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  111271. /**
  111272. * Returns the data related to the updraft event (cylinder).
  111273. * @returns A physics updraft event
  111274. */
  111275. getData(): PhysicsUpdraftEventData;
  111276. /**
  111277. * Enables the updraft.
  111278. */
  111279. enable(): void;
  111280. /**
  111281. * Disables the updraft.
  111282. */
  111283. disable(): void;
  111284. /**
  111285. * Disposes the cylinder.
  111286. * @param force Specifies if the updraft should be disposed by force
  111287. */
  111288. dispose(force?: boolean): void;
  111289. private getImpostorHitData;
  111290. private _tick;
  111291. /*** Helpers ***/
  111292. private _prepareCylinder;
  111293. private _intersectsWithCylinder;
  111294. }
  111295. /**
  111296. * Represents a physics vortex event
  111297. */
  111298. class PhysicsVortexEvent {
  111299. private _scene;
  111300. private _origin;
  111301. private _options;
  111302. private _physicsEngine;
  111303. private _originTop;
  111304. private _tickCallback;
  111305. private _cylinder;
  111306. private _cylinderPosition;
  111307. private _dataFetched;
  111308. /**
  111309. * Initializes the physics vortex event
  111310. * @param _scene The BabylonJS scene
  111311. * @param _origin The origin position of the vortex
  111312. * @param _options The options for the vortex event
  111313. */
  111314. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  111315. /**
  111316. * Returns the data related to the vortex event (cylinder).
  111317. * @returns The physics vortex event data
  111318. */
  111319. getData(): PhysicsVortexEventData;
  111320. /**
  111321. * Enables the vortex.
  111322. */
  111323. enable(): void;
  111324. /**
  111325. * Disables the cortex.
  111326. */
  111327. disable(): void;
  111328. /**
  111329. * Disposes the sphere.
  111330. * @param force
  111331. */
  111332. dispose(force?: boolean): void;
  111333. private getImpostorHitData;
  111334. private _tick;
  111335. /*** Helpers ***/
  111336. private _prepareCylinder;
  111337. private _intersectsWithCylinder;
  111338. }
  111339. /**
  111340. * Options fot the radial explosion event
  111341. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111342. */
  111343. export class PhysicsRadialExplosionEventOptions {
  111344. /**
  111345. * The radius of the sphere for the radial explosion.
  111346. */
  111347. radius: number;
  111348. /**
  111349. * The strenth of the explosion.
  111350. */
  111351. strength: number;
  111352. /**
  111353. * The strenght of the force in correspondence to the distance of the affected object
  111354. */
  111355. falloff: PhysicsRadialImpulseFalloff;
  111356. /**
  111357. * Sphere options for the radial explosion.
  111358. */
  111359. sphere: {
  111360. segments: number;
  111361. diameter: number;
  111362. };
  111363. /**
  111364. * Sphere options for the radial explosion.
  111365. */
  111366. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  111367. }
  111368. /**
  111369. * Options fot the updraft event
  111370. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111371. */
  111372. export class PhysicsUpdraftEventOptions {
  111373. /**
  111374. * The radius of the cylinder for the vortex
  111375. */
  111376. radius: number;
  111377. /**
  111378. * The strenth of the updraft.
  111379. */
  111380. strength: number;
  111381. /**
  111382. * The height of the cylinder for the updraft.
  111383. */
  111384. height: number;
  111385. /**
  111386. * The mode for the the updraft.
  111387. */
  111388. updraftMode: PhysicsUpdraftMode;
  111389. }
  111390. /**
  111391. * Options fot the vortex event
  111392. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111393. */
  111394. export class PhysicsVortexEventOptions {
  111395. /**
  111396. * The radius of the cylinder for the vortex
  111397. */
  111398. radius: number;
  111399. /**
  111400. * The strenth of the vortex.
  111401. */
  111402. strength: number;
  111403. /**
  111404. * The height of the cylinder for the vortex.
  111405. */
  111406. height: number;
  111407. /**
  111408. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  111409. */
  111410. centripetalForceThreshold: number;
  111411. /**
  111412. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  111413. */
  111414. centripetalForceMultiplier: number;
  111415. /**
  111416. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  111417. */
  111418. centrifugalForceMultiplier: number;
  111419. /**
  111420. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  111421. */
  111422. updraftForceMultiplier: number;
  111423. }
  111424. /**
  111425. * The strenght of the force in correspondence to the distance of the affected object
  111426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111427. */
  111428. export enum PhysicsRadialImpulseFalloff {
  111429. /** Defines that impulse is constant in strength across it's whole radius */
  111430. Constant = 0,
  111431. /** Defines that impulse gets weaker if it's further from the origin */
  111432. Linear = 1
  111433. }
  111434. /**
  111435. * The strength of the force in correspondence to the distance of the affected object
  111436. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111437. */
  111438. export enum PhysicsUpdraftMode {
  111439. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  111440. Center = 0,
  111441. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  111442. Perpendicular = 1
  111443. }
  111444. /**
  111445. * Interface for a physics hit data
  111446. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111447. */
  111448. export interface PhysicsHitData {
  111449. /**
  111450. * The force applied at the contact point
  111451. */
  111452. force: Vector3;
  111453. /**
  111454. * The contact point
  111455. */
  111456. contactPoint: Vector3;
  111457. /**
  111458. * The distance from the origin to the contact point
  111459. */
  111460. distanceFromOrigin: number;
  111461. }
  111462. /**
  111463. * Interface for radial explosion event data
  111464. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111465. */
  111466. export interface PhysicsRadialExplosionEventData {
  111467. /**
  111468. * A sphere used for the radial explosion event
  111469. */
  111470. sphere: Mesh;
  111471. }
  111472. /**
  111473. * Interface for gravitational field event data
  111474. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111475. */
  111476. export interface PhysicsGravitationalFieldEventData {
  111477. /**
  111478. * A sphere mesh used for the gravitational field event
  111479. */
  111480. sphere: Mesh;
  111481. }
  111482. /**
  111483. * Interface for updraft event data
  111484. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111485. */
  111486. export interface PhysicsUpdraftEventData {
  111487. /**
  111488. * A cylinder used for the updraft event
  111489. */
  111490. cylinder: Mesh;
  111491. }
  111492. /**
  111493. * Interface for vortex event data
  111494. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111495. */
  111496. export interface PhysicsVortexEventData {
  111497. /**
  111498. * A cylinder used for the vortex event
  111499. */
  111500. cylinder: Mesh;
  111501. }
  111502. /**
  111503. * Interface for an affected physics impostor
  111504. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  111505. */
  111506. export interface PhysicsAffectedImpostorWithData {
  111507. /**
  111508. * The impostor affected by the effect
  111509. */
  111510. impostor: PhysicsImpostor;
  111511. /**
  111512. * The data about the hit/horce from the explosion
  111513. */
  111514. hitData: PhysicsHitData;
  111515. }
  111516. }
  111517. declare module BABYLON {
  111518. /** @hidden */
  111519. export var blackAndWhitePixelShader: {
  111520. name: string;
  111521. shader: string;
  111522. };
  111523. }
  111524. declare module BABYLON {
  111525. /**
  111526. * Post process used to render in black and white
  111527. */
  111528. export class BlackAndWhitePostProcess extends PostProcess {
  111529. /**
  111530. * Linear about to convert he result to black and white (default: 1)
  111531. */
  111532. degree: number;
  111533. /**
  111534. * Creates a black and white post process
  111535. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  111536. * @param name The name of the effect.
  111537. * @param options The required width/height ratio to downsize to before computing the render pass.
  111538. * @param camera The camera to apply the render pass to.
  111539. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111540. * @param engine The engine which the post process will be applied. (default: current engine)
  111541. * @param reusable If the post process can be reused on the same frame. (default: false)
  111542. */
  111543. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111544. }
  111545. }
  111546. declare module BABYLON {
  111547. /**
  111548. * This represents a set of one or more post processes in Babylon.
  111549. * A post process can be used to apply a shader to a texture after it is rendered.
  111550. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  111551. */
  111552. export class PostProcessRenderEffect {
  111553. private _postProcesses;
  111554. private _getPostProcesses;
  111555. private _singleInstance;
  111556. private _cameras;
  111557. private _indicesForCamera;
  111558. /**
  111559. * Name of the effect
  111560. * @hidden
  111561. */
  111562. _name: string;
  111563. /**
  111564. * Instantiates a post process render effect.
  111565. * A post process can be used to apply a shader to a texture after it is rendered.
  111566. * @param engine The engine the effect is tied to
  111567. * @param name The name of the effect
  111568. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  111569. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  111570. */
  111571. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  111572. /**
  111573. * Checks if all the post processes in the effect are supported.
  111574. */
  111575. readonly isSupported: boolean;
  111576. /**
  111577. * Updates the current state of the effect
  111578. * @hidden
  111579. */
  111580. _update(): void;
  111581. /**
  111582. * Attaches the effect on cameras
  111583. * @param cameras The camera to attach to.
  111584. * @hidden
  111585. */
  111586. _attachCameras(cameras: Camera): void;
  111587. /**
  111588. * Attaches the effect on cameras
  111589. * @param cameras The camera to attach to.
  111590. * @hidden
  111591. */
  111592. _attachCameras(cameras: Camera[]): void;
  111593. /**
  111594. * Detatches the effect on cameras
  111595. * @param cameras The camera to detatch from.
  111596. * @hidden
  111597. */
  111598. _detachCameras(cameras: Camera): void;
  111599. /**
  111600. * Detatches the effect on cameras
  111601. * @param cameras The camera to detatch from.
  111602. * @hidden
  111603. */
  111604. _detachCameras(cameras: Camera[]): void;
  111605. /**
  111606. * Enables the effect on given cameras
  111607. * @param cameras The camera to enable.
  111608. * @hidden
  111609. */
  111610. _enable(cameras: Camera): void;
  111611. /**
  111612. * Enables the effect on given cameras
  111613. * @param cameras The camera to enable.
  111614. * @hidden
  111615. */
  111616. _enable(cameras: Nullable<Camera[]>): void;
  111617. /**
  111618. * Disables the effect on the given cameras
  111619. * @param cameras The camera to disable.
  111620. * @hidden
  111621. */
  111622. _disable(cameras: Camera): void;
  111623. /**
  111624. * Disables the effect on the given cameras
  111625. * @param cameras The camera to disable.
  111626. * @hidden
  111627. */
  111628. _disable(cameras: Nullable<Camera[]>): void;
  111629. /**
  111630. * Gets a list of the post processes contained in the effect.
  111631. * @param camera The camera to get the post processes on.
  111632. * @returns The list of the post processes in the effect.
  111633. */
  111634. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  111635. }
  111636. }
  111637. declare module BABYLON {
  111638. /** @hidden */
  111639. export var extractHighlightsPixelShader: {
  111640. name: string;
  111641. shader: string;
  111642. };
  111643. }
  111644. declare module BABYLON {
  111645. /**
  111646. * 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.
  111647. */
  111648. export class ExtractHighlightsPostProcess extends PostProcess {
  111649. /**
  111650. * The luminance threshold, pixels below this value will be set to black.
  111651. */
  111652. threshold: number;
  111653. /** @hidden */
  111654. _exposure: number;
  111655. /**
  111656. * Post process which has the input texture to be used when performing highlight extraction
  111657. * @hidden
  111658. */
  111659. _inputPostProcess: Nullable<PostProcess>;
  111660. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111661. }
  111662. }
  111663. declare module BABYLON {
  111664. /** @hidden */
  111665. export var bloomMergePixelShader: {
  111666. name: string;
  111667. shader: string;
  111668. };
  111669. }
  111670. declare module BABYLON {
  111671. /**
  111672. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111673. */
  111674. export class BloomMergePostProcess extends PostProcess {
  111675. /** Weight of the bloom to be added to the original input. */
  111676. weight: number;
  111677. /**
  111678. * Creates a new instance of @see BloomMergePostProcess
  111679. * @param name The name of the effect.
  111680. * @param originalFromInput Post process which's input will be used for the merge.
  111681. * @param blurred Blurred highlights post process which's output will be used.
  111682. * @param weight Weight of the bloom to be added to the original input.
  111683. * @param options The required width/height ratio to downsize to before computing the render pass.
  111684. * @param camera The camera to apply the render pass to.
  111685. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111686. * @param engine The engine which the post process will be applied. (default: current engine)
  111687. * @param reusable If the post process can be reused on the same frame. (default: false)
  111688. * @param textureType Type of textures used when performing the post process. (default: 0)
  111689. * @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)
  111690. */
  111691. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  111692. /** Weight of the bloom to be added to the original input. */
  111693. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111694. }
  111695. }
  111696. declare module BABYLON {
  111697. /**
  111698. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  111699. */
  111700. export class BloomEffect extends PostProcessRenderEffect {
  111701. private bloomScale;
  111702. /**
  111703. * @hidden Internal
  111704. */
  111705. _effects: Array<PostProcess>;
  111706. /**
  111707. * @hidden Internal
  111708. */
  111709. _downscale: ExtractHighlightsPostProcess;
  111710. private _blurX;
  111711. private _blurY;
  111712. private _merge;
  111713. /**
  111714. * The luminance threshold to find bright areas of the image to bloom.
  111715. */
  111716. threshold: number;
  111717. /**
  111718. * The strength of the bloom.
  111719. */
  111720. weight: number;
  111721. /**
  111722. * Specifies the size of the bloom blur kernel, relative to the final output size
  111723. */
  111724. kernel: number;
  111725. /**
  111726. * Creates a new instance of @see BloomEffect
  111727. * @param scene The scene the effect belongs to.
  111728. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  111729. * @param bloomKernel The size of the kernel to be used when applying the blur.
  111730. * @param bloomWeight The the strength of bloom.
  111731. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  111732. * @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)
  111733. */
  111734. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  111735. /**
  111736. * Disposes each of the internal effects for a given camera.
  111737. * @param camera The camera to dispose the effect on.
  111738. */
  111739. disposeEffects(camera: Camera): void;
  111740. /**
  111741. * @hidden Internal
  111742. */
  111743. _updateEffects(): void;
  111744. /**
  111745. * Internal
  111746. * @returns if all the contained post processes are ready.
  111747. * @hidden
  111748. */
  111749. _isReady(): boolean;
  111750. }
  111751. }
  111752. declare module BABYLON {
  111753. /** @hidden */
  111754. export var chromaticAberrationPixelShader: {
  111755. name: string;
  111756. shader: string;
  111757. };
  111758. }
  111759. declare module BABYLON {
  111760. /**
  111761. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  111762. */
  111763. export class ChromaticAberrationPostProcess extends PostProcess {
  111764. /**
  111765. * The amount of seperation of rgb channels (default: 30)
  111766. */
  111767. aberrationAmount: number;
  111768. /**
  111769. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  111770. */
  111771. radialIntensity: number;
  111772. /**
  111773. * 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))
  111774. */
  111775. direction: Vector2;
  111776. /**
  111777. * 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))
  111778. */
  111779. centerPosition: Vector2;
  111780. /**
  111781. * Creates a new instance ChromaticAberrationPostProcess
  111782. * @param name The name of the effect.
  111783. * @param screenWidth The width of the screen to apply the effect on.
  111784. * @param screenHeight The height of the screen to apply the effect on.
  111785. * @param options The required width/height ratio to downsize to before computing the render pass.
  111786. * @param camera The camera to apply the render pass to.
  111787. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111788. * @param engine The engine which the post process will be applied. (default: current engine)
  111789. * @param reusable If the post process can be reused on the same frame. (default: false)
  111790. * @param textureType Type of textures used when performing the post process. (default: 0)
  111791. * @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)
  111792. */
  111793. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111794. }
  111795. }
  111796. declare module BABYLON {
  111797. /** @hidden */
  111798. export var circleOfConfusionPixelShader: {
  111799. name: string;
  111800. shader: string;
  111801. };
  111802. }
  111803. declare module BABYLON {
  111804. /**
  111805. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  111806. */
  111807. export class CircleOfConfusionPostProcess extends PostProcess {
  111808. /**
  111809. * 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.
  111810. */
  111811. lensSize: number;
  111812. /**
  111813. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  111814. */
  111815. fStop: number;
  111816. /**
  111817. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  111818. */
  111819. focusDistance: number;
  111820. /**
  111821. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  111822. */
  111823. focalLength: number;
  111824. private _depthTexture;
  111825. /**
  111826. * Creates a new instance CircleOfConfusionPostProcess
  111827. * @param name The name of the effect.
  111828. * @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.
  111829. * @param options The required width/height ratio to downsize to before computing the render pass.
  111830. * @param camera The camera to apply the render pass to.
  111831. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111832. * @param engine The engine which the post process will be applied. (default: current engine)
  111833. * @param reusable If the post process can be reused on the same frame. (default: false)
  111834. * @param textureType Type of textures used when performing the post process. (default: 0)
  111835. * @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)
  111836. */
  111837. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  111838. /**
  111839. * 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.
  111840. */
  111841. depthTexture: RenderTargetTexture;
  111842. }
  111843. }
  111844. declare module BABYLON {
  111845. /** @hidden */
  111846. export var colorCorrectionPixelShader: {
  111847. name: string;
  111848. shader: string;
  111849. };
  111850. }
  111851. declare module BABYLON {
  111852. /**
  111853. *
  111854. * This post-process allows the modification of rendered colors by using
  111855. * a 'look-up table' (LUT). This effect is also called Color Grading.
  111856. *
  111857. * The object needs to be provided an url to a texture containing the color
  111858. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  111859. * Use an image editing software to tweak the LUT to match your needs.
  111860. *
  111861. * For an example of a color LUT, see here:
  111862. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  111863. * For explanations on color grading, see here:
  111864. * @see http://udn.epicgames.com/Three/ColorGrading.html
  111865. *
  111866. */
  111867. export class ColorCorrectionPostProcess extends PostProcess {
  111868. private _colorTableTexture;
  111869. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  111870. }
  111871. }
  111872. declare module BABYLON {
  111873. /** @hidden */
  111874. export var convolutionPixelShader: {
  111875. name: string;
  111876. shader: string;
  111877. };
  111878. }
  111879. declare module BABYLON {
  111880. /**
  111881. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  111882. * input texture to perform effects such as edge detection or sharpening
  111883. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  111884. */
  111885. export class ConvolutionPostProcess extends PostProcess {
  111886. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111887. kernel: number[];
  111888. /**
  111889. * Creates a new instance ConvolutionPostProcess
  111890. * @param name The name of the effect.
  111891. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  111892. * @param options The required width/height ratio to downsize to before computing the render pass.
  111893. * @param camera The camera to apply the render pass to.
  111894. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111895. * @param engine The engine which the post process will be applied. (default: current engine)
  111896. * @param reusable If the post process can be reused on the same frame. (default: false)
  111897. * @param textureType Type of textures used when performing the post process. (default: 0)
  111898. */
  111899. constructor(name: string,
  111900. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  111901. kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  111902. /**
  111903. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111904. */
  111905. static EdgeDetect0Kernel: number[];
  111906. /**
  111907. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111908. */
  111909. static EdgeDetect1Kernel: number[];
  111910. /**
  111911. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111912. */
  111913. static EdgeDetect2Kernel: number[];
  111914. /**
  111915. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111916. */
  111917. static SharpenKernel: number[];
  111918. /**
  111919. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111920. */
  111921. static EmbossKernel: number[];
  111922. /**
  111923. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  111924. */
  111925. static GaussianKernel: number[];
  111926. }
  111927. }
  111928. declare module BABYLON {
  111929. /**
  111930. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  111931. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  111932. * based on samples that have a large difference in distance than the center pixel.
  111933. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  111934. */
  111935. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  111936. direction: Vector2;
  111937. /**
  111938. * Creates a new instance CircleOfConfusionPostProcess
  111939. * @param name The name of the effect.
  111940. * @param scene The scene the effect belongs to.
  111941. * @param direction The direction the blur should be applied.
  111942. * @param kernel The size of the kernel used to blur.
  111943. * @param options The required width/height ratio to downsize to before computing the render pass.
  111944. * @param camera The camera to apply the render pass to.
  111945. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  111946. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  111947. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  111948. * @param engine The engine which the post process will be applied. (default: current engine)
  111949. * @param reusable If the post process can be reused on the same frame. (default: false)
  111950. * @param textureType Type of textures used when performing the post process. (default: 0)
  111951. * @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)
  111952. */
  111953. 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);
  111954. }
  111955. }
  111956. declare module BABYLON {
  111957. /** @hidden */
  111958. export var depthOfFieldMergePixelShader: {
  111959. name: string;
  111960. shader: string;
  111961. };
  111962. }
  111963. declare module BABYLON {
  111964. /**
  111965. * Options to be set when merging outputs from the default pipeline.
  111966. */
  111967. export class DepthOfFieldMergePostProcessOptions {
  111968. /**
  111969. * The original image to merge on top of
  111970. */
  111971. originalFromInput: PostProcess;
  111972. /**
  111973. * Parameters to perform the merge of the depth of field effect
  111974. */
  111975. depthOfField?: {
  111976. circleOfConfusion: PostProcess;
  111977. blurSteps: Array<PostProcess>;
  111978. };
  111979. /**
  111980. * Parameters to perform the merge of bloom effect
  111981. */
  111982. bloom?: {
  111983. blurred: PostProcess;
  111984. weight: number;
  111985. };
  111986. }
  111987. /**
  111988. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  111989. */
  111990. export class DepthOfFieldMergePostProcess extends PostProcess {
  111991. private blurSteps;
  111992. /**
  111993. * Creates a new instance of DepthOfFieldMergePostProcess
  111994. * @param name The name of the effect.
  111995. * @param originalFromInput Post process which's input will be used for the merge.
  111996. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  111997. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  111998. * @param options The required width/height ratio to downsize to before computing the render pass.
  111999. * @param camera The camera to apply the render pass to.
  112000. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112001. * @param engine The engine which the post process will be applied. (default: current engine)
  112002. * @param reusable If the post process can be reused on the same frame. (default: false)
  112003. * @param textureType Type of textures used when performing the post process. (default: 0)
  112004. * @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)
  112005. */
  112006. 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);
  112007. /**
  112008. * Updates the effect with the current post process compile time values and recompiles the shader.
  112009. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  112010. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  112011. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  112012. * @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
  112013. * @param onCompiled Called when the shader has been compiled.
  112014. * @param onError Called if there is an error when compiling a shader.
  112015. */
  112016. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  112017. }
  112018. }
  112019. declare module BABYLON {
  112020. /**
  112021. * Specifies the level of max blur that should be applied when using the depth of field effect
  112022. */
  112023. export enum DepthOfFieldEffectBlurLevel {
  112024. /**
  112025. * Subtle blur
  112026. */
  112027. Low = 0,
  112028. /**
  112029. * Medium blur
  112030. */
  112031. Medium = 1,
  112032. /**
  112033. * Large blur
  112034. */
  112035. High = 2
  112036. }
  112037. /**
  112038. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  112039. */
  112040. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  112041. private _circleOfConfusion;
  112042. /**
  112043. * @hidden Internal, blurs from high to low
  112044. */
  112045. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  112046. private _depthOfFieldBlurY;
  112047. private _dofMerge;
  112048. /**
  112049. * @hidden Internal post processes in depth of field effect
  112050. */
  112051. _effects: Array<PostProcess>;
  112052. /**
  112053. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  112054. */
  112055. focalLength: number;
  112056. /**
  112057. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  112058. */
  112059. fStop: number;
  112060. /**
  112061. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  112062. */
  112063. focusDistance: number;
  112064. /**
  112065. * 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.
  112066. */
  112067. lensSize: number;
  112068. /**
  112069. * Creates a new instance DepthOfFieldEffect
  112070. * @param scene The scene the effect belongs to.
  112071. * @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.
  112072. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  112073. * @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)
  112074. */
  112075. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  112076. /**
  112077. * 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.
  112078. */
  112079. depthTexture: RenderTargetTexture;
  112080. /**
  112081. * Disposes each of the internal effects for a given camera.
  112082. * @param camera The camera to dispose the effect on.
  112083. */
  112084. disposeEffects(camera: Camera): void;
  112085. /**
  112086. * @hidden Internal
  112087. */
  112088. _updateEffects(): void;
  112089. /**
  112090. * Internal
  112091. * @returns if all the contained post processes are ready.
  112092. * @hidden
  112093. */
  112094. _isReady(): boolean;
  112095. }
  112096. }
  112097. declare module BABYLON {
  112098. /** @hidden */
  112099. export var displayPassPixelShader: {
  112100. name: string;
  112101. shader: string;
  112102. };
  112103. }
  112104. declare module BABYLON {
  112105. /**
  112106. * DisplayPassPostProcess which produces an output the same as it's input
  112107. */
  112108. export class DisplayPassPostProcess extends PostProcess {
  112109. /**
  112110. * Creates the DisplayPassPostProcess
  112111. * @param name The name of the effect.
  112112. * @param options The required width/height ratio to downsize to before computing the render pass.
  112113. * @param camera The camera to apply the render pass to.
  112114. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112115. * @param engine The engine which the post process will be applied. (default: current engine)
  112116. * @param reusable If the post process can be reused on the same frame. (default: false)
  112117. */
  112118. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112119. }
  112120. }
  112121. declare module BABYLON {
  112122. /** @hidden */
  112123. export var filterPixelShader: {
  112124. name: string;
  112125. shader: string;
  112126. };
  112127. }
  112128. declare module BABYLON {
  112129. /**
  112130. * Applies a kernel filter to the image
  112131. */
  112132. export class FilterPostProcess extends PostProcess {
  112133. /** The matrix to be applied to the image */
  112134. kernelMatrix: Matrix;
  112135. /**
  112136. *
  112137. * @param name The name of the effect.
  112138. * @param kernelMatrix The matrix to be applied to the image
  112139. * @param options The required width/height ratio to downsize to before computing the render pass.
  112140. * @param camera The camera to apply the render pass to.
  112141. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112142. * @param engine The engine which the post process will be applied. (default: current engine)
  112143. * @param reusable If the post process can be reused on the same frame. (default: false)
  112144. */
  112145. constructor(name: string,
  112146. /** The matrix to be applied to the image */
  112147. kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112148. }
  112149. }
  112150. declare module BABYLON {
  112151. /** @hidden */
  112152. export var fxaaPixelShader: {
  112153. name: string;
  112154. shader: string;
  112155. };
  112156. }
  112157. declare module BABYLON {
  112158. /** @hidden */
  112159. export var fxaaVertexShader: {
  112160. name: string;
  112161. shader: string;
  112162. };
  112163. }
  112164. declare module BABYLON {
  112165. /**
  112166. * Fxaa post process
  112167. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  112168. */
  112169. export class FxaaPostProcess extends PostProcess {
  112170. /** @hidden */
  112171. texelWidth: number;
  112172. /** @hidden */
  112173. texelHeight: number;
  112174. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112175. private _getDefines;
  112176. }
  112177. }
  112178. declare module BABYLON {
  112179. /** @hidden */
  112180. export var grainPixelShader: {
  112181. name: string;
  112182. shader: string;
  112183. };
  112184. }
  112185. declare module BABYLON {
  112186. /**
  112187. * The GrainPostProcess adds noise to the image at mid luminance levels
  112188. */
  112189. export class GrainPostProcess extends PostProcess {
  112190. /**
  112191. * The intensity of the grain added (default: 30)
  112192. */
  112193. intensity: number;
  112194. /**
  112195. * If the grain should be randomized on every frame
  112196. */
  112197. animated: boolean;
  112198. /**
  112199. * Creates a new instance of @see GrainPostProcess
  112200. * @param name The name of the effect.
  112201. * @param options The required width/height ratio to downsize to before computing the render pass.
  112202. * @param camera The camera to apply the render pass to.
  112203. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112204. * @param engine The engine which the post process will be applied. (default: current engine)
  112205. * @param reusable If the post process can be reused on the same frame. (default: false)
  112206. * @param textureType Type of textures used when performing the post process. (default: 0)
  112207. * @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)
  112208. */
  112209. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112210. }
  112211. }
  112212. declare module BABYLON {
  112213. /** @hidden */
  112214. export var highlightsPixelShader: {
  112215. name: string;
  112216. shader: string;
  112217. };
  112218. }
  112219. declare module BABYLON {
  112220. /**
  112221. * Extracts highlights from the image
  112222. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112223. */
  112224. export class HighlightsPostProcess extends PostProcess {
  112225. /**
  112226. * Extracts highlights from the image
  112227. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  112228. * @param name The name of the effect.
  112229. * @param options The required width/height ratio to downsize to before computing the render pass.
  112230. * @param camera The camera to apply the render pass to.
  112231. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112232. * @param engine The engine which the post process will be applied. (default: current engine)
  112233. * @param reusable If the post process can be reused on the same frame. (default: false)
  112234. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  112235. */
  112236. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  112237. }
  112238. }
  112239. declare module BABYLON {
  112240. /** @hidden */
  112241. export var mrtFragmentDeclaration: {
  112242. name: string;
  112243. shader: string;
  112244. };
  112245. }
  112246. declare module BABYLON {
  112247. /** @hidden */
  112248. export var geometryPixelShader: {
  112249. name: string;
  112250. shader: string;
  112251. };
  112252. }
  112253. declare module BABYLON {
  112254. /** @hidden */
  112255. export var geometryVertexShader: {
  112256. name: string;
  112257. shader: string;
  112258. };
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  112263. */
  112264. export class GeometryBufferRenderer {
  112265. /**
  112266. * Constant used to retrieve the position texture index in the G-Buffer textures array
  112267. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  112268. */
  112269. static readonly POSITION_TEXTURE_TYPE: number;
  112270. /**
  112271. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  112272. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  112273. */
  112274. static readonly VELOCITY_TEXTURE_TYPE: number;
  112275. /**
  112276. * Dictionary used to store the previous transformation matrices of each rendered mesh
  112277. * in order to compute objects velocities when enableVelocity is set to "true"
  112278. * @hidden
  112279. */
  112280. _previousTransformationMatrices: {
  112281. [index: number]: Matrix;
  112282. };
  112283. private _scene;
  112284. private _multiRenderTarget;
  112285. private _ratio;
  112286. private _enablePosition;
  112287. private _enableVelocity;
  112288. private _positionIndex;
  112289. private _velocityIndex;
  112290. protected _effect: Effect;
  112291. protected _cachedDefines: string;
  112292. /**
  112293. * Set the render list (meshes to be rendered) used in the G buffer.
  112294. */
  112295. renderList: Mesh[];
  112296. /**
  112297. * Gets wether or not G buffer are supported by the running hardware.
  112298. * This requires draw buffer supports
  112299. */
  112300. readonly isSupported: boolean;
  112301. /**
  112302. * Returns the index of the given texture type in the G-Buffer textures array
  112303. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  112304. * @returns the index of the given texture type in the G-Buffer textures array
  112305. */
  112306. getTextureIndex(textureType: number): number;
  112307. /**
  112308. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  112309. */
  112310. /**
  112311. * Sets whether or not objects positions are enabled for the G buffer.
  112312. */
  112313. enablePosition: boolean;
  112314. /**
  112315. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  112316. */
  112317. /**
  112318. * Sets wether or not objects velocities are enabled for the G buffer.
  112319. */
  112320. enableVelocity: boolean;
  112321. /**
  112322. * Gets the scene associated with the buffer.
  112323. */
  112324. readonly scene: Scene;
  112325. /**
  112326. * Gets the ratio used by the buffer during its creation.
  112327. * How big is the buffer related to the main canvas.
  112328. */
  112329. readonly ratio: number;
  112330. /** @hidden */
  112331. static _SceneComponentInitialization: (scene: Scene) => void;
  112332. /**
  112333. * Creates a new G Buffer for the scene
  112334. * @param scene The scene the buffer belongs to
  112335. * @param ratio How big is the buffer related to the main canvas.
  112336. */
  112337. constructor(scene: Scene, ratio?: number);
  112338. /**
  112339. * Checks wether everything is ready to render a submesh to the G buffer.
  112340. * @param subMesh the submesh to check readiness for
  112341. * @param useInstances is the mesh drawn using instance or not
  112342. * @returns true if ready otherwise false
  112343. */
  112344. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  112345. /**
  112346. * Gets the current underlying G Buffer.
  112347. * @returns the buffer
  112348. */
  112349. getGBuffer(): MultiRenderTarget;
  112350. /**
  112351. * Gets the number of samples used to render the buffer (anti aliasing).
  112352. */
  112353. /**
  112354. * Sets the number of samples used to render the buffer (anti aliasing).
  112355. */
  112356. samples: number;
  112357. /**
  112358. * Disposes the renderer and frees up associated resources.
  112359. */
  112360. dispose(): void;
  112361. protected _createRenderTargets(): void;
  112362. }
  112363. }
  112364. declare module BABYLON {
  112365. interface Scene {
  112366. /** @hidden (Backing field) */
  112367. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112368. /**
  112369. * Gets or Sets the current geometry buffer associated to the scene.
  112370. */
  112371. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  112372. /**
  112373. * Enables a GeometryBufferRender and associates it with the scene
  112374. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  112375. * @returns the GeometryBufferRenderer
  112376. */
  112377. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  112378. /**
  112379. * Disables the GeometryBufferRender associated with the scene
  112380. */
  112381. disableGeometryBufferRenderer(): void;
  112382. }
  112383. /**
  112384. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  112385. * in several rendering techniques.
  112386. */
  112387. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  112388. /**
  112389. * The component name helpful to identify the component in the list of scene components.
  112390. */
  112391. readonly name: string;
  112392. /**
  112393. * The scene the component belongs to.
  112394. */
  112395. scene: Scene;
  112396. /**
  112397. * Creates a new instance of the component for the given scene
  112398. * @param scene Defines the scene to register the component in
  112399. */
  112400. constructor(scene: Scene);
  112401. /**
  112402. * Registers the component in a given scene
  112403. */
  112404. register(): void;
  112405. /**
  112406. * Rebuilds the elements related to this component in case of
  112407. * context lost for instance.
  112408. */
  112409. rebuild(): void;
  112410. /**
  112411. * Disposes the component and the associated ressources
  112412. */
  112413. dispose(): void;
  112414. private _gatherRenderTargets;
  112415. }
  112416. }
  112417. declare module BABYLON {
  112418. /** @hidden */
  112419. export var motionBlurPixelShader: {
  112420. name: string;
  112421. shader: string;
  112422. };
  112423. }
  112424. declare module BABYLON {
  112425. /**
  112426. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  112427. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  112428. * As an example, all you have to do is to create the post-process:
  112429. * var mb = new BABYLON.MotionBlurPostProcess(
  112430. * 'mb', // The name of the effect.
  112431. * scene, // The scene containing the objects to blur according to their velocity.
  112432. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  112433. * camera // The camera to apply the render pass to.
  112434. * );
  112435. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  112436. */
  112437. export class MotionBlurPostProcess extends PostProcess {
  112438. /**
  112439. * Defines how much the image is blurred by the movement. Default value is equal to 1
  112440. */
  112441. motionStrength: number;
  112442. /**
  112443. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  112444. */
  112445. /**
  112446. * Sets the number of iterations to be used for motion blur quality
  112447. */
  112448. motionBlurSamples: number;
  112449. private _motionBlurSamples;
  112450. private _geometryBufferRenderer;
  112451. /**
  112452. * Creates a new instance MotionBlurPostProcess
  112453. * @param name The name of the effect.
  112454. * @param scene The scene containing the objects to blur according to their velocity.
  112455. * @param options The required width/height ratio to downsize to before computing the render pass.
  112456. * @param camera The camera to apply the render pass to.
  112457. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112458. * @param engine The engine which the post process will be applied. (default: current engine)
  112459. * @param reusable If the post process can be reused on the same frame. (default: false)
  112460. * @param textureType Type of textures used when performing the post process. (default: 0)
  112461. * @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)
  112462. */
  112463. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112464. /**
  112465. * Disposes the post process.
  112466. * @param camera The camera to dispose the post process on.
  112467. */
  112468. dispose(camera?: Camera): void;
  112469. }
  112470. }
  112471. declare module BABYLON {
  112472. /** @hidden */
  112473. export var refractionPixelShader: {
  112474. name: string;
  112475. shader: string;
  112476. };
  112477. }
  112478. declare module BABYLON {
  112479. /**
  112480. * Post process which applies a refractin texture
  112481. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112482. */
  112483. export class RefractionPostProcess extends PostProcess {
  112484. /** the base color of the refraction (used to taint the rendering) */
  112485. color: Color3;
  112486. /** simulated refraction depth */
  112487. depth: number;
  112488. /** the coefficient of the base color (0 to remove base color tainting) */
  112489. colorLevel: number;
  112490. private _refTexture;
  112491. private _ownRefractionTexture;
  112492. /**
  112493. * Gets or sets the refraction texture
  112494. * Please note that you are responsible for disposing the texture if you set it manually
  112495. */
  112496. refractionTexture: Texture;
  112497. /**
  112498. * Initializes the RefractionPostProcess
  112499. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  112500. * @param name The name of the effect.
  112501. * @param refractionTextureUrl Url of the refraction texture to use
  112502. * @param color the base color of the refraction (used to taint the rendering)
  112503. * @param depth simulated refraction depth
  112504. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  112505. * @param camera The camera to apply the render pass to.
  112506. * @param options The required width/height ratio to downsize to before computing the render pass.
  112507. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112508. * @param engine The engine which the post process will be applied. (default: current engine)
  112509. * @param reusable If the post process can be reused on the same frame. (default: false)
  112510. */
  112511. constructor(name: string, refractionTextureUrl: string,
  112512. /** the base color of the refraction (used to taint the rendering) */
  112513. color: Color3,
  112514. /** simulated refraction depth */
  112515. depth: number,
  112516. /** the coefficient of the base color (0 to remove base color tainting) */
  112517. colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  112518. /**
  112519. * Disposes of the post process
  112520. * @param camera Camera to dispose post process on
  112521. */
  112522. dispose(camera: Camera): void;
  112523. }
  112524. }
  112525. declare module BABYLON {
  112526. /** @hidden */
  112527. export var sharpenPixelShader: {
  112528. name: string;
  112529. shader: string;
  112530. };
  112531. }
  112532. declare module BABYLON {
  112533. /**
  112534. * The SharpenPostProcess applies a sharpen kernel to every pixel
  112535. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  112536. */
  112537. export class SharpenPostProcess extends PostProcess {
  112538. /**
  112539. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  112540. */
  112541. colorAmount: number;
  112542. /**
  112543. * How much sharpness should be applied (default: 0.3)
  112544. */
  112545. edgeAmount: number;
  112546. /**
  112547. * Creates a new instance ConvolutionPostProcess
  112548. * @param name The name of the effect.
  112549. * @param options The required width/height ratio to downsize to before computing the render pass.
  112550. * @param camera The camera to apply the render pass to.
  112551. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  112552. * @param engine The engine which the post process will be applied. (default: current engine)
  112553. * @param reusable If the post process can be reused on the same frame. (default: false)
  112554. * @param textureType Type of textures used when performing the post process. (default: 0)
  112555. * @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)
  112556. */
  112557. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  112558. }
  112559. }
  112560. declare module BABYLON {
  112561. /**
  112562. * PostProcessRenderPipeline
  112563. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112564. */
  112565. export class PostProcessRenderPipeline {
  112566. private engine;
  112567. private _renderEffects;
  112568. private _renderEffectsForIsolatedPass;
  112569. /**
  112570. * List of inspectable custom properties (used by the Inspector)
  112571. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  112572. */
  112573. inspectableCustomProperties: IInspectable[];
  112574. /**
  112575. * @hidden
  112576. */
  112577. protected _cameras: Camera[];
  112578. /** @hidden */
  112579. _name: string;
  112580. /**
  112581. * Gets pipeline name
  112582. */
  112583. readonly name: string;
  112584. /**
  112585. * Initializes a PostProcessRenderPipeline
  112586. * @param engine engine to add the pipeline to
  112587. * @param name name of the pipeline
  112588. */
  112589. constructor(engine: Engine, name: string);
  112590. /**
  112591. * Gets the class name
  112592. * @returns "PostProcessRenderPipeline"
  112593. */
  112594. getClassName(): string;
  112595. /**
  112596. * If all the render effects in the pipeline are supported
  112597. */
  112598. readonly isSupported: boolean;
  112599. /**
  112600. * Adds an effect to the pipeline
  112601. * @param renderEffect the effect to add
  112602. */
  112603. addEffect(renderEffect: PostProcessRenderEffect): void;
  112604. /** @hidden */
  112605. _rebuild(): void;
  112606. /** @hidden */
  112607. _enableEffect(renderEffectName: string, cameras: Camera): void;
  112608. /** @hidden */
  112609. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  112610. /** @hidden */
  112611. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112612. /** @hidden */
  112613. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  112614. /** @hidden */
  112615. _attachCameras(cameras: Camera, unique: boolean): void;
  112616. /** @hidden */
  112617. _attachCameras(cameras: Camera[], unique: boolean): void;
  112618. /** @hidden */
  112619. _detachCameras(cameras: Camera): void;
  112620. /** @hidden */
  112621. _detachCameras(cameras: Nullable<Camera[]>): void;
  112622. /** @hidden */
  112623. _update(): void;
  112624. /** @hidden */
  112625. _reset(): void;
  112626. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  112627. /**
  112628. * Disposes of the pipeline
  112629. */
  112630. dispose(): void;
  112631. }
  112632. }
  112633. declare module BABYLON {
  112634. /**
  112635. * PostProcessRenderPipelineManager class
  112636. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112637. */
  112638. export class PostProcessRenderPipelineManager {
  112639. private _renderPipelines;
  112640. /**
  112641. * Initializes a PostProcessRenderPipelineManager
  112642. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112643. */
  112644. constructor();
  112645. /**
  112646. * Gets the list of supported render pipelines
  112647. */
  112648. readonly supportedPipelines: PostProcessRenderPipeline[];
  112649. /**
  112650. * Adds a pipeline to the manager
  112651. * @param renderPipeline The pipeline to add
  112652. */
  112653. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  112654. /**
  112655. * Attaches a camera to the pipeline
  112656. * @param renderPipelineName The name of the pipeline to attach to
  112657. * @param cameras the camera to attach
  112658. * @param unique if the camera can be attached multiple times to the pipeline
  112659. */
  112660. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  112661. /**
  112662. * Detaches a camera from the pipeline
  112663. * @param renderPipelineName The name of the pipeline to detach from
  112664. * @param cameras the camera to detach
  112665. */
  112666. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  112667. /**
  112668. * Enables an effect by name on a pipeline
  112669. * @param renderPipelineName the name of the pipeline to enable the effect in
  112670. * @param renderEffectName the name of the effect to enable
  112671. * @param cameras the cameras that the effect should be enabled on
  112672. */
  112673. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112674. /**
  112675. * Disables an effect by name on a pipeline
  112676. * @param renderPipelineName the name of the pipeline to disable the effect in
  112677. * @param renderEffectName the name of the effect to disable
  112678. * @param cameras the cameras that the effect should be disabled on
  112679. */
  112680. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  112681. /**
  112682. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  112683. */
  112684. update(): void;
  112685. /** @hidden */
  112686. _rebuild(): void;
  112687. /**
  112688. * Disposes of the manager and pipelines
  112689. */
  112690. dispose(): void;
  112691. }
  112692. }
  112693. declare module BABYLON {
  112694. interface Scene {
  112695. /** @hidden (Backing field) */
  112696. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112697. /**
  112698. * Gets the postprocess render pipeline manager
  112699. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  112700. * @see http://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112701. */
  112702. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  112703. }
  112704. /**
  112705. * Defines the Render Pipeline scene component responsible to rendering pipelines
  112706. */
  112707. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  112708. /**
  112709. * The component name helpfull to identify the component in the list of scene components.
  112710. */
  112711. readonly name: string;
  112712. /**
  112713. * The scene the component belongs to.
  112714. */
  112715. scene: Scene;
  112716. /**
  112717. * Creates a new instance of the component for the given scene
  112718. * @param scene Defines the scene to register the component in
  112719. */
  112720. constructor(scene: Scene);
  112721. /**
  112722. * Registers the component in a given scene
  112723. */
  112724. register(): void;
  112725. /**
  112726. * Rebuilds the elements related to this component in case of
  112727. * context lost for instance.
  112728. */
  112729. rebuild(): void;
  112730. /**
  112731. * Disposes the component and the associated ressources
  112732. */
  112733. dispose(): void;
  112734. private _gatherRenderTargets;
  112735. }
  112736. }
  112737. declare module BABYLON {
  112738. /**
  112739. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  112740. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  112741. */
  112742. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  112743. private _scene;
  112744. private _camerasToBeAttached;
  112745. /**
  112746. * ID of the sharpen post process,
  112747. */
  112748. private readonly SharpenPostProcessId;
  112749. /**
  112750. * @ignore
  112751. * ID of the image processing post process;
  112752. */
  112753. readonly ImageProcessingPostProcessId: string;
  112754. /**
  112755. * @ignore
  112756. * ID of the Fast Approximate Anti-Aliasing post process;
  112757. */
  112758. readonly FxaaPostProcessId: string;
  112759. /**
  112760. * ID of the chromatic aberration post process,
  112761. */
  112762. private readonly ChromaticAberrationPostProcessId;
  112763. /**
  112764. * ID of the grain post process
  112765. */
  112766. private readonly GrainPostProcessId;
  112767. /**
  112768. * Sharpen post process which will apply a sharpen convolution to enhance edges
  112769. */
  112770. sharpen: SharpenPostProcess;
  112771. private _sharpenEffect;
  112772. private bloom;
  112773. /**
  112774. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  112775. */
  112776. depthOfField: DepthOfFieldEffect;
  112777. /**
  112778. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  112779. */
  112780. fxaa: FxaaPostProcess;
  112781. /**
  112782. * Image post processing pass used to perform operations such as tone mapping or color grading.
  112783. */
  112784. imageProcessing: ImageProcessingPostProcess;
  112785. /**
  112786. * Chromatic aberration post process which will shift rgb colors in the image
  112787. */
  112788. chromaticAberration: ChromaticAberrationPostProcess;
  112789. private _chromaticAberrationEffect;
  112790. /**
  112791. * Grain post process which add noise to the image
  112792. */
  112793. grain: GrainPostProcess;
  112794. private _grainEffect;
  112795. /**
  112796. * Glow post process which adds a glow to emissive areas of the image
  112797. */
  112798. private _glowLayer;
  112799. /**
  112800. * Animations which can be used to tweak settings over a period of time
  112801. */
  112802. animations: Animation[];
  112803. private _imageProcessingConfigurationObserver;
  112804. private _sharpenEnabled;
  112805. private _bloomEnabled;
  112806. private _depthOfFieldEnabled;
  112807. private _depthOfFieldBlurLevel;
  112808. private _fxaaEnabled;
  112809. private _imageProcessingEnabled;
  112810. private _defaultPipelineTextureType;
  112811. private _bloomScale;
  112812. private _chromaticAberrationEnabled;
  112813. private _grainEnabled;
  112814. private _buildAllowed;
  112815. /**
  112816. * Gets active scene
  112817. */
  112818. readonly scene: Scene;
  112819. /**
  112820. * Enable or disable the sharpen process from the pipeline
  112821. */
  112822. sharpenEnabled: boolean;
  112823. private _resizeObserver;
  112824. private _hardwareScaleLevel;
  112825. private _bloomKernel;
  112826. /**
  112827. * Specifies the size of the bloom blur kernel, relative to the final output size
  112828. */
  112829. bloomKernel: number;
  112830. /**
  112831. * Specifies the weight of the bloom in the final rendering
  112832. */
  112833. private _bloomWeight;
  112834. /**
  112835. * Specifies the luma threshold for the area that will be blurred by the bloom
  112836. */
  112837. private _bloomThreshold;
  112838. private _hdr;
  112839. /**
  112840. * The strength of the bloom.
  112841. */
  112842. bloomWeight: number;
  112843. /**
  112844. * The strength of the bloom.
  112845. */
  112846. bloomThreshold: number;
  112847. /**
  112848. * The scale of the bloom, lower value will provide better performance.
  112849. */
  112850. bloomScale: number;
  112851. /**
  112852. * Enable or disable the bloom from the pipeline
  112853. */
  112854. bloomEnabled: boolean;
  112855. private _rebuildBloom;
  112856. /**
  112857. * If the depth of field is enabled.
  112858. */
  112859. depthOfFieldEnabled: boolean;
  112860. /**
  112861. * Blur level of the depth of field effect. (Higher blur will effect performance)
  112862. */
  112863. depthOfFieldBlurLevel: DepthOfFieldEffectBlurLevel;
  112864. /**
  112865. * If the anti aliasing is enabled.
  112866. */
  112867. fxaaEnabled: boolean;
  112868. private _samples;
  112869. /**
  112870. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  112871. */
  112872. samples: number;
  112873. /**
  112874. * If image processing is enabled.
  112875. */
  112876. imageProcessingEnabled: boolean;
  112877. /**
  112878. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  112879. */
  112880. glowLayerEnabled: boolean;
  112881. /**
  112882. * Enable or disable the chromaticAberration process from the pipeline
  112883. */
  112884. chromaticAberrationEnabled: boolean;
  112885. /**
  112886. * Enable or disable the grain process from the pipeline
  112887. */
  112888. grainEnabled: boolean;
  112889. /**
  112890. * @constructor
  112891. * @param name - The rendering pipeline name (default: "")
  112892. * @param hdr - If high dynamic range textures should be used (default: true)
  112893. * @param scene - The scene linked to this pipeline (default: the last created scene)
  112894. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  112895. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  112896. */
  112897. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  112898. /**
  112899. * Get the class name
  112900. * @returns "DefaultRenderingPipeline"
  112901. */
  112902. getClassName(): string;
  112903. /**
  112904. * Force the compilation of the entire pipeline.
  112905. */
  112906. prepare(): void;
  112907. private _hasCleared;
  112908. private _prevPostProcess;
  112909. private _prevPrevPostProcess;
  112910. private _setAutoClearAndTextureSharing;
  112911. private _depthOfFieldSceneObserver;
  112912. private _buildPipeline;
  112913. private _disposePostProcesses;
  112914. /**
  112915. * Adds a camera to the pipeline
  112916. * @param camera the camera to be added
  112917. */
  112918. addCamera(camera: Camera): void;
  112919. /**
  112920. * Removes a camera from the pipeline
  112921. * @param camera the camera to remove
  112922. */
  112923. removeCamera(camera: Camera): void;
  112924. /**
  112925. * Dispose of the pipeline and stop all post processes
  112926. */
  112927. dispose(): void;
  112928. /**
  112929. * Serialize the rendering pipeline (Used when exporting)
  112930. * @returns the serialized object
  112931. */
  112932. serialize(): any;
  112933. /**
  112934. * Parse the serialized pipeline
  112935. * @param source Source pipeline.
  112936. * @param scene The scene to load the pipeline to.
  112937. * @param rootUrl The URL of the serialized pipeline.
  112938. * @returns An instantiated pipeline from the serialized object.
  112939. */
  112940. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  112941. }
  112942. }
  112943. declare module BABYLON {
  112944. /** @hidden */
  112945. export var lensHighlightsPixelShader: {
  112946. name: string;
  112947. shader: string;
  112948. };
  112949. }
  112950. declare module BABYLON {
  112951. /** @hidden */
  112952. export var depthOfFieldPixelShader: {
  112953. name: string;
  112954. shader: string;
  112955. };
  112956. }
  112957. declare module BABYLON {
  112958. /**
  112959. * BABYLON.JS Chromatic Aberration GLSL Shader
  112960. * Author: Olivier Guyot
  112961. * Separates very slightly R, G and B colors on the edges of the screen
  112962. * Inspired by Francois Tarlier & Martins Upitis
  112963. */
  112964. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  112965. /**
  112966. * @ignore
  112967. * The chromatic aberration PostProcess id in the pipeline
  112968. */
  112969. LensChromaticAberrationEffect: string;
  112970. /**
  112971. * @ignore
  112972. * The highlights enhancing PostProcess id in the pipeline
  112973. */
  112974. HighlightsEnhancingEffect: string;
  112975. /**
  112976. * @ignore
  112977. * The depth-of-field PostProcess id in the pipeline
  112978. */
  112979. LensDepthOfFieldEffect: string;
  112980. private _scene;
  112981. private _depthTexture;
  112982. private _grainTexture;
  112983. private _chromaticAberrationPostProcess;
  112984. private _highlightsPostProcess;
  112985. private _depthOfFieldPostProcess;
  112986. private _edgeBlur;
  112987. private _grainAmount;
  112988. private _chromaticAberration;
  112989. private _distortion;
  112990. private _highlightsGain;
  112991. private _highlightsThreshold;
  112992. private _dofDistance;
  112993. private _dofAperture;
  112994. private _dofDarken;
  112995. private _dofPentagon;
  112996. private _blurNoise;
  112997. /**
  112998. * @constructor
  112999. *
  113000. * Effect parameters are as follow:
  113001. * {
  113002. * chromatic_aberration: number; // from 0 to x (1 for realism)
  113003. * edge_blur: number; // from 0 to x (1 for realism)
  113004. * distortion: number; // from 0 to x (1 for realism)
  113005. * grain_amount: number; // from 0 to 1
  113006. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  113007. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  113008. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  113009. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  113010. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  113011. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  113012. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  113013. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  113014. * }
  113015. * Note: if an effect parameter is unset, effect is disabled
  113016. *
  113017. * @param name The rendering pipeline name
  113018. * @param parameters - An object containing all parameters (see above)
  113019. * @param scene The scene linked to this pipeline
  113020. * @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)
  113021. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113022. */
  113023. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  113024. /**
  113025. * Get the class name
  113026. * @returns "LensRenderingPipeline"
  113027. */
  113028. getClassName(): string;
  113029. /**
  113030. * Gets associated scene
  113031. */
  113032. readonly scene: Scene;
  113033. /**
  113034. * Gets or sets the edge blur
  113035. */
  113036. edgeBlur: number;
  113037. /**
  113038. * Gets or sets the grain amount
  113039. */
  113040. grainAmount: number;
  113041. /**
  113042. * Gets or sets the chromatic aberration amount
  113043. */
  113044. chromaticAberration: number;
  113045. /**
  113046. * Gets or sets the depth of field aperture
  113047. */
  113048. dofAperture: number;
  113049. /**
  113050. * Gets or sets the edge distortion
  113051. */
  113052. edgeDistortion: number;
  113053. /**
  113054. * Gets or sets the depth of field distortion
  113055. */
  113056. dofDistortion: number;
  113057. /**
  113058. * Gets or sets the darken out of focus amount
  113059. */
  113060. darkenOutOfFocus: number;
  113061. /**
  113062. * Gets or sets a boolean indicating if blur noise is enabled
  113063. */
  113064. blurNoise: boolean;
  113065. /**
  113066. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  113067. */
  113068. pentagonBokeh: boolean;
  113069. /**
  113070. * Gets or sets the highlight grain amount
  113071. */
  113072. highlightsGain: number;
  113073. /**
  113074. * Gets or sets the highlight threshold
  113075. */
  113076. highlightsThreshold: number;
  113077. /**
  113078. * Sets the amount of blur at the edges
  113079. * @param amount blur amount
  113080. */
  113081. setEdgeBlur(amount: number): void;
  113082. /**
  113083. * Sets edge blur to 0
  113084. */
  113085. disableEdgeBlur(): void;
  113086. /**
  113087. * Sets the amout of grain
  113088. * @param amount Amount of grain
  113089. */
  113090. setGrainAmount(amount: number): void;
  113091. /**
  113092. * Set grain amount to 0
  113093. */
  113094. disableGrain(): void;
  113095. /**
  113096. * Sets the chromatic aberration amount
  113097. * @param amount amount of chromatic aberration
  113098. */
  113099. setChromaticAberration(amount: number): void;
  113100. /**
  113101. * Sets chromatic aberration amount to 0
  113102. */
  113103. disableChromaticAberration(): void;
  113104. /**
  113105. * Sets the EdgeDistortion amount
  113106. * @param amount amount of EdgeDistortion
  113107. */
  113108. setEdgeDistortion(amount: number): void;
  113109. /**
  113110. * Sets edge distortion to 0
  113111. */
  113112. disableEdgeDistortion(): void;
  113113. /**
  113114. * Sets the FocusDistance amount
  113115. * @param amount amount of FocusDistance
  113116. */
  113117. setFocusDistance(amount: number): void;
  113118. /**
  113119. * Disables depth of field
  113120. */
  113121. disableDepthOfField(): void;
  113122. /**
  113123. * Sets the Aperture amount
  113124. * @param amount amount of Aperture
  113125. */
  113126. setAperture(amount: number): void;
  113127. /**
  113128. * Sets the DarkenOutOfFocus amount
  113129. * @param amount amount of DarkenOutOfFocus
  113130. */
  113131. setDarkenOutOfFocus(amount: number): void;
  113132. private _pentagonBokehIsEnabled;
  113133. /**
  113134. * Creates a pentagon bokeh effect
  113135. */
  113136. enablePentagonBokeh(): void;
  113137. /**
  113138. * Disables the pentagon bokeh effect
  113139. */
  113140. disablePentagonBokeh(): void;
  113141. /**
  113142. * Enables noise blur
  113143. */
  113144. enableNoiseBlur(): void;
  113145. /**
  113146. * Disables noise blur
  113147. */
  113148. disableNoiseBlur(): void;
  113149. /**
  113150. * Sets the HighlightsGain amount
  113151. * @param amount amount of HighlightsGain
  113152. */
  113153. setHighlightsGain(amount: number): void;
  113154. /**
  113155. * Sets the HighlightsThreshold amount
  113156. * @param amount amount of HighlightsThreshold
  113157. */
  113158. setHighlightsThreshold(amount: number): void;
  113159. /**
  113160. * Disables highlights
  113161. */
  113162. disableHighlights(): void;
  113163. /**
  113164. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  113165. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  113166. */
  113167. dispose(disableDepthRender?: boolean): void;
  113168. private _createChromaticAberrationPostProcess;
  113169. private _createHighlightsPostProcess;
  113170. private _createDepthOfFieldPostProcess;
  113171. private _createGrainTexture;
  113172. }
  113173. }
  113174. declare module BABYLON {
  113175. /** @hidden */
  113176. export var ssao2PixelShader: {
  113177. name: string;
  113178. shader: string;
  113179. };
  113180. }
  113181. declare module BABYLON {
  113182. /** @hidden */
  113183. export var ssaoCombinePixelShader: {
  113184. name: string;
  113185. shader: string;
  113186. };
  113187. }
  113188. declare module BABYLON {
  113189. /**
  113190. * Render pipeline to produce ssao effect
  113191. */
  113192. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  113193. /**
  113194. * @ignore
  113195. * The PassPostProcess id in the pipeline that contains the original scene color
  113196. */
  113197. SSAOOriginalSceneColorEffect: string;
  113198. /**
  113199. * @ignore
  113200. * The SSAO PostProcess id in the pipeline
  113201. */
  113202. SSAORenderEffect: string;
  113203. /**
  113204. * @ignore
  113205. * The horizontal blur PostProcess id in the pipeline
  113206. */
  113207. SSAOBlurHRenderEffect: string;
  113208. /**
  113209. * @ignore
  113210. * The vertical blur PostProcess id in the pipeline
  113211. */
  113212. SSAOBlurVRenderEffect: string;
  113213. /**
  113214. * @ignore
  113215. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113216. */
  113217. SSAOCombineRenderEffect: string;
  113218. /**
  113219. * The output strength of the SSAO post-process. Default value is 1.0.
  113220. */
  113221. totalStrength: number;
  113222. /**
  113223. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  113224. */
  113225. maxZ: number;
  113226. /**
  113227. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  113228. */
  113229. minZAspect: number;
  113230. private _samples;
  113231. /**
  113232. * Number of samples used for the SSAO calculations. Default value is 8
  113233. */
  113234. samples: number;
  113235. private _textureSamples;
  113236. /**
  113237. * Number of samples to use for antialiasing
  113238. */
  113239. textureSamples: number;
  113240. /**
  113241. * Ratio object used for SSAO ratio and blur ratio
  113242. */
  113243. private _ratio;
  113244. /**
  113245. * Dynamically generated sphere sampler.
  113246. */
  113247. private _sampleSphere;
  113248. /**
  113249. * Blur filter offsets
  113250. */
  113251. private _samplerOffsets;
  113252. private _expensiveBlur;
  113253. /**
  113254. * If bilateral blur should be used
  113255. */
  113256. expensiveBlur: boolean;
  113257. /**
  113258. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  113259. */
  113260. radius: number;
  113261. /**
  113262. * The base color of the SSAO post-process
  113263. * The final result is "base + ssao" between [0, 1]
  113264. */
  113265. base: number;
  113266. /**
  113267. * Support test.
  113268. */
  113269. static readonly IsSupported: boolean;
  113270. private _scene;
  113271. private _depthTexture;
  113272. private _normalTexture;
  113273. private _randomTexture;
  113274. private _originalColorPostProcess;
  113275. private _ssaoPostProcess;
  113276. private _blurHPostProcess;
  113277. private _blurVPostProcess;
  113278. private _ssaoCombinePostProcess;
  113279. private _firstUpdate;
  113280. /**
  113281. * Gets active scene
  113282. */
  113283. readonly scene: Scene;
  113284. /**
  113285. * @constructor
  113286. * @param name The rendering pipeline name
  113287. * @param scene The scene linked to this pipeline
  113288. * @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 }
  113289. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113290. */
  113291. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113292. /**
  113293. * Get the class name
  113294. * @returns "SSAO2RenderingPipeline"
  113295. */
  113296. getClassName(): string;
  113297. /**
  113298. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113299. */
  113300. dispose(disableGeometryBufferRenderer?: boolean): void;
  113301. private _createBlurPostProcess;
  113302. /** @hidden */
  113303. _rebuild(): void;
  113304. private _bits;
  113305. private _radicalInverse_VdC;
  113306. private _hammersley;
  113307. private _hemisphereSample_uniform;
  113308. private _generateHemisphere;
  113309. private _createSSAOPostProcess;
  113310. private _createSSAOCombinePostProcess;
  113311. private _createRandomTexture;
  113312. /**
  113313. * Serialize the rendering pipeline (Used when exporting)
  113314. * @returns the serialized object
  113315. */
  113316. serialize(): any;
  113317. /**
  113318. * Parse the serialized pipeline
  113319. * @param source Source pipeline.
  113320. * @param scene The scene to load the pipeline to.
  113321. * @param rootUrl The URL of the serialized pipeline.
  113322. * @returns An instantiated pipeline from the serialized object.
  113323. */
  113324. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  113325. }
  113326. }
  113327. declare module BABYLON {
  113328. /** @hidden */
  113329. export var ssaoPixelShader: {
  113330. name: string;
  113331. shader: string;
  113332. };
  113333. }
  113334. declare module BABYLON {
  113335. /**
  113336. * Render pipeline to produce ssao effect
  113337. */
  113338. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  113339. /**
  113340. * @ignore
  113341. * The PassPostProcess id in the pipeline that contains the original scene color
  113342. */
  113343. SSAOOriginalSceneColorEffect: string;
  113344. /**
  113345. * @ignore
  113346. * The SSAO PostProcess id in the pipeline
  113347. */
  113348. SSAORenderEffect: string;
  113349. /**
  113350. * @ignore
  113351. * The horizontal blur PostProcess id in the pipeline
  113352. */
  113353. SSAOBlurHRenderEffect: string;
  113354. /**
  113355. * @ignore
  113356. * The vertical blur PostProcess id in the pipeline
  113357. */
  113358. SSAOBlurVRenderEffect: string;
  113359. /**
  113360. * @ignore
  113361. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  113362. */
  113363. SSAOCombineRenderEffect: string;
  113364. /**
  113365. * The output strength of the SSAO post-process. Default value is 1.0.
  113366. */
  113367. totalStrength: number;
  113368. /**
  113369. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  113370. */
  113371. radius: number;
  113372. /**
  113373. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  113374. * Must not be equal to fallOff and superior to fallOff.
  113375. * Default value is 0.0075
  113376. */
  113377. area: number;
  113378. /**
  113379. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  113380. * Must not be equal to area and inferior to area.
  113381. * Default value is 0.000001
  113382. */
  113383. fallOff: number;
  113384. /**
  113385. * The base color of the SSAO post-process
  113386. * The final result is "base + ssao" between [0, 1]
  113387. */
  113388. base: number;
  113389. private _scene;
  113390. private _depthTexture;
  113391. private _randomTexture;
  113392. private _originalColorPostProcess;
  113393. private _ssaoPostProcess;
  113394. private _blurHPostProcess;
  113395. private _blurVPostProcess;
  113396. private _ssaoCombinePostProcess;
  113397. private _firstUpdate;
  113398. /**
  113399. * Gets active scene
  113400. */
  113401. readonly scene: Scene;
  113402. /**
  113403. * @constructor
  113404. * @param name - The rendering pipeline name
  113405. * @param scene - The scene linked to this pipeline
  113406. * @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 }
  113407. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  113408. */
  113409. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  113410. /**
  113411. * Get the class name
  113412. * @returns "SSAORenderingPipeline"
  113413. */
  113414. getClassName(): string;
  113415. /**
  113416. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  113417. */
  113418. dispose(disableDepthRender?: boolean): void;
  113419. private _createBlurPostProcess;
  113420. /** @hidden */
  113421. _rebuild(): void;
  113422. private _createSSAOPostProcess;
  113423. private _createSSAOCombinePostProcess;
  113424. private _createRandomTexture;
  113425. }
  113426. }
  113427. declare module BABYLON {
  113428. /** @hidden */
  113429. export var standardPixelShader: {
  113430. name: string;
  113431. shader: string;
  113432. };
  113433. }
  113434. declare module BABYLON {
  113435. /**
  113436. * Standard rendering pipeline
  113437. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113438. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  113439. */
  113440. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  113441. /**
  113442. * Public members
  113443. */
  113444. /**
  113445. * Post-process which contains the original scene color before the pipeline applies all the effects
  113446. */
  113447. originalPostProcess: Nullable<PostProcess>;
  113448. /**
  113449. * Post-process used to down scale an image x4
  113450. */
  113451. downSampleX4PostProcess: Nullable<PostProcess>;
  113452. /**
  113453. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  113454. */
  113455. brightPassPostProcess: Nullable<PostProcess>;
  113456. /**
  113457. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  113458. */
  113459. blurHPostProcesses: PostProcess[];
  113460. /**
  113461. * Post-process array storing all the vertical blur post-processes used by the pipeline
  113462. */
  113463. blurVPostProcesses: PostProcess[];
  113464. /**
  113465. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  113466. */
  113467. textureAdderPostProcess: Nullable<PostProcess>;
  113468. /**
  113469. * Post-process used to create volumetric lighting effect
  113470. */
  113471. volumetricLightPostProcess: Nullable<PostProcess>;
  113472. /**
  113473. * Post-process used to smooth the previous volumetric light post-process on the X axis
  113474. */
  113475. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  113476. /**
  113477. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  113478. */
  113479. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  113480. /**
  113481. * Post-process used to merge the volumetric light effect and the real scene color
  113482. */
  113483. volumetricLightMergePostProces: Nullable<PostProcess>;
  113484. /**
  113485. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  113486. */
  113487. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  113488. /**
  113489. * Base post-process used to calculate the average luminance of the final image for HDR
  113490. */
  113491. luminancePostProcess: Nullable<PostProcess>;
  113492. /**
  113493. * Post-processes used to create down sample post-processes in order to get
  113494. * the average luminance of the final image for HDR
  113495. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  113496. */
  113497. luminanceDownSamplePostProcesses: PostProcess[];
  113498. /**
  113499. * Post-process used to create a HDR effect (light adaptation)
  113500. */
  113501. hdrPostProcess: Nullable<PostProcess>;
  113502. /**
  113503. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  113504. */
  113505. textureAdderFinalPostProcess: Nullable<PostProcess>;
  113506. /**
  113507. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  113508. */
  113509. lensFlareFinalPostProcess: Nullable<PostProcess>;
  113510. /**
  113511. * Post-process used to merge the final HDR post-process and the real scene color
  113512. */
  113513. hdrFinalPostProcess: Nullable<PostProcess>;
  113514. /**
  113515. * Post-process used to create a lens flare effect
  113516. */
  113517. lensFlarePostProcess: Nullable<PostProcess>;
  113518. /**
  113519. * Post-process that merges the result of the lens flare post-process and the real scene color
  113520. */
  113521. lensFlareComposePostProcess: Nullable<PostProcess>;
  113522. /**
  113523. * Post-process used to create a motion blur effect
  113524. */
  113525. motionBlurPostProcess: Nullable<PostProcess>;
  113526. /**
  113527. * Post-process used to create a depth of field effect
  113528. */
  113529. depthOfFieldPostProcess: Nullable<PostProcess>;
  113530. /**
  113531. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  113532. */
  113533. fxaaPostProcess: Nullable<FxaaPostProcess>;
  113534. /**
  113535. * Represents the brightness threshold in order to configure the illuminated surfaces
  113536. */
  113537. brightThreshold: number;
  113538. /**
  113539. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  113540. */
  113541. blurWidth: number;
  113542. /**
  113543. * Sets if the blur for highlighted surfaces must be only horizontal
  113544. */
  113545. horizontalBlur: boolean;
  113546. /**
  113547. * Gets the overall exposure used by the pipeline
  113548. */
  113549. /**
  113550. * Sets the overall exposure used by the pipeline
  113551. */
  113552. exposure: number;
  113553. /**
  113554. * Texture used typically to simulate "dirty" on camera lens
  113555. */
  113556. lensTexture: Nullable<Texture>;
  113557. /**
  113558. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  113559. */
  113560. volumetricLightCoefficient: number;
  113561. /**
  113562. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  113563. */
  113564. volumetricLightPower: number;
  113565. /**
  113566. * Used the set the blur intensity to smooth the volumetric lights
  113567. */
  113568. volumetricLightBlurScale: number;
  113569. /**
  113570. * Light (spot or directional) used to generate the volumetric lights rays
  113571. * The source light must have a shadow generate so the pipeline can get its
  113572. * depth map
  113573. */
  113574. sourceLight: Nullable<SpotLight | DirectionalLight>;
  113575. /**
  113576. * For eye adaptation, represents the minimum luminance the eye can see
  113577. */
  113578. hdrMinimumLuminance: number;
  113579. /**
  113580. * For eye adaptation, represents the decrease luminance speed
  113581. */
  113582. hdrDecreaseRate: number;
  113583. /**
  113584. * For eye adaptation, represents the increase luminance speed
  113585. */
  113586. hdrIncreaseRate: number;
  113587. /**
  113588. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113589. */
  113590. /**
  113591. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  113592. */
  113593. hdrAutoExposure: boolean;
  113594. /**
  113595. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  113596. */
  113597. lensColorTexture: Nullable<Texture>;
  113598. /**
  113599. * The overall strengh for the lens flare effect
  113600. */
  113601. lensFlareStrength: number;
  113602. /**
  113603. * Dispersion coefficient for lens flare ghosts
  113604. */
  113605. lensFlareGhostDispersal: number;
  113606. /**
  113607. * Main lens flare halo width
  113608. */
  113609. lensFlareHaloWidth: number;
  113610. /**
  113611. * Based on the lens distortion effect, defines how much the lens flare result
  113612. * is distorted
  113613. */
  113614. lensFlareDistortionStrength: number;
  113615. /**
  113616. * Lens star texture must be used to simulate rays on the flares and is available
  113617. * in the documentation
  113618. */
  113619. lensStarTexture: Nullable<Texture>;
  113620. /**
  113621. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  113622. * flare effect by taking account of the dirt texture
  113623. */
  113624. lensFlareDirtTexture: Nullable<Texture>;
  113625. /**
  113626. * Represents the focal length for the depth of field effect
  113627. */
  113628. depthOfFieldDistance: number;
  113629. /**
  113630. * Represents the blur intensity for the blurred part of the depth of field effect
  113631. */
  113632. depthOfFieldBlurWidth: number;
  113633. /**
  113634. * For motion blur, defines how much the image is blurred by the movement
  113635. */
  113636. motionStrength: number;
  113637. /**
  113638. * List of animations for the pipeline (IAnimatable implementation)
  113639. */
  113640. animations: Animation[];
  113641. /**
  113642. * Private members
  113643. */
  113644. private _scene;
  113645. private _currentDepthOfFieldSource;
  113646. private _basePostProcess;
  113647. private _fixedExposure;
  113648. private _currentExposure;
  113649. private _hdrAutoExposure;
  113650. private _hdrCurrentLuminance;
  113651. private _floatTextureType;
  113652. private _ratio;
  113653. private _bloomEnabled;
  113654. private _depthOfFieldEnabled;
  113655. private _vlsEnabled;
  113656. private _lensFlareEnabled;
  113657. private _hdrEnabled;
  113658. private _motionBlurEnabled;
  113659. private _fxaaEnabled;
  113660. private _motionBlurSamples;
  113661. private _volumetricLightStepsCount;
  113662. private _samples;
  113663. /**
  113664. * @ignore
  113665. * Specifies if the bloom pipeline is enabled
  113666. */
  113667. BloomEnabled: boolean;
  113668. /**
  113669. * @ignore
  113670. * Specifies if the depth of field pipeline is enabed
  113671. */
  113672. DepthOfFieldEnabled: boolean;
  113673. /**
  113674. * @ignore
  113675. * Specifies if the lens flare pipeline is enabed
  113676. */
  113677. LensFlareEnabled: boolean;
  113678. /**
  113679. * @ignore
  113680. * Specifies if the HDR pipeline is enabled
  113681. */
  113682. HDREnabled: boolean;
  113683. /**
  113684. * @ignore
  113685. * Specifies if the volumetric lights scattering effect is enabled
  113686. */
  113687. VLSEnabled: boolean;
  113688. /**
  113689. * @ignore
  113690. * Specifies if the motion blur effect is enabled
  113691. */
  113692. MotionBlurEnabled: boolean;
  113693. /**
  113694. * Specifies if anti-aliasing is enabled
  113695. */
  113696. fxaaEnabled: boolean;
  113697. /**
  113698. * Specifies the number of steps used to calculate the volumetric lights
  113699. * Typically in interval [50, 200]
  113700. */
  113701. volumetricLightStepsCount: number;
  113702. /**
  113703. * Specifies the number of samples used for the motion blur effect
  113704. * Typically in interval [16, 64]
  113705. */
  113706. motionBlurSamples: number;
  113707. /**
  113708. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113709. */
  113710. samples: number;
  113711. /**
  113712. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  113713. * @constructor
  113714. * @param name The rendering pipeline name
  113715. * @param scene The scene linked to this pipeline
  113716. * @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)
  113717. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  113718. * @param cameras The array of cameras that the rendering pipeline will be attached to
  113719. */
  113720. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  113721. private _buildPipeline;
  113722. private _createDownSampleX4PostProcess;
  113723. private _createBrightPassPostProcess;
  113724. private _createBlurPostProcesses;
  113725. private _createTextureAdderPostProcess;
  113726. private _createVolumetricLightPostProcess;
  113727. private _createLuminancePostProcesses;
  113728. private _createHdrPostProcess;
  113729. private _createLensFlarePostProcess;
  113730. private _createDepthOfFieldPostProcess;
  113731. private _createMotionBlurPostProcess;
  113732. private _getDepthTexture;
  113733. private _disposePostProcesses;
  113734. /**
  113735. * Dispose of the pipeline and stop all post processes
  113736. */
  113737. dispose(): void;
  113738. /**
  113739. * Serialize the rendering pipeline (Used when exporting)
  113740. * @returns the serialized object
  113741. */
  113742. serialize(): any;
  113743. /**
  113744. * Parse the serialized pipeline
  113745. * @param source Source pipeline.
  113746. * @param scene The scene to load the pipeline to.
  113747. * @param rootUrl The URL of the serialized pipeline.
  113748. * @returns An instantiated pipeline from the serialized object.
  113749. */
  113750. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  113751. /**
  113752. * Luminance steps
  113753. */
  113754. static LuminanceSteps: number;
  113755. }
  113756. }
  113757. declare module BABYLON {
  113758. /** @hidden */
  113759. export var tonemapPixelShader: {
  113760. name: string;
  113761. shader: string;
  113762. };
  113763. }
  113764. declare module BABYLON {
  113765. /** Defines operator used for tonemapping */
  113766. export enum TonemappingOperator {
  113767. /** Hable */
  113768. Hable = 0,
  113769. /** Reinhard */
  113770. Reinhard = 1,
  113771. /** HejiDawson */
  113772. HejiDawson = 2,
  113773. /** Photographic */
  113774. Photographic = 3
  113775. }
  113776. /**
  113777. * Defines a post process to apply tone mapping
  113778. */
  113779. export class TonemapPostProcess extends PostProcess {
  113780. private _operator;
  113781. /** Defines the required exposure adjustement */
  113782. exposureAdjustment: number;
  113783. /**
  113784. * Creates a new TonemapPostProcess
  113785. * @param name defines the name of the postprocess
  113786. * @param _operator defines the operator to use
  113787. * @param exposureAdjustment defines the required exposure adjustement
  113788. * @param camera defines the camera to use (can be null)
  113789. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  113790. * @param engine defines the hosting engine (can be ignore if camera is set)
  113791. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  113792. */
  113793. constructor(name: string, _operator: TonemappingOperator,
  113794. /** Defines the required exposure adjustement */
  113795. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  113796. }
  113797. }
  113798. declare module BABYLON {
  113799. /** @hidden */
  113800. export var depthVertexShader: {
  113801. name: string;
  113802. shader: string;
  113803. };
  113804. }
  113805. declare module BABYLON {
  113806. /** @hidden */
  113807. export var volumetricLightScatteringPixelShader: {
  113808. name: string;
  113809. shader: string;
  113810. };
  113811. }
  113812. declare module BABYLON {
  113813. /** @hidden */
  113814. export var volumetricLightScatteringPassPixelShader: {
  113815. name: string;
  113816. shader: string;
  113817. };
  113818. }
  113819. declare module BABYLON {
  113820. /**
  113821. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  113822. */
  113823. export class VolumetricLightScatteringPostProcess extends PostProcess {
  113824. private _volumetricLightScatteringPass;
  113825. private _volumetricLightScatteringRTT;
  113826. private _viewPort;
  113827. private _screenCoordinates;
  113828. private _cachedDefines;
  113829. /**
  113830. * If not undefined, the mesh position is computed from the attached node position
  113831. */
  113832. attachedNode: {
  113833. position: Vector3;
  113834. };
  113835. /**
  113836. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  113837. */
  113838. customMeshPosition: Vector3;
  113839. /**
  113840. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  113841. */
  113842. useCustomMeshPosition: boolean;
  113843. /**
  113844. * If the post-process should inverse the light scattering direction
  113845. */
  113846. invert: boolean;
  113847. /**
  113848. * The internal mesh used by the post-process
  113849. */
  113850. mesh: Mesh;
  113851. /**
  113852. * @hidden
  113853. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  113854. */
  113855. useDiffuseColor: boolean;
  113856. /**
  113857. * Array containing the excluded meshes not rendered in the internal pass
  113858. */
  113859. excludedMeshes: AbstractMesh[];
  113860. /**
  113861. * Controls the overall intensity of the post-process
  113862. */
  113863. exposure: number;
  113864. /**
  113865. * Dissipates each sample's contribution in range [0, 1]
  113866. */
  113867. decay: number;
  113868. /**
  113869. * Controls the overall intensity of each sample
  113870. */
  113871. weight: number;
  113872. /**
  113873. * Controls the density of each sample
  113874. */
  113875. density: number;
  113876. /**
  113877. * @constructor
  113878. * @param name The post-process name
  113879. * @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)
  113880. * @param camera The camera that the post-process will be attached to
  113881. * @param mesh The mesh used to create the light scattering
  113882. * @param samples The post-process quality, default 100
  113883. * @param samplingModeThe post-process filtering mode
  113884. * @param engine The babylon engine
  113885. * @param reusable If the post-process is reusable
  113886. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  113887. */
  113888. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  113889. /**
  113890. * Returns the string "VolumetricLightScatteringPostProcess"
  113891. * @returns "VolumetricLightScatteringPostProcess"
  113892. */
  113893. getClassName(): string;
  113894. private _isReady;
  113895. /**
  113896. * Sets the new light position for light scattering effect
  113897. * @param position The new custom light position
  113898. */
  113899. setCustomMeshPosition(position: Vector3): void;
  113900. /**
  113901. * Returns the light position for light scattering effect
  113902. * @return Vector3 The custom light position
  113903. */
  113904. getCustomMeshPosition(): Vector3;
  113905. /**
  113906. * Disposes the internal assets and detaches the post-process from the camera
  113907. */
  113908. dispose(camera: Camera): void;
  113909. /**
  113910. * Returns the render target texture used by the post-process
  113911. * @return the render target texture used by the post-process
  113912. */
  113913. getPass(): RenderTargetTexture;
  113914. private _meshExcluded;
  113915. private _createPass;
  113916. private _updateMeshScreenCoordinates;
  113917. /**
  113918. * Creates a default mesh for the Volumeric Light Scattering post-process
  113919. * @param name The mesh name
  113920. * @param scene The scene where to create the mesh
  113921. * @return the default mesh
  113922. */
  113923. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  113924. }
  113925. }
  113926. declare module BABYLON {
  113927. interface Scene {
  113928. /** @hidden (Backing field) */
  113929. _boundingBoxRenderer: BoundingBoxRenderer;
  113930. /** @hidden (Backing field) */
  113931. _forceShowBoundingBoxes: boolean;
  113932. /**
  113933. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  113934. */
  113935. forceShowBoundingBoxes: boolean;
  113936. /**
  113937. * Gets the bounding box renderer associated with the scene
  113938. * @returns a BoundingBoxRenderer
  113939. */
  113940. getBoundingBoxRenderer(): BoundingBoxRenderer;
  113941. }
  113942. interface AbstractMesh {
  113943. /** @hidden (Backing field) */
  113944. _showBoundingBox: boolean;
  113945. /**
  113946. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  113947. */
  113948. showBoundingBox: boolean;
  113949. }
  113950. /**
  113951. * Component responsible of rendering the bounding box of the meshes in a scene.
  113952. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  113953. */
  113954. export class BoundingBoxRenderer implements ISceneComponent {
  113955. /**
  113956. * The component name helpfull to identify the component in the list of scene components.
  113957. */
  113958. readonly name: string;
  113959. /**
  113960. * The scene the component belongs to.
  113961. */
  113962. scene: Scene;
  113963. /**
  113964. * Color of the bounding box lines placed in front of an object
  113965. */
  113966. frontColor: Color3;
  113967. /**
  113968. * Color of the bounding box lines placed behind an object
  113969. */
  113970. backColor: Color3;
  113971. /**
  113972. * Defines if the renderer should show the back lines or not
  113973. */
  113974. showBackLines: boolean;
  113975. /**
  113976. * @hidden
  113977. */
  113978. renderList: SmartArray<BoundingBox>;
  113979. private _colorShader;
  113980. private _vertexBuffers;
  113981. private _indexBuffer;
  113982. /**
  113983. * Instantiates a new bounding box renderer in a scene.
  113984. * @param scene the scene the renderer renders in
  113985. */
  113986. constructor(scene: Scene);
  113987. /**
  113988. * Registers the component in a given scene
  113989. */
  113990. register(): void;
  113991. private _evaluateSubMesh;
  113992. private _activeMesh;
  113993. private _prepareRessources;
  113994. private _createIndexBuffer;
  113995. /**
  113996. * Rebuilds the elements related to this component in case of
  113997. * context lost for instance.
  113998. */
  113999. rebuild(): void;
  114000. /**
  114001. * @hidden
  114002. */
  114003. reset(): void;
  114004. /**
  114005. * Render the bounding boxes of a specific rendering group
  114006. * @param renderingGroupId defines the rendering group to render
  114007. */
  114008. render(renderingGroupId: number): void;
  114009. /**
  114010. * In case of occlusion queries, we can render the occlusion bounding box through this method
  114011. * @param mesh Define the mesh to render the occlusion bounding box for
  114012. */
  114013. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  114014. /**
  114015. * Dispose and release the resources attached to this renderer.
  114016. */
  114017. dispose(): void;
  114018. }
  114019. }
  114020. declare module BABYLON {
  114021. /** @hidden */
  114022. export var depthPixelShader: {
  114023. name: string;
  114024. shader: string;
  114025. };
  114026. }
  114027. declare module BABYLON {
  114028. /**
  114029. * This represents a depth renderer in Babylon.
  114030. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  114031. */
  114032. export class DepthRenderer {
  114033. private _scene;
  114034. private _depthMap;
  114035. private _effect;
  114036. private _cachedDefines;
  114037. private _camera;
  114038. /**
  114039. * Specifiess that the depth renderer will only be used within
  114040. * the camera it is created for.
  114041. * This can help forcing its rendering during the camera processing.
  114042. */
  114043. useOnlyInActiveCamera: boolean;
  114044. /** @hidden */
  114045. static _SceneComponentInitialization: (scene: Scene) => void;
  114046. /**
  114047. * Instantiates a depth renderer
  114048. * @param scene The scene the renderer belongs to
  114049. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  114050. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  114051. */
  114052. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>);
  114053. /**
  114054. * Creates the depth rendering effect and checks if the effect is ready.
  114055. * @param subMesh The submesh to be used to render the depth map of
  114056. * @param useInstances If multiple world instances should be used
  114057. * @returns if the depth renderer is ready to render the depth map
  114058. */
  114059. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114060. /**
  114061. * Gets the texture which the depth map will be written to.
  114062. * @returns The depth map texture
  114063. */
  114064. getDepthMap(): RenderTargetTexture;
  114065. /**
  114066. * Disposes of the depth renderer.
  114067. */
  114068. dispose(): void;
  114069. }
  114070. }
  114071. declare module BABYLON {
  114072. interface Scene {
  114073. /** @hidden (Backing field) */
  114074. _depthRenderer: {
  114075. [id: string]: DepthRenderer;
  114076. };
  114077. /**
  114078. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  114079. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  114080. * @returns the created depth renderer
  114081. */
  114082. enableDepthRenderer(camera?: Nullable<Camera>): DepthRenderer;
  114083. /**
  114084. * Disables a depth renderer for a given camera
  114085. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  114086. */
  114087. disableDepthRenderer(camera?: Nullable<Camera>): void;
  114088. }
  114089. /**
  114090. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  114091. * in several rendering techniques.
  114092. */
  114093. export class DepthRendererSceneComponent implements ISceneComponent {
  114094. /**
  114095. * The component name helpfull to identify the component in the list of scene components.
  114096. */
  114097. readonly name: string;
  114098. /**
  114099. * The scene the component belongs to.
  114100. */
  114101. scene: Scene;
  114102. /**
  114103. * Creates a new instance of the component for the given scene
  114104. * @param scene Defines the scene to register the component in
  114105. */
  114106. constructor(scene: Scene);
  114107. /**
  114108. * Registers the component in a given scene
  114109. */
  114110. register(): void;
  114111. /**
  114112. * Rebuilds the elements related to this component in case of
  114113. * context lost for instance.
  114114. */
  114115. rebuild(): void;
  114116. /**
  114117. * Disposes the component and the associated ressources
  114118. */
  114119. dispose(): void;
  114120. private _gatherRenderTargets;
  114121. private _gatherActiveCameraRenderTargets;
  114122. }
  114123. }
  114124. declare module BABYLON {
  114125. /** @hidden */
  114126. export var outlinePixelShader: {
  114127. name: string;
  114128. shader: string;
  114129. };
  114130. }
  114131. declare module BABYLON {
  114132. /** @hidden */
  114133. export var outlineVertexShader: {
  114134. name: string;
  114135. shader: string;
  114136. };
  114137. }
  114138. declare module BABYLON {
  114139. interface Scene {
  114140. /** @hidden */
  114141. _outlineRenderer: OutlineRenderer;
  114142. /**
  114143. * Gets the outline renderer associated with the scene
  114144. * @returns a OutlineRenderer
  114145. */
  114146. getOutlineRenderer(): OutlineRenderer;
  114147. }
  114148. interface AbstractMesh {
  114149. /** @hidden (Backing field) */
  114150. _renderOutline: boolean;
  114151. /**
  114152. * Gets or sets a boolean indicating if the outline must be rendered as well
  114153. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  114154. */
  114155. renderOutline: boolean;
  114156. /** @hidden (Backing field) */
  114157. _renderOverlay: boolean;
  114158. /**
  114159. * Gets or sets a boolean indicating if the overlay must be rendered as well
  114160. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  114161. */
  114162. renderOverlay: boolean;
  114163. }
  114164. /**
  114165. * This class is responsible to draw bothe outline/overlay of meshes.
  114166. * It should not be used directly but through the available method on mesh.
  114167. */
  114168. export class OutlineRenderer implements ISceneComponent {
  114169. /**
  114170. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  114171. */
  114172. private static _StencilReference;
  114173. /**
  114174. * The name of the component. Each component must have a unique name.
  114175. */
  114176. name: string;
  114177. /**
  114178. * The scene the component belongs to.
  114179. */
  114180. scene: Scene;
  114181. /**
  114182. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  114183. */
  114184. zOffset: number;
  114185. private _engine;
  114186. private _effect;
  114187. private _cachedDefines;
  114188. private _savedDepthWrite;
  114189. /**
  114190. * Instantiates a new outline renderer. (There could be only one per scene).
  114191. * @param scene Defines the scene it belongs to
  114192. */
  114193. constructor(scene: Scene);
  114194. /**
  114195. * Register the component to one instance of a scene.
  114196. */
  114197. register(): void;
  114198. /**
  114199. * Rebuilds the elements related to this component in case of
  114200. * context lost for instance.
  114201. */
  114202. rebuild(): void;
  114203. /**
  114204. * Disposes the component and the associated ressources.
  114205. */
  114206. dispose(): void;
  114207. /**
  114208. * Renders the outline in the canvas.
  114209. * @param subMesh Defines the sumesh to render
  114210. * @param batch Defines the batch of meshes in case of instances
  114211. * @param useOverlay Defines if the rendering is for the overlay or the outline
  114212. */
  114213. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  114214. /**
  114215. * Returns whether or not the outline renderer is ready for a given submesh.
  114216. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  114217. * @param subMesh Defines the submesh to check readyness for
  114218. * @param useInstances Defines wheter wee are trying to render instances or not
  114219. * @returns true if ready otherwise false
  114220. */
  114221. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  114222. private _beforeRenderingMesh;
  114223. private _afterRenderingMesh;
  114224. }
  114225. }
  114226. declare module BABYLON {
  114227. /**
  114228. * Defines the list of states available for a task inside a AssetsManager
  114229. */
  114230. export enum AssetTaskState {
  114231. /**
  114232. * Initialization
  114233. */
  114234. INIT = 0,
  114235. /**
  114236. * Running
  114237. */
  114238. RUNNING = 1,
  114239. /**
  114240. * Done
  114241. */
  114242. DONE = 2,
  114243. /**
  114244. * Error
  114245. */
  114246. ERROR = 3
  114247. }
  114248. /**
  114249. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  114250. */
  114251. export abstract class AbstractAssetTask {
  114252. /**
  114253. * Task name
  114254. */ name: string;
  114255. /**
  114256. * Callback called when the task is successful
  114257. */
  114258. onSuccess: (task: any) => void;
  114259. /**
  114260. * Callback called when the task is not successful
  114261. */
  114262. onError: (task: any, message?: string, exception?: any) => void;
  114263. /**
  114264. * Creates a new AssetsManager
  114265. * @param name defines the name of the task
  114266. */
  114267. constructor(
  114268. /**
  114269. * Task name
  114270. */ name: string);
  114271. private _isCompleted;
  114272. private _taskState;
  114273. private _errorObject;
  114274. /**
  114275. * Get if the task is completed
  114276. */
  114277. readonly isCompleted: boolean;
  114278. /**
  114279. * Gets the current state of the task
  114280. */
  114281. readonly taskState: AssetTaskState;
  114282. /**
  114283. * Gets the current error object (if task is in error)
  114284. */
  114285. readonly errorObject: {
  114286. message?: string;
  114287. exception?: any;
  114288. };
  114289. /**
  114290. * Internal only
  114291. * @hidden
  114292. */
  114293. _setErrorObject(message?: string, exception?: any): void;
  114294. /**
  114295. * Execute the current task
  114296. * @param scene defines the scene where you want your assets to be loaded
  114297. * @param onSuccess is a callback called when the task is successfully executed
  114298. * @param onError is a callback called if an error occurs
  114299. */
  114300. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114301. /**
  114302. * Execute the current task
  114303. * @param scene defines the scene where you want your assets to be loaded
  114304. * @param onSuccess is a callback called when the task is successfully executed
  114305. * @param onError is a callback called if an error occurs
  114306. */
  114307. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114308. /**
  114309. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  114310. * This can be used with failed tasks that have the reason for failure fixed.
  114311. */
  114312. reset(): void;
  114313. private onErrorCallback;
  114314. private onDoneCallback;
  114315. }
  114316. /**
  114317. * Define the interface used by progress events raised during assets loading
  114318. */
  114319. export interface IAssetsProgressEvent {
  114320. /**
  114321. * Defines the number of remaining tasks to process
  114322. */
  114323. remainingCount: number;
  114324. /**
  114325. * Defines the total number of tasks
  114326. */
  114327. totalCount: number;
  114328. /**
  114329. * Defines the task that was just processed
  114330. */
  114331. task: AbstractAssetTask;
  114332. }
  114333. /**
  114334. * Class used to share progress information about assets loading
  114335. */
  114336. export class AssetsProgressEvent implements IAssetsProgressEvent {
  114337. /**
  114338. * Defines the number of remaining tasks to process
  114339. */
  114340. remainingCount: number;
  114341. /**
  114342. * Defines the total number of tasks
  114343. */
  114344. totalCount: number;
  114345. /**
  114346. * Defines the task that was just processed
  114347. */
  114348. task: AbstractAssetTask;
  114349. /**
  114350. * Creates a AssetsProgressEvent
  114351. * @param remainingCount defines the number of remaining tasks to process
  114352. * @param totalCount defines the total number of tasks
  114353. * @param task defines the task that was just processed
  114354. */
  114355. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  114356. }
  114357. /**
  114358. * Define a task used by AssetsManager to load meshes
  114359. */
  114360. export class MeshAssetTask extends AbstractAssetTask {
  114361. /**
  114362. * Defines the name of the task
  114363. */
  114364. name: string;
  114365. /**
  114366. * Defines the list of mesh's names you want to load
  114367. */
  114368. meshesNames: any;
  114369. /**
  114370. * Defines the root url to use as a base to load your meshes and associated resources
  114371. */
  114372. rootUrl: string;
  114373. /**
  114374. * Defines the filename of the scene to load from
  114375. */
  114376. sceneFilename: string;
  114377. /**
  114378. * Gets the list of loaded meshes
  114379. */
  114380. loadedMeshes: Array<AbstractMesh>;
  114381. /**
  114382. * Gets the list of loaded particle systems
  114383. */
  114384. loadedParticleSystems: Array<IParticleSystem>;
  114385. /**
  114386. * Gets the list of loaded skeletons
  114387. */
  114388. loadedSkeletons: Array<Skeleton>;
  114389. /**
  114390. * Gets the list of loaded animation groups
  114391. */
  114392. loadedAnimationGroups: Array<AnimationGroup>;
  114393. /**
  114394. * Callback called when the task is successful
  114395. */
  114396. onSuccess: (task: MeshAssetTask) => void;
  114397. /**
  114398. * Callback called when the task is successful
  114399. */
  114400. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  114401. /**
  114402. * Creates a new MeshAssetTask
  114403. * @param name defines the name of the task
  114404. * @param meshesNames defines the list of mesh's names you want to load
  114405. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  114406. * @param sceneFilename defines the filename of the scene to load from
  114407. */
  114408. constructor(
  114409. /**
  114410. * Defines the name of the task
  114411. */
  114412. name: string,
  114413. /**
  114414. * Defines the list of mesh's names you want to load
  114415. */
  114416. meshesNames: any,
  114417. /**
  114418. * Defines the root url to use as a base to load your meshes and associated resources
  114419. */
  114420. rootUrl: string,
  114421. /**
  114422. * Defines the filename of the scene to load from
  114423. */
  114424. sceneFilename: string);
  114425. /**
  114426. * Execute the current task
  114427. * @param scene defines the scene where you want your assets to be loaded
  114428. * @param onSuccess is a callback called when the task is successfully executed
  114429. * @param onError is a callback called if an error occurs
  114430. */
  114431. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114432. }
  114433. /**
  114434. * Define a task used by AssetsManager to load text content
  114435. */
  114436. export class TextFileAssetTask extends AbstractAssetTask {
  114437. /**
  114438. * Defines the name of the task
  114439. */
  114440. name: string;
  114441. /**
  114442. * Defines the location of the file to load
  114443. */
  114444. url: string;
  114445. /**
  114446. * Gets the loaded text string
  114447. */
  114448. text: string;
  114449. /**
  114450. * Callback called when the task is successful
  114451. */
  114452. onSuccess: (task: TextFileAssetTask) => void;
  114453. /**
  114454. * Callback called when the task is successful
  114455. */
  114456. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  114457. /**
  114458. * Creates a new TextFileAssetTask object
  114459. * @param name defines the name of the task
  114460. * @param url defines the location of the file to load
  114461. */
  114462. constructor(
  114463. /**
  114464. * Defines the name of the task
  114465. */
  114466. name: string,
  114467. /**
  114468. * Defines the location of the file to load
  114469. */
  114470. url: string);
  114471. /**
  114472. * Execute the current task
  114473. * @param scene defines the scene where you want your assets to be loaded
  114474. * @param onSuccess is a callback called when the task is successfully executed
  114475. * @param onError is a callback called if an error occurs
  114476. */
  114477. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114478. }
  114479. /**
  114480. * Define a task used by AssetsManager to load binary data
  114481. */
  114482. export class BinaryFileAssetTask extends AbstractAssetTask {
  114483. /**
  114484. * Defines the name of the task
  114485. */
  114486. name: string;
  114487. /**
  114488. * Defines the location of the file to load
  114489. */
  114490. url: string;
  114491. /**
  114492. * Gets the lodaded data (as an array buffer)
  114493. */
  114494. data: ArrayBuffer;
  114495. /**
  114496. * Callback called when the task is successful
  114497. */
  114498. onSuccess: (task: BinaryFileAssetTask) => void;
  114499. /**
  114500. * Callback called when the task is successful
  114501. */
  114502. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  114503. /**
  114504. * Creates a new BinaryFileAssetTask object
  114505. * @param name defines the name of the new task
  114506. * @param url defines the location of the file to load
  114507. */
  114508. constructor(
  114509. /**
  114510. * Defines the name of the task
  114511. */
  114512. name: string,
  114513. /**
  114514. * Defines the location of the file to load
  114515. */
  114516. url: string);
  114517. /**
  114518. * Execute the current task
  114519. * @param scene defines the scene where you want your assets to be loaded
  114520. * @param onSuccess is a callback called when the task is successfully executed
  114521. * @param onError is a callback called if an error occurs
  114522. */
  114523. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114524. }
  114525. /**
  114526. * Define a task used by AssetsManager to load images
  114527. */
  114528. export class ImageAssetTask extends AbstractAssetTask {
  114529. /**
  114530. * Defines the name of the task
  114531. */
  114532. name: string;
  114533. /**
  114534. * Defines the location of the image to load
  114535. */
  114536. url: string;
  114537. /**
  114538. * Gets the loaded images
  114539. */
  114540. image: HTMLImageElement;
  114541. /**
  114542. * Callback called when the task is successful
  114543. */
  114544. onSuccess: (task: ImageAssetTask) => void;
  114545. /**
  114546. * Callback called when the task is successful
  114547. */
  114548. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  114549. /**
  114550. * Creates a new ImageAssetTask
  114551. * @param name defines the name of the task
  114552. * @param url defines the location of the image to load
  114553. */
  114554. constructor(
  114555. /**
  114556. * Defines the name of the task
  114557. */
  114558. name: string,
  114559. /**
  114560. * Defines the location of the image to load
  114561. */
  114562. url: string);
  114563. /**
  114564. * Execute the current task
  114565. * @param scene defines the scene where you want your assets to be loaded
  114566. * @param onSuccess is a callback called when the task is successfully executed
  114567. * @param onError is a callback called if an error occurs
  114568. */
  114569. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114570. }
  114571. /**
  114572. * Defines the interface used by texture loading tasks
  114573. */
  114574. export interface ITextureAssetTask<TEX extends BaseTexture> {
  114575. /**
  114576. * Gets the loaded texture
  114577. */
  114578. texture: TEX;
  114579. }
  114580. /**
  114581. * Define a task used by AssetsManager to load 2D textures
  114582. */
  114583. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  114584. /**
  114585. * Defines the name of the task
  114586. */
  114587. name: string;
  114588. /**
  114589. * Defines the location of the file to load
  114590. */
  114591. url: string;
  114592. /**
  114593. * Defines if mipmap should not be generated (default is false)
  114594. */
  114595. noMipmap?: boolean | undefined;
  114596. /**
  114597. * Defines if texture must be inverted on Y axis (default is false)
  114598. */
  114599. invertY?: boolean | undefined;
  114600. /**
  114601. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114602. */
  114603. samplingMode: number;
  114604. /**
  114605. * Gets the loaded texture
  114606. */
  114607. texture: Texture;
  114608. /**
  114609. * Callback called when the task is successful
  114610. */
  114611. onSuccess: (task: TextureAssetTask) => void;
  114612. /**
  114613. * Callback called when the task is successful
  114614. */
  114615. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  114616. /**
  114617. * Creates a new TextureAssetTask object
  114618. * @param name defines the name of the task
  114619. * @param url defines the location of the file to load
  114620. * @param noMipmap defines if mipmap should not be generated (default is false)
  114621. * @param invertY defines if texture must be inverted on Y axis (default is false)
  114622. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114623. */
  114624. constructor(
  114625. /**
  114626. * Defines the name of the task
  114627. */
  114628. name: string,
  114629. /**
  114630. * Defines the location of the file to load
  114631. */
  114632. url: string,
  114633. /**
  114634. * Defines if mipmap should not be generated (default is false)
  114635. */
  114636. noMipmap?: boolean | undefined,
  114637. /**
  114638. * Defines if texture must be inverted on Y axis (default is false)
  114639. */
  114640. invertY?: boolean | undefined,
  114641. /**
  114642. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  114643. */
  114644. samplingMode?: number);
  114645. /**
  114646. * Execute the current task
  114647. * @param scene defines the scene where you want your assets to be loaded
  114648. * @param onSuccess is a callback called when the task is successfully executed
  114649. * @param onError is a callback called if an error occurs
  114650. */
  114651. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114652. }
  114653. /**
  114654. * Define a task used by AssetsManager to load cube textures
  114655. */
  114656. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  114657. /**
  114658. * Defines the name of the task
  114659. */
  114660. name: string;
  114661. /**
  114662. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114663. */
  114664. url: string;
  114665. /**
  114666. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114667. */
  114668. extensions?: string[] | undefined;
  114669. /**
  114670. * Defines if mipmaps should not be generated (default is false)
  114671. */
  114672. noMipmap?: boolean | undefined;
  114673. /**
  114674. * Defines the explicit list of files (undefined by default)
  114675. */
  114676. files?: string[] | undefined;
  114677. /**
  114678. * Gets the loaded texture
  114679. */
  114680. texture: CubeTexture;
  114681. /**
  114682. * Callback called when the task is successful
  114683. */
  114684. onSuccess: (task: CubeTextureAssetTask) => void;
  114685. /**
  114686. * Callback called when the task is successful
  114687. */
  114688. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  114689. /**
  114690. * Creates a new CubeTextureAssetTask
  114691. * @param name defines the name of the task
  114692. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114693. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114694. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114695. * @param files defines the explicit list of files (undefined by default)
  114696. */
  114697. constructor(
  114698. /**
  114699. * Defines the name of the task
  114700. */
  114701. name: string,
  114702. /**
  114703. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  114704. */
  114705. url: string,
  114706. /**
  114707. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  114708. */
  114709. extensions?: string[] | undefined,
  114710. /**
  114711. * Defines if mipmaps should not be generated (default is false)
  114712. */
  114713. noMipmap?: boolean | undefined,
  114714. /**
  114715. * Defines the explicit list of files (undefined by default)
  114716. */
  114717. files?: string[] | undefined);
  114718. /**
  114719. * Execute the current task
  114720. * @param scene defines the scene where you want your assets to be loaded
  114721. * @param onSuccess is a callback called when the task is successfully executed
  114722. * @param onError is a callback called if an error occurs
  114723. */
  114724. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114725. }
  114726. /**
  114727. * Define a task used by AssetsManager to load HDR cube textures
  114728. */
  114729. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  114730. /**
  114731. * Defines the name of the task
  114732. */
  114733. name: string;
  114734. /**
  114735. * Defines the location of the file to load
  114736. */
  114737. url: string;
  114738. /**
  114739. * Defines the desired size (the more it increases the longer the generation will be)
  114740. */
  114741. size: number;
  114742. /**
  114743. * Defines if mipmaps should not be generated (default is false)
  114744. */
  114745. noMipmap: boolean;
  114746. /**
  114747. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114748. */
  114749. generateHarmonics: boolean;
  114750. /**
  114751. * 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)
  114752. */
  114753. gammaSpace: boolean;
  114754. /**
  114755. * Internal Use Only
  114756. */
  114757. reserved: boolean;
  114758. /**
  114759. * Gets the loaded texture
  114760. */
  114761. texture: HDRCubeTexture;
  114762. /**
  114763. * Callback called when the task is successful
  114764. */
  114765. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  114766. /**
  114767. * Callback called when the task is successful
  114768. */
  114769. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  114770. /**
  114771. * Creates a new HDRCubeTextureAssetTask object
  114772. * @param name defines the name of the task
  114773. * @param url defines the location of the file to load
  114774. * @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.
  114775. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114776. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114777. * @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)
  114778. * @param reserved Internal use only
  114779. */
  114780. constructor(
  114781. /**
  114782. * Defines the name of the task
  114783. */
  114784. name: string,
  114785. /**
  114786. * Defines the location of the file to load
  114787. */
  114788. url: string,
  114789. /**
  114790. * Defines the desired size (the more it increases the longer the generation will be)
  114791. */
  114792. size: number,
  114793. /**
  114794. * Defines if mipmaps should not be generated (default is false)
  114795. */
  114796. noMipmap?: boolean,
  114797. /**
  114798. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  114799. */
  114800. generateHarmonics?: boolean,
  114801. /**
  114802. * 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)
  114803. */
  114804. gammaSpace?: boolean,
  114805. /**
  114806. * Internal Use Only
  114807. */
  114808. reserved?: boolean);
  114809. /**
  114810. * Execute the current task
  114811. * @param scene defines the scene where you want your assets to be loaded
  114812. * @param onSuccess is a callback called when the task is successfully executed
  114813. * @param onError is a callback called if an error occurs
  114814. */
  114815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114816. }
  114817. /**
  114818. * Define a task used by AssetsManager to load Equirectangular cube textures
  114819. */
  114820. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  114821. /**
  114822. * Defines the name of the task
  114823. */
  114824. name: string;
  114825. /**
  114826. * Defines the location of the file to load
  114827. */
  114828. url: string;
  114829. /**
  114830. * Defines the desired size (the more it increases the longer the generation will be)
  114831. */
  114832. size: number;
  114833. /**
  114834. * Defines if mipmaps should not be generated (default is false)
  114835. */
  114836. noMipmap: boolean;
  114837. /**
  114838. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114839. * but the standard material would require them in Gamma space) (default is true)
  114840. */
  114841. gammaSpace: boolean;
  114842. /**
  114843. * Gets the loaded texture
  114844. */
  114845. texture: EquiRectangularCubeTexture;
  114846. /**
  114847. * Callback called when the task is successful
  114848. */
  114849. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  114850. /**
  114851. * Callback called when the task is successful
  114852. */
  114853. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  114854. /**
  114855. * Creates a new EquiRectangularCubeTextureAssetTask object
  114856. * @param name defines the name of the task
  114857. * @param url defines the location of the file to load
  114858. * @param size defines the desired size (the more it increases the longer the generation will be)
  114859. * If the size is omitted this implies you are using a preprocessed cubemap.
  114860. * @param noMipmap defines if mipmaps should not be generated (default is false)
  114861. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  114862. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  114863. * (default is true)
  114864. */
  114865. constructor(
  114866. /**
  114867. * Defines the name of the task
  114868. */
  114869. name: string,
  114870. /**
  114871. * Defines the location of the file to load
  114872. */
  114873. url: string,
  114874. /**
  114875. * Defines the desired size (the more it increases the longer the generation will be)
  114876. */
  114877. size: number,
  114878. /**
  114879. * Defines if mipmaps should not be generated (default is false)
  114880. */
  114881. noMipmap?: boolean,
  114882. /**
  114883. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  114884. * but the standard material would require them in Gamma space) (default is true)
  114885. */
  114886. gammaSpace?: boolean);
  114887. /**
  114888. * Execute the current task
  114889. * @param scene defines the scene where you want your assets to be loaded
  114890. * @param onSuccess is a callback called when the task is successfully executed
  114891. * @param onError is a callback called if an error occurs
  114892. */
  114893. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  114894. }
  114895. /**
  114896. * This class can be used to easily import assets into a scene
  114897. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  114898. */
  114899. export class AssetsManager {
  114900. private _scene;
  114901. private _isLoading;
  114902. protected _tasks: AbstractAssetTask[];
  114903. protected _waitingTasksCount: number;
  114904. protected _totalTasksCount: number;
  114905. /**
  114906. * Callback called when all tasks are processed
  114907. */
  114908. onFinish: (tasks: AbstractAssetTask[]) => void;
  114909. /**
  114910. * Callback called when a task is successful
  114911. */
  114912. onTaskSuccess: (task: AbstractAssetTask) => void;
  114913. /**
  114914. * Callback called when a task had an error
  114915. */
  114916. onTaskError: (task: AbstractAssetTask) => void;
  114917. /**
  114918. * Callback called when a task is done (whatever the result is)
  114919. */
  114920. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  114921. /**
  114922. * Observable called when all tasks are processed
  114923. */
  114924. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  114925. /**
  114926. * Observable called when a task had an error
  114927. */
  114928. onTaskErrorObservable: Observable<AbstractAssetTask>;
  114929. /**
  114930. * Observable called when all tasks were executed
  114931. */
  114932. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  114933. /**
  114934. * Observable called when a task is done (whatever the result is)
  114935. */
  114936. onProgressObservable: Observable<IAssetsProgressEvent>;
  114937. /**
  114938. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  114939. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  114940. */
  114941. useDefaultLoadingScreen: boolean;
  114942. /**
  114943. * Creates a new AssetsManager
  114944. * @param scene defines the scene to work on
  114945. */
  114946. constructor(scene: Scene);
  114947. /**
  114948. * Add a MeshAssetTask to the list of active tasks
  114949. * @param taskName defines the name of the new task
  114950. * @param meshesNames defines the name of meshes to load
  114951. * @param rootUrl defines the root url to use to locate files
  114952. * @param sceneFilename defines the filename of the scene file
  114953. * @returns a new MeshAssetTask object
  114954. */
  114955. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  114956. /**
  114957. * Add a TextFileAssetTask to the list of active tasks
  114958. * @param taskName defines the name of the new task
  114959. * @param url defines the url of the file to load
  114960. * @returns a new TextFileAssetTask object
  114961. */
  114962. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  114963. /**
  114964. * Add a BinaryFileAssetTask to the list of active tasks
  114965. * @param taskName defines the name of the new task
  114966. * @param url defines the url of the file to load
  114967. * @returns a new BinaryFileAssetTask object
  114968. */
  114969. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  114970. /**
  114971. * Add a ImageAssetTask to the list of active tasks
  114972. * @param taskName defines the name of the new task
  114973. * @param url defines the url of the file to load
  114974. * @returns a new ImageAssetTask object
  114975. */
  114976. addImageTask(taskName: string, url: string): ImageAssetTask;
  114977. /**
  114978. * Add a TextureAssetTask to the list of active tasks
  114979. * @param taskName defines the name of the new task
  114980. * @param url defines the url of the file to load
  114981. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114982. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  114983. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  114984. * @returns a new TextureAssetTask object
  114985. */
  114986. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  114987. /**
  114988. * Add a CubeTextureAssetTask to the list of active tasks
  114989. * @param taskName defines the name of the new task
  114990. * @param url defines the url of the file to load
  114991. * @param extensions defines the extension to use to load the cube map (can be null)
  114992. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  114993. * @param files defines the list of files to load (can be null)
  114994. * @returns a new CubeTextureAssetTask object
  114995. */
  114996. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  114997. /**
  114998. *
  114999. * Add a HDRCubeTextureAssetTask to the list of active tasks
  115000. * @param taskName defines the name of the new task
  115001. * @param url defines the url of the file to load
  115002. * @param size defines the size you want for the cubemap (can be null)
  115003. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115004. * @param generateHarmonics defines if you want to automatically generate (true by default)
  115005. * @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)
  115006. * @param reserved Internal use only
  115007. * @returns a new HDRCubeTextureAssetTask object
  115008. */
  115009. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  115010. /**
  115011. *
  115012. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  115013. * @param taskName defines the name of the new task
  115014. * @param url defines the url of the file to load
  115015. * @param size defines the size you want for the cubemap (can be null)
  115016. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  115017. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  115018. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  115019. * @returns a new EquiRectangularCubeTextureAssetTask object
  115020. */
  115021. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  115022. /**
  115023. * Remove a task from the assets manager.
  115024. * @param task the task to remove
  115025. */
  115026. removeTask(task: AbstractAssetTask): void;
  115027. private _decreaseWaitingTasksCount;
  115028. private _runTask;
  115029. /**
  115030. * Reset the AssetsManager and remove all tasks
  115031. * @return the current instance of the AssetsManager
  115032. */
  115033. reset(): AssetsManager;
  115034. /**
  115035. * Start the loading process
  115036. * @return the current instance of the AssetsManager
  115037. */
  115038. load(): AssetsManager;
  115039. /**
  115040. * Start the loading process as an async operation
  115041. * @return a promise returning the list of failed tasks
  115042. */
  115043. loadAsync(): Promise<void>;
  115044. }
  115045. }
  115046. declare module BABYLON {
  115047. /**
  115048. * Wrapper class for promise with external resolve and reject.
  115049. */
  115050. export class Deferred<T> {
  115051. /**
  115052. * The promise associated with this deferred object.
  115053. */
  115054. readonly promise: Promise<T>;
  115055. private _resolve;
  115056. private _reject;
  115057. /**
  115058. * The resolve method of the promise associated with this deferred object.
  115059. */
  115060. readonly resolve: (value?: T | PromiseLike<T> | undefined) => void;
  115061. /**
  115062. * The reject method of the promise associated with this deferred object.
  115063. */
  115064. readonly reject: (reason?: any) => void;
  115065. /**
  115066. * Constructor for this deferred object.
  115067. */
  115068. constructor();
  115069. }
  115070. }
  115071. declare module BABYLON {
  115072. /**
  115073. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  115074. */
  115075. export class MeshExploder {
  115076. private _centerMesh;
  115077. private _meshes;
  115078. private _meshesOrigins;
  115079. private _toCenterVectors;
  115080. private _scaledDirection;
  115081. private _newPosition;
  115082. private _centerPosition;
  115083. /**
  115084. * Explodes meshes from a center mesh.
  115085. * @param meshes The meshes to explode.
  115086. * @param centerMesh The mesh to be center of explosion.
  115087. */
  115088. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  115089. private _setCenterMesh;
  115090. /**
  115091. * Get class name
  115092. * @returns "MeshExploder"
  115093. */
  115094. getClassName(): string;
  115095. /**
  115096. * "Exploded meshes"
  115097. * @returns Array of meshes with the centerMesh at index 0.
  115098. */
  115099. getMeshes(): Array<Mesh>;
  115100. /**
  115101. * Explodes meshes giving a specific direction
  115102. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  115103. */
  115104. explode(direction?: number): void;
  115105. }
  115106. }
  115107. declare module BABYLON {
  115108. /**
  115109. * Class used to help managing file picking and drag'n'drop
  115110. */
  115111. export class FilesInput {
  115112. /**
  115113. * List of files ready to be loaded
  115114. */
  115115. static readonly FilesToLoad: {
  115116. [key: string]: File;
  115117. };
  115118. /**
  115119. * Callback called when a file is processed
  115120. */
  115121. onProcessFileCallback: (file: File, name: string, extension: string) => true;
  115122. private _engine;
  115123. private _currentScene;
  115124. private _sceneLoadedCallback;
  115125. private _progressCallback;
  115126. private _additionalRenderLoopLogicCallback;
  115127. private _textureLoadingCallback;
  115128. private _startingProcessingFilesCallback;
  115129. private _onReloadCallback;
  115130. private _errorCallback;
  115131. private _elementToMonitor;
  115132. private _sceneFileToLoad;
  115133. private _filesToLoad;
  115134. /**
  115135. * Creates a new FilesInput
  115136. * @param engine defines the rendering engine
  115137. * @param scene defines the hosting scene
  115138. * @param sceneLoadedCallback callback called when scene is loaded
  115139. * @param progressCallback callback called to track progress
  115140. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  115141. * @param textureLoadingCallback callback called when a texture is loading
  115142. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  115143. * @param onReloadCallback callback called when a reload is requested
  115144. * @param errorCallback callback call if an error occurs
  115145. */
  115146. 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);
  115147. private _dragEnterHandler;
  115148. private _dragOverHandler;
  115149. private _dropHandler;
  115150. /**
  115151. * Calls this function to listen to drag'n'drop events on a specific DOM element
  115152. * @param elementToMonitor defines the DOM element to track
  115153. */
  115154. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  115155. /**
  115156. * Release all associated resources
  115157. */
  115158. dispose(): void;
  115159. private renderFunction;
  115160. private drag;
  115161. private drop;
  115162. private _traverseFolder;
  115163. private _processFiles;
  115164. /**
  115165. * Load files from a drop event
  115166. * @param event defines the drop event to use as source
  115167. */
  115168. loadFiles(event: any): void;
  115169. private _processReload;
  115170. /**
  115171. * Reload the current scene from the loaded files
  115172. */
  115173. reload(): void;
  115174. }
  115175. }
  115176. declare module BABYLON {
  115177. /**
  115178. * Defines the root class used to create scene optimization to use with SceneOptimizer
  115179. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115180. */
  115181. export class SceneOptimization {
  115182. /**
  115183. * Defines the priority of this optimization (0 by default which means first in the list)
  115184. */
  115185. priority: number;
  115186. /**
  115187. * Gets a string describing the action executed by the current optimization
  115188. * @returns description string
  115189. */
  115190. getDescription(): string;
  115191. /**
  115192. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115193. * @param scene defines the current scene where to apply this optimization
  115194. * @param optimizer defines the current optimizer
  115195. * @returns true if everything that can be done was applied
  115196. */
  115197. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115198. /**
  115199. * Creates the SceneOptimization object
  115200. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115201. * @param desc defines the description associated with the optimization
  115202. */
  115203. constructor(
  115204. /**
  115205. * Defines the priority of this optimization (0 by default which means first in the list)
  115206. */
  115207. priority?: number);
  115208. }
  115209. /**
  115210. * Defines an optimization used to reduce the size of render target textures
  115211. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115212. */
  115213. export class TextureOptimization extends SceneOptimization {
  115214. /**
  115215. * Defines the priority of this optimization (0 by default which means first in the list)
  115216. */
  115217. priority: number;
  115218. /**
  115219. * 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
  115220. */
  115221. maximumSize: number;
  115222. /**
  115223. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115224. */
  115225. step: number;
  115226. /**
  115227. * Gets a string describing the action executed by the current optimization
  115228. * @returns description string
  115229. */
  115230. getDescription(): string;
  115231. /**
  115232. * Creates the TextureOptimization object
  115233. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115234. * @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
  115235. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115236. */
  115237. constructor(
  115238. /**
  115239. * Defines the priority of this optimization (0 by default which means first in the list)
  115240. */
  115241. priority?: number,
  115242. /**
  115243. * 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
  115244. */
  115245. maximumSize?: number,
  115246. /**
  115247. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  115248. */
  115249. step?: number);
  115250. /**
  115251. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115252. * @param scene defines the current scene where to apply this optimization
  115253. * @param optimizer defines the current optimizer
  115254. * @returns true if everything that can be done was applied
  115255. */
  115256. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115257. }
  115258. /**
  115259. * Defines an optimization used to increase or decrease the rendering resolution
  115260. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115261. */
  115262. export class HardwareScalingOptimization extends SceneOptimization {
  115263. /**
  115264. * Defines the priority of this optimization (0 by default which means first in the list)
  115265. */
  115266. priority: number;
  115267. /**
  115268. * Defines the maximum scale to use (2 by default)
  115269. */
  115270. maximumScale: number;
  115271. /**
  115272. * Defines the step to use between two passes (0.5 by default)
  115273. */
  115274. step: number;
  115275. private _currentScale;
  115276. private _directionOffset;
  115277. /**
  115278. * Gets a string describing the action executed by the current optimization
  115279. * @return description string
  115280. */
  115281. getDescription(): string;
  115282. /**
  115283. * Creates the HardwareScalingOptimization object
  115284. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115285. * @param maximumScale defines the maximum scale to use (2 by default)
  115286. * @param step defines the step to use between two passes (0.5 by default)
  115287. */
  115288. constructor(
  115289. /**
  115290. * Defines the priority of this optimization (0 by default which means first in the list)
  115291. */
  115292. priority?: number,
  115293. /**
  115294. * Defines the maximum scale to use (2 by default)
  115295. */
  115296. maximumScale?: number,
  115297. /**
  115298. * Defines the step to use between two passes (0.5 by default)
  115299. */
  115300. step?: number);
  115301. /**
  115302. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115303. * @param scene defines the current scene where to apply this optimization
  115304. * @param optimizer defines the current optimizer
  115305. * @returns true if everything that can be done was applied
  115306. */
  115307. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115308. }
  115309. /**
  115310. * Defines an optimization used to remove shadows
  115311. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115312. */
  115313. export class ShadowsOptimization extends SceneOptimization {
  115314. /**
  115315. * Gets a string describing the action executed by the current optimization
  115316. * @return description string
  115317. */
  115318. getDescription(): string;
  115319. /**
  115320. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115321. * @param scene defines the current scene where to apply this optimization
  115322. * @param optimizer defines the current optimizer
  115323. * @returns true if everything that can be done was applied
  115324. */
  115325. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115326. }
  115327. /**
  115328. * Defines an optimization used to turn post-processes off
  115329. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115330. */
  115331. export class PostProcessesOptimization extends SceneOptimization {
  115332. /**
  115333. * Gets a string describing the action executed by the current optimization
  115334. * @return description string
  115335. */
  115336. getDescription(): string;
  115337. /**
  115338. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115339. * @param scene defines the current scene where to apply this optimization
  115340. * @param optimizer defines the current optimizer
  115341. * @returns true if everything that can be done was applied
  115342. */
  115343. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115344. }
  115345. /**
  115346. * Defines an optimization used to turn lens flares off
  115347. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115348. */
  115349. export class LensFlaresOptimization extends SceneOptimization {
  115350. /**
  115351. * Gets a string describing the action executed by the current optimization
  115352. * @return description string
  115353. */
  115354. getDescription(): string;
  115355. /**
  115356. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115357. * @param scene defines the current scene where to apply this optimization
  115358. * @param optimizer defines the current optimizer
  115359. * @returns true if everything that can be done was applied
  115360. */
  115361. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115362. }
  115363. /**
  115364. * Defines an optimization based on user defined callback.
  115365. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115366. */
  115367. export class CustomOptimization extends SceneOptimization {
  115368. /**
  115369. * Callback called to apply the custom optimization.
  115370. */
  115371. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  115372. /**
  115373. * Callback called to get custom description
  115374. */
  115375. onGetDescription: () => string;
  115376. /**
  115377. * Gets a string describing the action executed by the current optimization
  115378. * @returns description string
  115379. */
  115380. getDescription(): string;
  115381. /**
  115382. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115383. * @param scene defines the current scene where to apply this optimization
  115384. * @param optimizer defines the current optimizer
  115385. * @returns true if everything that can be done was applied
  115386. */
  115387. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115388. }
  115389. /**
  115390. * Defines an optimization used to turn particles off
  115391. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115392. */
  115393. export class ParticlesOptimization extends SceneOptimization {
  115394. /**
  115395. * Gets a string describing the action executed by the current optimization
  115396. * @return description string
  115397. */
  115398. getDescription(): string;
  115399. /**
  115400. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115401. * @param scene defines the current scene where to apply this optimization
  115402. * @param optimizer defines the current optimizer
  115403. * @returns true if everything that can be done was applied
  115404. */
  115405. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115406. }
  115407. /**
  115408. * Defines an optimization used to turn render targets off
  115409. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115410. */
  115411. export class RenderTargetsOptimization extends SceneOptimization {
  115412. /**
  115413. * Gets a string describing the action executed by the current optimization
  115414. * @return description string
  115415. */
  115416. getDescription(): string;
  115417. /**
  115418. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115419. * @param scene defines the current scene where to apply this optimization
  115420. * @param optimizer defines the current optimizer
  115421. * @returns true if everything that can be done was applied
  115422. */
  115423. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  115424. }
  115425. /**
  115426. * Defines an optimization used to merge meshes with compatible materials
  115427. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115428. */
  115429. export class MergeMeshesOptimization extends SceneOptimization {
  115430. private static _UpdateSelectionTree;
  115431. /**
  115432. * Gets or sets a boolean which defines if optimization octree has to be updated
  115433. */
  115434. /**
  115435. * Gets or sets a boolean which defines if optimization octree has to be updated
  115436. */
  115437. static UpdateSelectionTree: boolean;
  115438. /**
  115439. * Gets a string describing the action executed by the current optimization
  115440. * @return description string
  115441. */
  115442. getDescription(): string;
  115443. private _canBeMerged;
  115444. /**
  115445. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  115446. * @param scene defines the current scene where to apply this optimization
  115447. * @param optimizer defines the current optimizer
  115448. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  115449. * @returns true if everything that can be done was applied
  115450. */
  115451. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  115452. }
  115453. /**
  115454. * Defines a list of options used by SceneOptimizer
  115455. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115456. */
  115457. export class SceneOptimizerOptions {
  115458. /**
  115459. * Defines the target frame rate to reach (60 by default)
  115460. */
  115461. targetFrameRate: number;
  115462. /**
  115463. * Defines the interval between two checkes (2000ms by default)
  115464. */
  115465. trackerDuration: number;
  115466. /**
  115467. * Gets the list of optimizations to apply
  115468. */
  115469. optimizations: SceneOptimization[];
  115470. /**
  115471. * Creates a new list of options used by SceneOptimizer
  115472. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  115473. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  115474. */
  115475. constructor(
  115476. /**
  115477. * Defines the target frame rate to reach (60 by default)
  115478. */
  115479. targetFrameRate?: number,
  115480. /**
  115481. * Defines the interval between two checkes (2000ms by default)
  115482. */
  115483. trackerDuration?: number);
  115484. /**
  115485. * Add a new optimization
  115486. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  115487. * @returns the current SceneOptimizerOptions
  115488. */
  115489. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  115490. /**
  115491. * Add a new custom optimization
  115492. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  115493. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  115494. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  115495. * @returns the current SceneOptimizerOptions
  115496. */
  115497. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  115498. /**
  115499. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  115500. * @param targetFrameRate defines the target frame rate (60 by default)
  115501. * @returns a SceneOptimizerOptions object
  115502. */
  115503. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115504. /**
  115505. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  115506. * @param targetFrameRate defines the target frame rate (60 by default)
  115507. * @returns a SceneOptimizerOptions object
  115508. */
  115509. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115510. /**
  115511. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  115512. * @param targetFrameRate defines the target frame rate (60 by default)
  115513. * @returns a SceneOptimizerOptions object
  115514. */
  115515. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  115516. }
  115517. /**
  115518. * Class used to run optimizations in order to reach a target frame rate
  115519. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  115520. */
  115521. export class SceneOptimizer implements IDisposable {
  115522. private _isRunning;
  115523. private _options;
  115524. private _scene;
  115525. private _currentPriorityLevel;
  115526. private _targetFrameRate;
  115527. private _trackerDuration;
  115528. private _currentFrameRate;
  115529. private _sceneDisposeObserver;
  115530. private _improvementMode;
  115531. /**
  115532. * Defines an observable called when the optimizer reaches the target frame rate
  115533. */
  115534. onSuccessObservable: Observable<SceneOptimizer>;
  115535. /**
  115536. * Defines an observable called when the optimizer enables an optimization
  115537. */
  115538. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  115539. /**
  115540. * Defines an observable called when the optimizer is not able to reach the target frame rate
  115541. */
  115542. onFailureObservable: Observable<SceneOptimizer>;
  115543. /**
  115544. * Gets a boolean indicating if the optimizer is in improvement mode
  115545. */
  115546. readonly isInImprovementMode: boolean;
  115547. /**
  115548. * Gets the current priority level (0 at start)
  115549. */
  115550. readonly currentPriorityLevel: number;
  115551. /**
  115552. * Gets the current frame rate checked by the SceneOptimizer
  115553. */
  115554. readonly currentFrameRate: number;
  115555. /**
  115556. * Gets or sets the current target frame rate (60 by default)
  115557. */
  115558. /**
  115559. * Gets or sets the current target frame rate (60 by default)
  115560. */
  115561. targetFrameRate: number;
  115562. /**
  115563. * Gets or sets the current interval between two checks (every 2000ms by default)
  115564. */
  115565. /**
  115566. * Gets or sets the current interval between two checks (every 2000ms by default)
  115567. */
  115568. trackerDuration: number;
  115569. /**
  115570. * Gets the list of active optimizations
  115571. */
  115572. readonly optimizations: SceneOptimization[];
  115573. /**
  115574. * Creates a new SceneOptimizer
  115575. * @param scene defines the scene to work on
  115576. * @param options defines the options to use with the SceneOptimizer
  115577. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  115578. * @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)
  115579. */
  115580. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  115581. /**
  115582. * Stops the current optimizer
  115583. */
  115584. stop(): void;
  115585. /**
  115586. * Reset the optimizer to initial step (current priority level = 0)
  115587. */
  115588. reset(): void;
  115589. /**
  115590. * Start the optimizer. By default it will try to reach a specific framerate
  115591. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  115592. */
  115593. start(): void;
  115594. private _checkCurrentState;
  115595. /**
  115596. * Release all resources
  115597. */
  115598. dispose(): void;
  115599. /**
  115600. * Helper function to create a SceneOptimizer with one single line of code
  115601. * @param scene defines the scene to work on
  115602. * @param options defines the options to use with the SceneOptimizer
  115603. * @param onSuccess defines a callback to call on success
  115604. * @param onFailure defines a callback to call on failure
  115605. * @returns the new SceneOptimizer object
  115606. */
  115607. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  115608. }
  115609. }
  115610. declare module BABYLON {
  115611. /**
  115612. * Class used to serialize a scene into a string
  115613. */
  115614. export class SceneSerializer {
  115615. /**
  115616. * Clear cache used by a previous serialization
  115617. */
  115618. static ClearCache(): void;
  115619. /**
  115620. * Serialize a scene into a JSON compatible object
  115621. * @param scene defines the scene to serialize
  115622. * @returns a JSON compatible object
  115623. */
  115624. static Serialize(scene: Scene): any;
  115625. /**
  115626. * Serialize a mesh into a JSON compatible object
  115627. * @param toSerialize defines the mesh to serialize
  115628. * @param withParents defines if parents must be serialized as well
  115629. * @param withChildren defines if children must be serialized as well
  115630. * @returns a JSON compatible object
  115631. */
  115632. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  115633. }
  115634. }
  115635. declare module BABYLON {
  115636. /**
  115637. * Class used to host texture specific utilities
  115638. */
  115639. export class TextureTools {
  115640. /**
  115641. * Uses the GPU to create a copy texture rescaled at a given size
  115642. * @param texture Texture to copy from
  115643. * @param width defines the desired width
  115644. * @param height defines the desired height
  115645. * @param useBilinearMode defines if bilinear mode has to be used
  115646. * @return the generated texture
  115647. */
  115648. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  115649. }
  115650. }
  115651. declare module BABYLON {
  115652. /**
  115653. * This represents the different options avilable for the video capture.
  115654. */
  115655. export interface VideoRecorderOptions {
  115656. /** Defines the mime type of the video */
  115657. mimeType: string;
  115658. /** Defines the video the video should be recorded at */
  115659. fps: number;
  115660. /** Defines the chunk size for the recording data */
  115661. recordChunckSize: number;
  115662. /** The audio tracks to attach to the record */
  115663. audioTracks?: MediaStreamTrack[];
  115664. }
  115665. /**
  115666. * This can helps recording videos from BabylonJS.
  115667. * This is based on the available WebRTC functionalities of the browser.
  115668. *
  115669. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  115670. */
  115671. export class VideoRecorder {
  115672. private static readonly _defaultOptions;
  115673. /**
  115674. * Returns wehther or not the VideoRecorder is available in your browser.
  115675. * @param engine Defines the Babylon Engine to check the support for
  115676. * @returns true if supported otherwise false
  115677. */
  115678. static IsSupported(engine: Engine): boolean;
  115679. private readonly _options;
  115680. private _canvas;
  115681. private _mediaRecorder;
  115682. private _recordedChunks;
  115683. private _fileName;
  115684. private _resolve;
  115685. private _reject;
  115686. /**
  115687. * True wether a recording is already in progress.
  115688. */
  115689. readonly isRecording: boolean;
  115690. /**
  115691. * Create a new VideoCapture object which can help converting what you see in Babylon to
  115692. * a video file.
  115693. * @param engine Defines the BabylonJS Engine you wish to record
  115694. * @param options Defines options that can be used to customized the capture
  115695. */
  115696. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  115697. /**
  115698. * Stops the current recording before the default capture timeout passed in the startRecording
  115699. * functions.
  115700. */
  115701. stopRecording(): void;
  115702. /**
  115703. * Starts recording the canvas for a max duration specified in parameters.
  115704. * @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.
  115705. * @param maxDuration Defines the maximum recording time in seconds.
  115706. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  115707. * @return a promise callback at the end of the recording with the video data in Blob.
  115708. */
  115709. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  115710. /**
  115711. * Releases internal resources used during the recording.
  115712. */
  115713. dispose(): void;
  115714. private _handleDataAvailable;
  115715. private _handleError;
  115716. private _handleStop;
  115717. }
  115718. }
  115719. declare module BABYLON {
  115720. /**
  115721. * Class containing a set of static utilities functions for screenshots
  115722. */
  115723. export class ScreenshotTools {
  115724. /**
  115725. * Captures a screenshot of the current rendering
  115726. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115727. * @param engine defines the rendering engine
  115728. * @param camera defines the source camera
  115729. * @param size This parameter can be set to a single number or to an object with the
  115730. * following (optional) properties: precision, width, height. If a single number is passed,
  115731. * it will be used for both width and height. If an object is passed, the screenshot size
  115732. * will be derived from the parameters. The precision property is a multiplier allowing
  115733. * rendering at a higher or lower resolution
  115734. * @param successCallback defines the callback receives a single parameter which contains the
  115735. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115736. * src parameter of an <img> to display it
  115737. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  115738. * Check your browser for supported MIME types
  115739. */
  115740. static CreateScreenshot(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string): void;
  115741. /**
  115742. * Generates an image screenshot from the specified camera.
  115743. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  115744. * @param engine The engine to use for rendering
  115745. * @param camera The camera to use for rendering
  115746. * @param size This parameter can be set to a single number or to an object with the
  115747. * following (optional) properties: precision, width, height. If a single number is passed,
  115748. * it will be used for both width and height. If an object is passed, the screenshot size
  115749. * will be derived from the parameters. The precision property is a multiplier allowing
  115750. * rendering at a higher or lower resolution
  115751. * @param successCallback The callback receives a single parameter which contains the
  115752. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  115753. * src parameter of an <img> to display it
  115754. * @param mimeType The MIME type of the screenshot image (default: image/png).
  115755. * Check your browser for supported MIME types
  115756. * @param samples Texture samples (default: 1)
  115757. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  115758. * @param fileName A name for for the downloaded file.
  115759. */
  115760. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: any, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  115761. }
  115762. }
  115763. declare module BABYLON {
  115764. /**
  115765. * A cursor which tracks a point on a path
  115766. */
  115767. export class PathCursor {
  115768. private path;
  115769. /**
  115770. * Stores path cursor callbacks for when an onchange event is triggered
  115771. */
  115772. private _onchange;
  115773. /**
  115774. * The value of the path cursor
  115775. */
  115776. value: number;
  115777. /**
  115778. * The animation array of the path cursor
  115779. */
  115780. animations: Animation[];
  115781. /**
  115782. * Initializes the path cursor
  115783. * @param path The path to track
  115784. */
  115785. constructor(path: Path2);
  115786. /**
  115787. * Gets the cursor point on the path
  115788. * @returns A point on the path cursor at the cursor location
  115789. */
  115790. getPoint(): Vector3;
  115791. /**
  115792. * Moves the cursor ahead by the step amount
  115793. * @param step The amount to move the cursor forward
  115794. * @returns This path cursor
  115795. */
  115796. moveAhead(step?: number): PathCursor;
  115797. /**
  115798. * Moves the cursor behind by the step amount
  115799. * @param step The amount to move the cursor back
  115800. * @returns This path cursor
  115801. */
  115802. moveBack(step?: number): PathCursor;
  115803. /**
  115804. * Moves the cursor by the step amount
  115805. * If the step amount is greater than one, an exception is thrown
  115806. * @param step The amount to move the cursor
  115807. * @returns This path cursor
  115808. */
  115809. move(step: number): PathCursor;
  115810. /**
  115811. * Ensures that the value is limited between zero and one
  115812. * @returns This path cursor
  115813. */
  115814. private ensureLimits;
  115815. /**
  115816. * Runs onchange callbacks on change (used by the animation engine)
  115817. * @returns This path cursor
  115818. */
  115819. private raiseOnChange;
  115820. /**
  115821. * Executes a function on change
  115822. * @param f A path cursor onchange callback
  115823. * @returns This path cursor
  115824. */
  115825. onchange(f: (cursor: PathCursor) => void): PathCursor;
  115826. }
  115827. }
  115828. declare module BABYLON {
  115829. /** @hidden */
  115830. export var blurPixelShader: {
  115831. name: string;
  115832. shader: string;
  115833. };
  115834. }
  115835. declare module BABYLON {
  115836. /** @hidden */
  115837. export var bones300Declaration: {
  115838. name: string;
  115839. shader: string;
  115840. };
  115841. }
  115842. declare module BABYLON {
  115843. /** @hidden */
  115844. export var instances300Declaration: {
  115845. name: string;
  115846. shader: string;
  115847. };
  115848. }
  115849. declare module BABYLON {
  115850. /** @hidden */
  115851. export var pointCloudVertexDeclaration: {
  115852. name: string;
  115853. shader: string;
  115854. };
  115855. }
  115856. // Mixins
  115857. interface Window {
  115858. mozIndexedDB: IDBFactory;
  115859. webkitIndexedDB: IDBFactory;
  115860. msIndexedDB: IDBFactory;
  115861. webkitURL: typeof URL;
  115862. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  115863. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  115864. WebGLRenderingContext: WebGLRenderingContext;
  115865. MSGesture: MSGesture;
  115866. CANNON: any;
  115867. AudioContext: AudioContext;
  115868. webkitAudioContext: AudioContext;
  115869. PointerEvent: any;
  115870. Math: Math;
  115871. Uint8Array: Uint8ArrayConstructor;
  115872. Float32Array: Float32ArrayConstructor;
  115873. mozURL: typeof URL;
  115874. msURL: typeof URL;
  115875. VRFrameData: any; // WebVR, from specs 1.1
  115876. DracoDecoderModule: any;
  115877. setImmediate(handler: (...args: any[]) => void): number;
  115878. }
  115879. interface HTMLCanvasElement {
  115880. requestPointerLock(): void;
  115881. msRequestPointerLock?(): void;
  115882. mozRequestPointerLock?(): void;
  115883. webkitRequestPointerLock?(): void;
  115884. /** Track wether a record is in progress */
  115885. isRecording: boolean;
  115886. /** Capture Stream method defined by some browsers */
  115887. captureStream(fps?: number): MediaStream;
  115888. }
  115889. interface CanvasRenderingContext2D {
  115890. msImageSmoothingEnabled: boolean;
  115891. }
  115892. interface MouseEvent {
  115893. mozMovementX: number;
  115894. mozMovementY: number;
  115895. webkitMovementX: number;
  115896. webkitMovementY: number;
  115897. msMovementX: number;
  115898. msMovementY: number;
  115899. }
  115900. interface Navigator {
  115901. mozGetVRDevices: (any: any) => any;
  115902. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115903. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115904. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  115905. webkitGetGamepads(): Gamepad[];
  115906. msGetGamepads(): Gamepad[];
  115907. webkitGamepads(): Gamepad[];
  115908. }
  115909. interface HTMLVideoElement {
  115910. mozSrcObject: any;
  115911. }
  115912. interface Math {
  115913. fround(x: number): number;
  115914. imul(a: number, b: number): number;
  115915. }
  115916. interface WebGLProgram {
  115917. context?: WebGLRenderingContext;
  115918. vertexShader?: WebGLShader;
  115919. fragmentShader?: WebGLShader;
  115920. isParallelCompiled: boolean;
  115921. onCompiled?: () => void;
  115922. }
  115923. interface WebGLRenderingContext {
  115924. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  115925. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  115926. vertexAttribDivisor(index: number, divisor: number): void;
  115927. createVertexArray(): any;
  115928. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  115929. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  115930. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  115931. renderbufferStorageMultisample(target: number, samples: number, internalformat: number, width: number, height: number): void;
  115932. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  115933. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  115934. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  115935. // Queries
  115936. createQuery(): WebGLQuery;
  115937. deleteQuery(query: WebGLQuery): void;
  115938. beginQuery(target: number, query: WebGLQuery): void;
  115939. endQuery(target: number): void;
  115940. getQueryParameter(query: WebGLQuery, pname: number): any;
  115941. getQuery(target: number, pname: number): any;
  115942. MAX_SAMPLES: number;
  115943. RGBA8: number;
  115944. READ_FRAMEBUFFER: number;
  115945. DRAW_FRAMEBUFFER: number;
  115946. UNIFORM_BUFFER: number;
  115947. HALF_FLOAT_OES: number;
  115948. RGBA16F: number;
  115949. RGBA32F: number;
  115950. R32F: number;
  115951. RG32F: number;
  115952. RGB32F: number;
  115953. R16F: number;
  115954. RG16F: number;
  115955. RGB16F: number;
  115956. RED: number;
  115957. RG: number;
  115958. R8: number;
  115959. RG8: number;
  115960. UNSIGNED_INT_24_8: number;
  115961. DEPTH24_STENCIL8: number;
  115962. /* Multiple Render Targets */
  115963. drawBuffers(buffers: number[]): void;
  115964. readBuffer(src: number): void;
  115965. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  115966. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  115967. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  115968. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  115969. // Occlusion Query
  115970. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  115971. ANY_SAMPLES_PASSED: number;
  115972. QUERY_RESULT_AVAILABLE: number;
  115973. QUERY_RESULT: number;
  115974. }
  115975. interface WebGLBuffer {
  115976. references: number;
  115977. capacity: number;
  115978. is32Bits: boolean;
  115979. }
  115980. interface WebGLProgram {
  115981. transformFeedback?: WebGLTransformFeedback | null;
  115982. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  115983. }
  115984. interface EXT_disjoint_timer_query {
  115985. QUERY_COUNTER_BITS_EXT: number;
  115986. TIME_ELAPSED_EXT: number;
  115987. TIMESTAMP_EXT: number;
  115988. GPU_DISJOINT_EXT: number;
  115989. QUERY_RESULT_EXT: number;
  115990. QUERY_RESULT_AVAILABLE_EXT: number;
  115991. queryCounterEXT(query: WebGLQuery, target: number): void;
  115992. createQueryEXT(): WebGLQuery;
  115993. beginQueryEXT(target: number, query: WebGLQuery): void;
  115994. endQueryEXT(target: number): void;
  115995. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  115996. deleteQueryEXT(query: WebGLQuery): void;
  115997. }
  115998. interface WebGLUniformLocation {
  115999. _currentState: any;
  116000. }
  116001. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  116002. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  116003. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  116004. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116005. interface WebGLRenderingContext {
  116006. readonly RASTERIZER_DISCARD: number;
  116007. readonly DEPTH_COMPONENT24: number;
  116008. readonly TEXTURE_3D: number;
  116009. readonly TEXTURE_2D_ARRAY: number;
  116010. readonly TEXTURE_COMPARE_FUNC: number;
  116011. readonly TEXTURE_COMPARE_MODE: number;
  116012. readonly COMPARE_REF_TO_TEXTURE: number;
  116013. readonly TEXTURE_WRAP_R: number;
  116014. readonly HALF_FLOAT: number;
  116015. readonly RGB8: number;
  116016. readonly RED_INTEGER: number;
  116017. readonly RG_INTEGER: number;
  116018. readonly RGB_INTEGER: number;
  116019. readonly RGBA_INTEGER: number;
  116020. readonly R8_SNORM: number;
  116021. readonly RG8_SNORM: number;
  116022. readonly RGB8_SNORM: number;
  116023. readonly RGBA8_SNORM: number;
  116024. readonly R8I: number;
  116025. readonly RG8I: number;
  116026. readonly RGB8I: number;
  116027. readonly RGBA8I: number;
  116028. readonly R8UI: number;
  116029. readonly RG8UI: number;
  116030. readonly RGB8UI: number;
  116031. readonly RGBA8UI: number;
  116032. readonly R16I: number;
  116033. readonly RG16I: number;
  116034. readonly RGB16I: number;
  116035. readonly RGBA16I: number;
  116036. readonly R16UI: number;
  116037. readonly RG16UI: number;
  116038. readonly RGB16UI: number;
  116039. readonly RGBA16UI: number;
  116040. readonly R32I: number;
  116041. readonly RG32I: number;
  116042. readonly RGB32I: number;
  116043. readonly RGBA32I: number;
  116044. readonly R32UI: number;
  116045. readonly RG32UI: number;
  116046. readonly RGB32UI: number;
  116047. readonly RGBA32UI: number;
  116048. readonly RGB10_A2UI: number;
  116049. readonly R11F_G11F_B10F: number;
  116050. readonly RGB9_E5: number;
  116051. readonly RGB10_A2: number;
  116052. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  116053. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  116054. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  116055. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  116056. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  116057. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  116058. 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;
  116059. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  116060. readonly TRANSFORM_FEEDBACK: number;
  116061. readonly INTERLEAVED_ATTRIBS: number;
  116062. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  116063. createTransformFeedback(): WebGLTransformFeedback;
  116064. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  116065. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  116066. beginTransformFeedback(primitiveMode: number): void;
  116067. endTransformFeedback(): void;
  116068. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  116069. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116070. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116071. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  116072. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  116073. }
  116074. interface ImageBitmap {
  116075. readonly width: number;
  116076. readonly height: number;
  116077. close(): void;
  116078. }
  116079. interface WebGLQuery extends WebGLObject {
  116080. }
  116081. declare var WebGLQuery: {
  116082. prototype: WebGLQuery;
  116083. new(): WebGLQuery;
  116084. };
  116085. interface WebGLSampler extends WebGLObject {
  116086. }
  116087. declare var WebGLSampler: {
  116088. prototype: WebGLSampler;
  116089. new(): WebGLSampler;
  116090. };
  116091. interface WebGLSync extends WebGLObject {
  116092. }
  116093. declare var WebGLSync: {
  116094. prototype: WebGLSync;
  116095. new(): WebGLSync;
  116096. };
  116097. interface WebGLTransformFeedback extends WebGLObject {
  116098. }
  116099. declare var WebGLTransformFeedback: {
  116100. prototype: WebGLTransformFeedback;
  116101. new(): WebGLTransformFeedback;
  116102. };
  116103. interface WebGLVertexArrayObject extends WebGLObject {
  116104. }
  116105. declare var WebGLVertexArrayObject: {
  116106. prototype: WebGLVertexArrayObject;
  116107. new(): WebGLVertexArrayObject;
  116108. };
  116109. // Type definitions for WebVR API
  116110. // Project: https://w3c.github.io/webvr/
  116111. // Definitions by: six a <https://github.com/lostfictions>
  116112. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  116113. interface VRDisplay extends EventTarget {
  116114. /**
  116115. * Dictionary of capabilities describing the VRDisplay.
  116116. */
  116117. readonly capabilities: VRDisplayCapabilities;
  116118. /**
  116119. * z-depth defining the far plane of the eye view frustum
  116120. * enables mapping of values in the render target depth
  116121. * attachment to scene coordinates. Initially set to 10000.0.
  116122. */
  116123. depthFar: number;
  116124. /**
  116125. * z-depth defining the near plane of the eye view frustum
  116126. * enables mapping of values in the render target depth
  116127. * attachment to scene coordinates. Initially set to 0.01.
  116128. */
  116129. depthNear: number;
  116130. /**
  116131. * An identifier for this distinct VRDisplay. Used as an
  116132. * association point in the Gamepad API.
  116133. */
  116134. readonly displayId: number;
  116135. /**
  116136. * A display name, a user-readable name identifying it.
  116137. */
  116138. readonly displayName: string;
  116139. readonly isConnected: boolean;
  116140. readonly isPresenting: boolean;
  116141. /**
  116142. * If this VRDisplay supports room-scale experiences, the optional
  116143. * stage attribute contains details on the room-scale parameters.
  116144. */
  116145. readonly stageParameters: VRStageParameters | null;
  116146. /**
  116147. * Passing the value returned by `requestAnimationFrame` to
  116148. * `cancelAnimationFrame` will unregister the callback.
  116149. * @param handle Define the hanle of the request to cancel
  116150. */
  116151. cancelAnimationFrame(handle: number): void;
  116152. /**
  116153. * Stops presenting to the VRDisplay.
  116154. * @returns a promise to know when it stopped
  116155. */
  116156. exitPresent(): Promise<void>;
  116157. /**
  116158. * Return the current VREyeParameters for the given eye.
  116159. * @param whichEye Define the eye we want the parameter for
  116160. * @returns the eye parameters
  116161. */
  116162. getEyeParameters(whichEye: string): VREyeParameters;
  116163. /**
  116164. * Populates the passed VRFrameData with the information required to render
  116165. * the current frame.
  116166. * @param frameData Define the data structure to populate
  116167. * @returns true if ok otherwise false
  116168. */
  116169. getFrameData(frameData: VRFrameData): boolean;
  116170. /**
  116171. * Get the layers currently being presented.
  116172. * @returns the list of VR layers
  116173. */
  116174. getLayers(): VRLayer[];
  116175. /**
  116176. * Return a VRPose containing the future predicted pose of the VRDisplay
  116177. * when the current frame will be presented. The value returned will not
  116178. * change until JavaScript has returned control to the browser.
  116179. *
  116180. * The VRPose will contain the position, orientation, velocity,
  116181. * and acceleration of each of these properties.
  116182. * @returns the pose object
  116183. */
  116184. getPose(): VRPose;
  116185. /**
  116186. * Return the current instantaneous pose of the VRDisplay, with no
  116187. * prediction applied.
  116188. * @returns the current instantaneous pose
  116189. */
  116190. getImmediatePose(): VRPose;
  116191. /**
  116192. * The callback passed to `requestAnimationFrame` will be called
  116193. * any time a new frame should be rendered. When the VRDisplay is
  116194. * presenting the callback will be called at the native refresh
  116195. * rate of the HMD. When not presenting this function acts
  116196. * identically to how window.requestAnimationFrame acts. Content should
  116197. * make no assumptions of frame rate or vsync behavior as the HMD runs
  116198. * asynchronously from other displays and at differing refresh rates.
  116199. * @param callback Define the eaction to run next frame
  116200. * @returns the request handle it
  116201. */
  116202. requestAnimationFrame(callback: FrameRequestCallback): number;
  116203. /**
  116204. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  116205. * Repeat calls while already presenting will update the VRLayers being displayed.
  116206. * @param layers Define the list of layer to present
  116207. * @returns a promise to know when the request has been fulfilled
  116208. */
  116209. requestPresent(layers: VRLayer[]): Promise<void>;
  116210. /**
  116211. * Reset the pose for this display, treating its current position and
  116212. * orientation as the "origin/zero" values. VRPose.position,
  116213. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  116214. * updated when calling resetPose(). This should be called in only
  116215. * sitting-space experiences.
  116216. */
  116217. resetPose(): void;
  116218. /**
  116219. * The VRLayer provided to the VRDisplay will be captured and presented
  116220. * in the HMD. Calling this function has the same effect on the source
  116221. * canvas as any other operation that uses its source image, and canvases
  116222. * created without preserveDrawingBuffer set to true will be cleared.
  116223. * @param pose Define the pose to submit
  116224. */
  116225. submitFrame(pose?: VRPose): void;
  116226. }
  116227. declare var VRDisplay: {
  116228. prototype: VRDisplay;
  116229. new(): VRDisplay;
  116230. };
  116231. interface VRLayer {
  116232. leftBounds?: number[] | Float32Array | null;
  116233. rightBounds?: number[] | Float32Array | null;
  116234. source?: HTMLCanvasElement | null;
  116235. }
  116236. interface VRDisplayCapabilities {
  116237. readonly canPresent: boolean;
  116238. readonly hasExternalDisplay: boolean;
  116239. readonly hasOrientation: boolean;
  116240. readonly hasPosition: boolean;
  116241. readonly maxLayers: number;
  116242. }
  116243. interface VREyeParameters {
  116244. /** @deprecated */
  116245. readonly fieldOfView: VRFieldOfView;
  116246. readonly offset: Float32Array;
  116247. readonly renderHeight: number;
  116248. readonly renderWidth: number;
  116249. }
  116250. interface VRFieldOfView {
  116251. readonly downDegrees: number;
  116252. readonly leftDegrees: number;
  116253. readonly rightDegrees: number;
  116254. readonly upDegrees: number;
  116255. }
  116256. interface VRFrameData {
  116257. readonly leftProjectionMatrix: Float32Array;
  116258. readonly leftViewMatrix: Float32Array;
  116259. readonly pose: VRPose;
  116260. readonly rightProjectionMatrix: Float32Array;
  116261. readonly rightViewMatrix: Float32Array;
  116262. readonly timestamp: number;
  116263. }
  116264. interface VRPose {
  116265. readonly angularAcceleration: Float32Array | null;
  116266. readonly angularVelocity: Float32Array | null;
  116267. readonly linearAcceleration: Float32Array | null;
  116268. readonly linearVelocity: Float32Array | null;
  116269. readonly orientation: Float32Array | null;
  116270. readonly position: Float32Array | null;
  116271. readonly timestamp: number;
  116272. }
  116273. interface VRStageParameters {
  116274. sittingToStandingTransform?: Float32Array;
  116275. sizeX?: number;
  116276. sizeY?: number;
  116277. }
  116278. interface Navigator {
  116279. getVRDisplays(): Promise<VRDisplay[]>;
  116280. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  116281. }
  116282. interface Window {
  116283. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  116284. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  116285. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  116286. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116287. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  116288. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  116289. }
  116290. interface Gamepad {
  116291. readonly displayId: number;
  116292. }
  116293. interface XRDevice {
  116294. requestSession(options: XRSessionCreationOptions): Promise<XRSession>;
  116295. supportsSession(options: XRSessionCreationOptions): Promise<void>;
  116296. }
  116297. interface XRSession {
  116298. getInputSources(): Array<any>;
  116299. baseLayer: XRWebGLLayer;
  116300. requestFrameOfReference(type: string): Promise<void>;
  116301. requestHitTest(origin: Float32Array, direction: Float32Array, frameOfReference: any): any;
  116302. end(): Promise<void>;
  116303. requestAnimationFrame: Function;
  116304. addEventListener: Function;
  116305. }
  116306. interface XRSessionCreationOptions {
  116307. outputContext?: WebGLRenderingContext | null;
  116308. immersive?: boolean;
  116309. environmentIntegration?: boolean;
  116310. }
  116311. interface XRLayer {
  116312. getViewport: Function;
  116313. framebufferWidth: number;
  116314. framebufferHeight: number;
  116315. }
  116316. interface XRView {
  116317. projectionMatrix: Float32Array;
  116318. }
  116319. interface XRFrame {
  116320. getDevicePose: Function;
  116321. getInputPose: Function;
  116322. views: Array<XRView>;
  116323. baseLayer: XRLayer;
  116324. }
  116325. interface XRFrameOfReference {
  116326. }
  116327. interface XRWebGLLayer extends XRLayer {
  116328. framebuffer: WebGLFramebuffer;
  116329. }
  116330. declare var XRWebGLLayer: {
  116331. prototype: XRWebGLLayer;
  116332. new(session: XRSession, context?: WebGLRenderingContext): XRWebGLLayer;
  116333. };